#K60997. Metro Connectivity

    ID: 31210 Type: Default 1000ms 256MiB

Metro Connectivity

Metro Connectivity

You are given a metro system with n stations and m bidirectional routes connecting them. Determine whether the entire metro system is connected, i.e., every station is reachable from every other station.

Formally, let \(G=(V,E)\) be an undirected graph where \(V\) represents the stations and \(E\) represents the routes. The graph is connected if for every pair of vertices \(u,v \in V\), there exists a path between u and v.

If the network is connected, output YES; otherwise, output NO.

The input is read from standard input and the output should be written to standard output.

inputFormat

The first line of input contains two integers n and m (1 ≤ n ≤ 105, 0 ≤ m ≤ 105) representing the number of stations and routes respectively. The next m lines each contain two integers u and v (1 ≤ u, v ≤ n) which represent a bidirectional route between station u and station v.

outputFormat

Output a single line containing YES if all stations are connected, otherwise output NO.

## sample
5 4
1 2
2 3
3 4
4 5
YES