#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, a, b, temp;
  cin >> n;
  vector<long> v;
  bool flag = 0;
  cin >> a >> b;
  v.push_back(max(a, b));
  for (long i = 1; i < n; i++) {
    cin >> a >> b;
    if (v[i - 1] >= max(a, b))
      v.push_back(max(a, b));
    else if (v[i - 1] >= min(a, b))
      v.push_back(min(a, b));
    else {
      flag = 1;
      temp = i;
      break;
    }
  }
  for (long i = temp + 1; i < n; i++) {
    cin >> a >> b;
  }
  if (flag == 1)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}
