In this case, one student will be picked from each class. The number of student in class A is 26, so the chance for a student to be selected would be 1/26. The number of student in class B is 20, so the chance for a student to be selected would be 1/20
Assuming all the student has same chance to be selected, then the chance for both Grace and Ellie will be picked to attend the competition would be:
1/26 * 1/20= 1/520