#include <bits/stdc++.h>
using namespace std;
long long a[300010], b[300010], e[300010], o[300010], n1, n2, t, l, r, k, c, x,
    j, c1, c2, n, d, m, sum, fact[300010];
stack<long long> s;
deque<long long> q;
string st;
set<long long> se;
vector<long long> adj[100010];
vector<pair<long long, long long>> we[100010];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  k = 0;
  cin >> l >> r;
  x = max(l, r);
  for (long long i = 1; i < n; i++) {
    cin >> l >> r;
    if (l > r) {
      if (l <= x)
        x = l;
      else if (r <= x)
        x = r;
      else
        k = 1;
    } else {
      if (r <= x)
        x = r;
      else if (l <= x)
        x = l;
      else
        k = 1;
    }
  }
  if (k)
    cout << "NO\n";
  else
    cout << "YES\n";
  return 0;
}
