Rated Contest 1 P2 - Circular Motion

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Uniform Circular Motion, one worksheet reads. In his other hand, Max holds another worksheet titled Kinetic Energy and the Work-Energy Theorem. Which to do first? thinks Max, as he sits down in the library...

After coming just on time and narrowly avoiding the ire of Ms. Gugoiu in period one, Max is now on his period two spare! He is trying to catch up on physics homework, but he is not sure which of the two worksheets in his hands he should do first. He checks the course outline, which states something along these lines:

There are N worksheets in total, numbered from 1 to N, as well as M listings on prerequisite worksheets, which are pairs of worksheets (a, b) where worksheet a must be completed before worksheet b (or else Max won't understand anything on worksheet b). With this, it can also be determined that if worksheet a is a prerequisite to worksheet b, and worksheet b is a prerequisite to worksheet c, then worksheet a is also a prerequisite to worksheet c.

Max deems a worksheet a more important than another worksheet b if the number of worksheets that require a as a prerequisite is more than the number of worksheets that require b as a prerequisite. Can you help Max determine which worksheet is more important so he can prioritize his studying?

Constraints

2 \le N \le 10^5

1 \le M \le 10^5

1 \le a_i, b_i \le N

Input Specification

The first line of input will contain the integers N and M.

The next M lines will each contain two integers, a_i and b_i, stating that worksheet a_i must be completed before worksheet b_i. It is guaranteed that worksheet b_i is not a prerequisite to worksheet a_i.

The last line of input will contain A and B, the two worksheets in Max's hands.

Output Specification

Output A if worksheet A is more important, output B if worksheet B is more important, and output Either if neither is more important than the other.

Sample Input 1

6 5
2 3
3 5
3 4
1 4
4 6
1 2

Sample Output 1

B

Sample Input 2

5 4
1 4
2 3
4 5
2 5
2 1

Sample Output 2

Either

Comments

There are no comments at the moment.