#include using namespace std; bool dp[6][20001]; vector adj[20001]; int main(void) { cin.tie(0); ios::sync_with_stdio(false); int n, m, a, b; cin >> n >> m; for (int i = 0; i < m; i++) { cin >> a >> b; adj[a].push_back(b); adj[b].push_back(a); } dp[0][1] = true; for (int j = 0; j < 5; j++) { for (int k = 1; k <= n; k++) { if (dp[j][k] == false) continue; for (auto u : adj[k]) { dp[j + 1][u] = true; } } } if (dp[5][1]) { cout << "YES" << '\n'; //return 0; } else { cout << "NO" << '\n'; } return 0; }