#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, 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; A = mat(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; } 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] == 0) cout << "NO\n"; else cout << "YES\n"; return 0; }