#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define Getsign(n) ((n > 0) - (n < 0)) #define QWERTYR(c) (c == 'y' || c == 'u' || (c >= 'h' && c <= 'p') ? true : false) map roma_time = { { "I",1 },{ "II",2 },{ "III",3 },{ "IIII",4 },{ "V",5 },{ "VI",6 },{ "VII",7 },{ "VIII",8 },{ "IX",9 },{ "X",10 },{ "XI",11 },{ "XII",12 } }; typedef vector Ivec; typedef pair pii; int main() { int n, m; scanf("%d %d", &n, &m); vector> graph(n, vector()); for (int i = 0; m > i; i++) { int a, b; scanf("%d %d", &a, &b); a--; b--; graph[a].push_back(b); graph[b].push_back(a); } queue que; array tesu = {}; for (int i = 0; graph[0].size() > i; i++) { tesu[graph[0][i]] = 1; que.push(graph[0][i]); } while (!que.empty()) { int vertex = que.front(); que.pop(); if (tesu[vertex]) { for (int i = 0; graph[vertex].size() > i; i++) { if (tesu[graph[vertex][i]] == 2) { printf("YES\n"); return 0; } } } else { for (int i = 0; graph[vertex].size() > i; i++) { if (tesu[graph[vertex][i]] == 0) { tesu[graph[vertex][i]] = 2; que.push(graph[vertex][i]); } } } } printf("NO\n"); return 0; }