fn.cpp
#include <iostream>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <string>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define DEBUG(x) cout << ">>> " #x << " : " << x << endl;
int main() {
int n,m;
while( scanf("%d %d", &n, &m) == 2 ) {
map<int,int> neighbours;
bool found = false;
for( int i = 0; i < m; i++ ) {
int u,v;
scanf( "%d %d", &u, &v );
if( ++neighbours[u] >= 4 ) { found = true; }
if( ++neighbours[v] >= 4 ) { found = true; }
}
if( found ) {
printf( "YES\n" );
} else {
printf( "NO\n" );
}
}
return 0;
}