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