#include <bits/stdc++.h>
using namespace std;
int a[100000 + 5], b[100000 + 5];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i], &b[i]);
    if (a[i] > b[i]) swap(a[i], b[i]);
  }
  int s = b[1];
  for (int i = 2; i <= n; i++) {
    if (b[i] <= s)
      s = b[i];
    else if (a[i] <= s)
      s = a[i];
    else {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}
