#include <iostream>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int ms[n][n] = {};
for (int i = 0; i < m; i++) {
int a, b;
cin >> a >> b;
a--; b--;
if (ms[a][b] == 1 || ms[b][a] == 1) {
cout << "YES" << endl;
return 0;
}
ms[a][b] = 1;
ms[b][a] = 1;
}
cout << "NO" << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CiAgICBpbnQgbiwgbTsKICAgIGNpbiA+PiBuID4+IG07CiAgICBpbnQgbXNbbl1bbl0gPSB7fTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbTsgaSsrKSB7CiAgICAgICAgaW50IGEsIGI7CiAgICAgICAgY2luID4+IGEgPj4gYjsKICAgICAgICBhLS07IGItLTsgIAogICAgICAgIGlmIChtc1thXVtiXSA9PSAxIHx8IG1zW2JdW2FdID09IDEpIHsKICAgICAgICAgICAgY291dCA8PCAiWUVTIiA8PCBlbmRsOwogICAgICAgICAgICByZXR1cm4gMDsgIAogICAgICAgIH0KICAgICAgICBtc1thXVtiXSA9IDE7CiAgICAgICAgbXNbYl1bYV0gPSAxOwogICAgfQogICAgY291dCA8PCAiTk8iIDw8IGVuZGw7CgogICAgcmV0dXJuIDA7Cn0=