#include <iostream>
#include <vector>
using namespace std;
void DFS( int node, const vector< vector< int >> & adjList, vector< bool > & visited, int destination) {
// If we've reached the destination, print YES and return
if ( node == destination) {
cout << "YES" << endl;
exit ( 0 ) ; // Exit once we find the path
}
visited[ node] = true ; // Mark the current node as visited
// Explore all neighbors
for ( int neighbor : adjList[ node] ) {
if ( ! visited[ neighbor] ) {
DFS( neighbor, adjList, visited, destination) ; // Recur for unvisited neighbors
}
}
}
int main( ) {
int n, m;
cin >> n >> m; // Read number of nodes and edges
vector< vector< int >> adjList( n) ; // Adjacency list to store the graph
// Read edges and build the graph
for ( int i = 0 ; i < m; i++ ) {
int u, v;
cin >> u >> v;
adjList[ u] .push_back ( v) ; // Add v to u's list
adjList[ v] .push_back ( u) ; // Add u to v's list (undirected graph)
}
int start, destination;
cin >> start >> destination; // Read the start and destination nodes
vector< bool > visited( n, false ) ; // Initialize the visited array
DFS( start, adjList, visited, destination) ; // Call DFS to check for path
cout << "NO" << endl; // If we reach here, there is no path
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdm9pZCBERlMoaW50IG5vZGUsIGNvbnN0IHZlY3Rvcjx2ZWN0b3I8aW50Pj4mIGFkakxpc3QsIHZlY3Rvcjxib29sPiYgdmlzaXRlZCwgaW50IGRlc3RpbmF0aW9uKSB7CiAgICAvLyBJZiB3ZSd2ZSByZWFjaGVkIHRoZSBkZXN0aW5hdGlvbiwgcHJpbnQgWUVTIGFuZCByZXR1cm4KICAgIGlmIChub2RlID09IGRlc3RpbmF0aW9uKSB7CiAgICAgICAgY291dCA8PCAiWUVTIiA8PCBlbmRsOwogICAgICAgIGV4aXQoMCk7ICAvLyBFeGl0IG9uY2Ugd2UgZmluZCB0aGUgcGF0aAogICAgfQoKICAgIHZpc2l0ZWRbbm9kZV0gPSB0cnVlOyAgLy8gTWFyayB0aGUgY3VycmVudCBub2RlIGFzIHZpc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