Company

No attempts yetTime limit1sMemory limit128 MB

Problem

At the Plumsoft company there is a hierarchy among employees: some employees are the boss of others. Person AA is in charge of person BB if there is a chain of employees P1=A, P2, , Pk=BP_1 = A,\ P_2,\ \dots,\ P_k = B such that P1P_1 is P2P_2's boss, P2P_2 is P3P_3's boss, \dots, and Pk1P_{k-1} is PkP_k's boss. Plumsoft is a very well-run company, so you may assume that no two employees are each in charge of the other (the hierarchy has no cycles).

Management wants to cut the cost of meetings, so they plan to keep only some of the existing direct "AA is the boss of BB" relations while preserving every "AA is in charge of BB" relation. Help them keep as few direct "boss" relations as possible without changing who is in charge of whom.

Input

The first line contains two integers NN and MM separated by a space (1N10001 \le N \le 1000, 1M100001 \le M \le 10000), where NN is the number of employees and MM is the number of direct "boss" relations. Employees are labeled 11 through NN. Each of the next MM lines contains two labels AA and BB separated by a space, meaning AA is the boss of BB.

Output

On the first line, print a single integer MminM_{min} — the minimum number of direct "boss" relations that must be kept so that every "in charge of" relation is preserved. Then print those MminM_{min} relations, one per line, as two labels AA and BB separated by a space (meaning AA is still the boss of BB). Print the relations in ascending order, sorted first by AA and then by BB.