A simple problem

Time Limit: 1000 ms Memory Limit: 65536 KiB

Problem Description

       This is a very easy problem, so I do not want to write a long description for it.
       Given an undirected graph with N vertexes and M edges and a vertex S of the graph, your task is to check whether all the loops of the graph contains vertex-S.
       We guarantee that the given graph has at least one loop.

Input

    There are multiple test cases.
   For each test case:
   The fist line is three integers N M and S (1 <= N <= 10000 , M <= 100000 , 1<= S <= N).
   Each of the following M lines contains two integers UV (1<= U,V <= N). It shows that there is an edge between the U-th vertex and the V-th vertex.

Output

     For each test case,output one line containing a string “YES” or “NO” (without the quotes).

Sample Input

5 6 3
1 2
1 5
2 3
2 4
2 5
4 5
5 6 2
1 2
1 5
2 3
2 4
2 5
4 5 

Sample Output

NO
YES

Hint

 

Source

qinchuan