#include using namespace std; typedef vector vec; typedef vector mat; vec mul(const mat& A, const vec& x) { int s = x.size(); vec ret(s, 0); for (int i = 0; i < s; i++) { for (int j = 0; j < s; j++) { ret[i] += A[i][j] * x[j]; } } return ret; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; mat A(n, vec(n, 0)); for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; a--; b--; A[a][b] = 1; A[b][a] = 1; } vec x(n, 0); x[0] = 1; for (int i = 0; i < 5; i++) { x = mul(A, x); } if (x[0] == 0) cout << "NO\n"; else cout << "YES\n"; return 0; }