Alice finally finished her CS assignment and programmed her robot to explore a directed graph G with n nodes (numbered 1 through n) and m edges.
Alice programmed the robot with a series of k instructions. The robot will attempt to execute one instruction per second in the given order; it won't repeat any instruction or return to an instruction it didn't execute. Each instruction is of the form "if the robot is currently at node x, it will move to node y". Note that if the robot is not currently at node x, it will ignore such an instruction. The robot is initially located at node 1.
Unfortunately, the robot is a bit buggy — at one moment in time, it can move from its current node to an arbitrary neighboring node (a node to which an edge leads from the current node). Note that this bug could have happened before any instructions, between any two instructions, or after all instructions; however, it couldn't have happened multiple times. It is also possible that this bug did not happen at all.
Alice is having trouble debugging the robot, and would like your help to determine all nodes where the robot could be located at the end.
for each valid i
for each valid i
each instruction for the robot will correspond to an existing directed edge
the graph won't contain loops — for each valid i
the graph won't contain multiple edges — for each valid
The first line of the input contains three integers n, m and k, denoting the number of nodes, the number of edges and the number of instructions respectively.
Each of the following m lines contains two space-separated integers and denoting a directed edge from node to node .
Each of the following k lines contains two space-separated integers and denoting an instruction for the robot.
On the first line, print a single integer F — the number of possible final nodes for the robot.
On the second line, print F space-separated integers, representing the possible final nodes for the robot, in increasing order.
Some of the possible scenarios are the following (the starred arrows represent the robot moving because a bug occured):
1 -> 2 -> 3
1 -> 2 -*> 3 -> 4
There may be more scenarios where the robot took different paths; however, there is no way for the robot to end up in node 2 or back in node 1.