def solve():
n=int(input()) x=10**9 for _ in range(n): w,h=sorted(map(int,input().split())) if h<=x: x=h elif w<=x: x=w else:
print('NO') return
print('YES')
solve()
#include <bits/stdc++.h>
using namespace std;
#define int long long
bool isPrime(int n)
{
for (int i = 2; i * i <= n; ++i)
{
if (n % i == 0)
{
return false;
}
}
return true;
}
int mod = 1e9 + 7;
int power(int x, int y)
{
int z = 1;
x = x % mod;
while (y > 0)
{
if (y & 1)
z = (z * x) % mod;
y = y >> 1;
x = (x * x) % mod;
}
return z;
}
int lcm(int a, int b)
{
return (a * b) / __gcd(a, b);
}
bool so(const pair<int, int> &a,
const pair<int, int> &b)
{
if (a.first != b.first)
return (a.first < b.first);
else
return (a.second > b.second);
}
int getsum(int n)
{
int sum = 0;
while (n != 0)
{
sum = sum + n % 10;
n = n / 10;
}
return sum;
}
void sort(map<int, int> &M) // sort map by value
{
// Declare a multimap
multimap<int, int> MM;
// Insert every (key-value) pairs from
// map M to multimap MM as (value-key)
// pairs
for (auto &it : M)
{
MM.insert({it.second, it.first});
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
// int t;
// cin >> t;
// while (t--)
// {
int n;
cin>>n;
vector<int> v1;
vector<int> v2;
for(int i=0;i<n;i++){
int w,h;
cin>>w>>h;
v1.push_back(max(w,h));
v2.push_back(min(w,h));
}
int prev=v1[0];
bool f=true;
for(int i=0;i<n-1;i++){
if(prev<v2[i+1]){
f=false;
break;
}
else{
if(prev>=v1[i+1]){
prev=v1[i+1];
}
else{
prev=v2[i+1];
}
}
}
if(f){
cout<<"YES"<<endl;
}
else{
cout<<"NO"<<endl;
}
// }
}
102. Binary Tree Level Order Traversal | 96. Unique Binary Search Trees |
75. Sort Colors | 74. Search a 2D Matrix |
71. Simplify Path | 62. Unique Paths |
50. Pow(x, n) | 43. Multiply Strings |
34. Find First and Last Position of Element in Sorted Array | 33. Search in Rotated Sorted Array |
17. Letter Combinations of a Phone Number | 5. Longest Palindromic Substring |
3. Longest Substring Without Repeating Characters | 1312. Minimum Insertion Steps to Make a String Palindrome |
1092. Shortest Common Supersequence | 1044. Longest Duplicate Substring |
1032. Stream of Characters | 987. Vertical Order Traversal of a Binary Tree |
952. Largest Component Size by Common Factor | 212. Word Search II |
174. Dungeon Game | 127. Word Ladder |
123. Best Time to Buy and Sell Stock III | 85. Maximal Rectangle |
84. Largest Rectangle in Histogram | 60. Permutation Sequence |
42. Trapping Rain Water | 32. Longest Valid Parentheses |
Cutting a material | Bubble Sort |