Task
A department lists its courses and which courses must be taken before others. Write plan_courses in planner.c so the program prints an order in which a student can take every course, with each course after all of its prerequisites.
When more than one course is available, take the one whose code is alphabetically smallest, comparing codes character by character as strcmp does. If the prerequisites form a cycle, no order exists: print IMPOSSIBLE instead.
Input
The first line holds n and m: the number of courses and the number of prerequisite pairs.
The second line holds the n course codes, separated by spaces.
Each of the next m lines holds two codes A B, meaning course A requires course B.
Output
One line with the course codes in study order, separated by single spaces, or the single word IMPOSSIBLE.
Constraints
1 ≤ n ≤ 100, and every code has 1 to 10 uppercase letters or digits.
Every code in a pair appears on the second line, and no pair appears twice.
Codes compare as strings, so MATH10 comes before MATH9.
Examples
4 4
CS101 CS102 CS201 MATH21
CS102 CS101
CS201 CS102
CS201 MATH21
MATH21 CS101
prints CS101 CS102 MATH21 CS201. After CS101, both CS102 and MATH21 are available, and CS102 is smaller.
3 3
CS201 CS202 CS203
CS202 CS201
CS203 CS202
CS201 CS203
prints IMPOSSIBLE. CS201 needs CS203, which needs CS202, which needs CS201 again, so none of them can be taken first.