{"problem":{"name":"Who is Saikyo?","description":{"content":"There are $N$ competitive programmers numbered person $1$, person $2$, $\\ldots$, and person $N$.   There is a relation called **superiority** between the programmers. For all pairs of distinct program","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc313_b"},"statements":[{"statement_type":"Markdown","content":"There are $N$ competitive programmers numbered person $1$, person $2$, $\\ldots$, and person $N$.  \nThere is a relation called **superiority** between the programmers. For all pairs of distinct programmers $($person $X$, person $Y$$)$, exactly one of the following two relations holds: \"person $X$ is stronger than person $Y$\" or \"person $Y$ is stronger than person $X$.\"  \nThe superiority is **transitive**. In other words, for all triplets of distinct programmers $($person $X$, person $Y$, person $Z$$)$, it holds that:\n\n*   if person $X$ is stronger than person $Y$ and person $Y$ is stronger than person $Z$, then person $X$ is stronger than person $Z$.\n\nA person $X$ is said to be the **strongest programmer** if person $X$ is stronger than person $Y$ for all people $Y$ other than person $X$. (Under the constraints above, we can prove that there is always exactly one such person.)\nYou have $M$ pieces of information on their superiority. The $i$\\-th of them is that \"person $A_i$ is stronger than person $B_i$.\"  \nCan you determine the strongest programmer among the $N$ based on the information?  \nIf you can, print the person's number. Otherwise, that is, if there are multiple possible strongest programmers, print `-1`.\n\n## Constraints\n\n*   $2 \\leq N \\leq 50$\n*   $0 \\leq M \\leq \\frac{N(N-1)}{2}$\n*   $1 \\leq A_i, B_i \\leq N$\n*   $A_i \\neq B_i$\n*   If $i \\neq j$, then $(A_i, B_i) \\neq (A_j, B_j)$.\n*   There is at least one way to determine superiorities for all pairs of distinct programmers, that is consistent with the given information.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $M$\n$A_1$ $B_1$\n$A_2$ $B_2$\n$\\vdots$\n$A_M$ $B_M$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc313_b","tags":[],"sample_group":[["3 2\n1 2\n2 3","1\n\nYou have two pieces of information: \"person $1$ is stronger than person $2$\" and \"person $2$ is stronger than person $3$.\"  \nBy the transitivity, you can also infer that \"person $1$ is stronger than person $3$,\" so person $1$ is the strongest programmer."],["3 2\n1 3\n2 3","\\-1\n\nBoth person $1$ and person $2$ may be the strongest programmer. Since you cannot uniquely determine which is the strongest, you should print `-1`."],["6 6\n1 6\n6 5\n6 2\n2 3\n4 3\n4 2","\\-1"]],"created_at":"2026-03-03 11:01:14"}}