Matt's Graph Book
Practice
3.8 (24 votes)
Algorithms
Easy
Graphs
Hiring
Problem
72% Success 8770 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Matt loves Graph Theory. He recently enrolled into the Algorithms course and started liking it too. His teacher understood his love for graphs and decided to give him a problem.

She gives him a Tree and asks him to write a program to find if it's connected or not. She realizes that Matt would do this in no time. So, instead she gives him a Graph and then removes a vertex from it and now asks him to find if the resultant graph is connected or not.

Since he is new to programming and algorithms, you have to help him solve this problem.

Input

First line contains a single integer N denoting the number of vertices in the graph. Second line contains a single integer k denoting the number of edges in the graph. k lines follow each containing two space separated integers a and b denoting the edge between the vertices a and b. Then, the last line contains a single integer x which denotes the vertex that is removed from the graph.

Output

"Connected" (without quotes) if the resultant graph is connected. "Not Connected" (without quotes), otherwise.

Constraints

1 ≤ N ≤ 105
1 ≤ k ≤ 2×105
0 ≤ a,b ≤ 105
0 ≤ x ≤ 105

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
33 votes
Tags:
AlgorithmsDepth First SearchEasyGraphsTrees
Points:20
37 votes
Tags:
AlgorithmsApprovedBacktrackingDepth First SearchEasyGraphsOpenRecursion
Points:20
66 votes
Tags:
ApprovedDepth First SearchDisjoint setEasyGraphsOpen