#C57. Find the Person Trusted by Everyone
Find the Person Trusted by Everyone
Find the Person Trusted by Everyone
You are given a city with (N) people and (M) trust relationships. Each trust relationship is represented as an ordered pair ((A, B)) which indicates that person (A) trusts person (B). A person is considered the celebrity (or the most trusted person) if they are trusted by everyone else (i.e. they receive trust from (N - 1) people) and they trust no one (i.e. they send out 0 trusts).
In the special case where (N = 1), if there are no trust relationships (i.e. (M = 0)), the single person is trivially considered trusted by everyone and the answer is 1. However, if there exists any trust relationship (including self-trust), the answer should be -1.
Your task is to determine if such a person exists. If so, print their label; otherwise, print -1.
inputFormat
The input is read from standard input (stdin).
The first line contains two integers (N) and (M), representing the number of people and the number of trust relationships, respectively.
Each of the following (M) lines contains two integers (A) and (B), indicating that person (A) trusts person (B).
outputFormat
The output should be printed to standard output (stdout).
Print the label of the person who is trusted by everyone but trusts no one. If no such person exists, print -1.## sample
1 0
1