#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     vector<pair<int, int>> v;     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       v.push_back(make_pair(a, b));     }     int x1 = v[0].first;     int y1 = v[0].second;     vector<int> p1, p2;     for (int i = 1; i < m; i++) {       int a = v[i].first;       int b = v[i].second;       if (x1 != a && x1 != b) {         p1.push_back(i);       }       if (y1 != a && y1 != b) {         p2.push_back(i);       }     }     if (p1.size() == 0 || p2.size() == 0) {       cout <<  YES  << endl;       return 0;     }     x1 = v[p1[0]].first;     y1 = v[p1[0]].second;     int c1 = 0, c2 = 0, c3 = 0, c4 = 0;     for (int i = 1; i < p1.size(); i++) {       int a = v[p1[i]].first;       int b = v[p1[i]].second;       if (x1 != a && x1 != b) {         c1++;       }       if (y1 != a && y1 != b) {         c2++;       }     }     x1 = v[p2[0]].first;     y1 = v[p2[0]].second;     for (int i = 1; i < p2.size(); i++) {       int a = v[p2[i]].first;       int b = v[p2[i]].second;       if (x1 != a && x1 != b) {         c3++;       }       if (y1 != a && y1 != b) {         c4++;       }     }     if (c1 == 0 || c2 == 0) {       cout <<  YES  << endl;     } else if (c3 == 0 || c4 == 0) {       cout <<  YES  << endl;     } else {       cout <<  NO  << endl;     }     return 0;   }   