#include using namespace std; long long n, x, y, a, b, s1, s2; int main() { cin >> n; cin >> a >> b; s1 = 0; s2 = 0; for (int i = 1; i < n; i++) { cin >> x >> y; if (x != a) s1 = 1; if (y != b) s2 = 1; } if (s1 * s2 == 0) cout << "YES"; else cout << "NO"; return 0; }