#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) {
cout << "YES" << endl;
return 0;
}
ms[a][b] = 1;
}
cout << "NO" << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CiAgICBpbnQgbiwgbTsKICAgIGNpbiA+PiBuID4+IG07CiAgICBpbnQgbXNbbl1bbl0gPSB7fTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbTsgaSsrKSB7CiAgICAgICAgaW50IGEsIGI7CiAgICAgICAgY2luID4+IGEgPj4gYjsKICAgICAgICBhLS07IGItLTsgIAogICAgICAgIGlmIChtc1thXVtiXSA9PSAxKSB7CiAgICAgICAgICAgIGNvdXQgPDwgIllFUyIgPDwgZW5kbDsKICAgICAgICAgICAgcmV0dXJuIDA7ICAKICAgICAgICB9CiAgICAgICAgbXNbYV1bYl0gPSAxOwogICAgfQogICAgY291dCA8PCAiTk8iIDw8IGVuZGw7CgogICAgcmV0dXJuIDA7Cn0=