import java.util.*;

public class Test{

     static int  primeFactors(int n)
    {
        ArrayList<Integer> a = new ArrayList<>();
        while (n%2==0)
        {
            n /= 2;
            a.add(2);
        }

        for (int i = 3; i <= Math.sqrt(n); i+= 2)
        {
            while (n%i == 0)
            {
                a.add(i);
                n /= i;
            }
        }

        if (n > 2)
            a.add(n);
        Collections.sort(a);
        //System.out.println(a);
        return a.get(0);
    }
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int t=sc.nextInt();
        while(t-->0)
        {
            int n=sc.nextInt();
            int k=sc.nextInt();
            int sum=n;
            for(int i=0;i<k;i++)
            {
                sum=sum+primeFactors(sum);
            }
            System.out.println(sum);
        }
    }

}


import java.io.*;
import java.util.*;

public class GFG {
    static int div(int n){
        int a=(int) Math.sqrt(n);
        for(int i=2;i<=a;i++){
            if(n%i==0){
                return i;
            }
        }
        return n;
    }
	public static void main (String[] args)throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t=Integer.parseInt(br.readLine());
		for(int l=0;l<t;l++){
		int n;
		int k;
		String[] input=br.readLine().split(" ");
		n=Integer.parseInt(input[0]);
		k=Integer.parseInt(input[1]);
		int divisor=div(n);
		n=n+divisor;
		n=n+(k-1)*2;
		System.out.println(n);
		}
	}
}


import java.util.*;

public class Test{

    static Scanner sc = new Scanner(System.in);
    static int divi(int n)
    {
        int div=0;
        boolean flag=false;
        for(int i=2;i<=n/2;i++)
        {
            if(n%i==0)
            {
                flag=true;
                div=i;
                break;
            }
        }
        if(flag)
            return div;
        else
            return n;
    }
    public static void main(String[] args) {
        int t=sc.nextInt();
        while(t-->0)
        {
            int n=sc.nextInt();
            int k=sc.nextInt();
            int sum=n;
            for(int i=0;i<k;i++)
            {
                sum=sum+divi(sum);
            }
            System.out.println(sum);
        }
    }

}


import java.util.*;
import java.io.*;
public class HelloWorld{

    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

    static int fn (int n){
        if (n%2 == 0){
            return 2;
        }else{
            for (int i = 3;i*i<=n;i=i+2){
                if (n%i ==0){
                    return n;
                }
            }
        }
        return n;

    }

     public static void main(String []args) throws java.lang.Exception{
         Reader sc = new Reader();
         int test = sc.nextInt();
         while (test>0){
             int n = sc.nextInt();
             int k = sc.nextInt();
             for (int i =0;i<k;i++){
                 n = fn(n)+n;
             }
             System.out.println(n);
             test--;
         }
     }
}


import java.util.*;
import java.io.*;
public class HelloWorld{

    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

    static long fn (long n){
        if (n%2 == 0){
            return 2;
        }else{
            for (int i = 3;i*i<=n;i=i+2){
                if (n%i ==0){
                    return n;
                }
            }
        }
        return n;

    }

     public static void main(String []args) throws java.lang.Exception{
         Reader sc = new Reader();
         int test = sc.nextInt();
         while (test>0){
             long n = sc.nextLong();
             long k = sc.nextLong();
             long one = fn(n);
             long y = (k-1)*2;
             long ans = n+one+y;

             System.out.println(ans);
             test--;
         }
     }
}


import java.util.*;
import java.io.*;
public class HelloWorld{

    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

    static long fn (long n){
        if (n%2 == 0){
            return 2;
        }else{
            for (int i = 3;i*i<=n;i=i+2){
                if (n%i ==0){
                    return i;
                }
            }
        }
        return n;

    }

     public static void main(String []args) throws java.lang.Exception{
         Reader sc = new Reader();
         int test = sc.nextInt();
         while (test>0){
             long n = sc.nextLong();
             long k = sc.nextLong();
             long ans = 0;
             if (n%2 ==0){
                 n = n+2;
             }else{
                 n = fn(n)+n;
             }
             n += (k-1)*2;
             System.out.println(n);
             test--;
         }
     }
}


import java.util.*;
public class HelloWorld{
    static int fn (int n){
        if (n%2 == 0){
            return 2;
        }else{
            for (int i = 3;i*i<=n;i=i+2){
                if (n%i ==0){
                    return n;
                }
            }
        }
        return n;

    }

     public static void main(String []args){
         Scanner sc = new Scanner(System.in);
         int test = sc.nextInt();
         while (test>0){
             int n = sc.nextInt();
             int k = sc.nextInt();
             for (int i =0;i<k;i++){
                 n = fn(n)+n;
             }
             System.out.println(n);
             test--;
         }
     }
}


#include<bits/stdc++.h>
#define int long long int
#define TRY_HARD ios_base::sync_with_stdio(false);  cin.tie(NULL);  cout.tie(NULL);
using namespace std;

bool isPrime(int n)
{
    // Corner case
    if (n <= 1)
        return false;

    // Check from 2 to n-1
    for (int i = 2; i < n; i++)
        if (n % i == 0)
            return false;

    return true;
}

signed main()
 {
	TRY_HARD ;
	int t ;
	cin >> t ;
	while ( t-- )
	{
		int n ;
		vector <pair < int , int >> v ;
		cin >> n ;
		for ( int i = 0 ; i < n ; i++ )
		{
			int a , b ;
			cin >> a >> b ;

			v.push_back(make_pair( a , b ) ) ;

		}
		if ( n == 1 )
		{
			if ( v[0].first >= v[0].second )
			cout << "YES" ;
			else
			cout << "NO" ;
		}

		else
		{
			int flag = 1 ;
		for ( int i = 0 ; i < v.size() -1  ; i++ )
		{
			if ( v[i].first > v[i+1].first)
			{
				cout << "NO" ;
				flag = 0 ;
			}
			else
			if ( v[i].first < v[i].second )
			{
				cout << "NO" ;
				flag = 0 ;
			}
			else
			if ( v[i].second > v[i+1].second )
			{
				cout << "NO" ;
				flag = 0 ;
			}
		}
		if ( v[v.size()-1].first < v[v.size()-1].second )
		{
			cout << "NO" ;
		   flag = 0 ;
		}
		if ( flag == 1 )
		cout << "YES" ;
		}
		cout << endl ;
	}

}


#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable: 4996)
#define MAX 100+1

int t, n, p[MAX], c[MAX], flag, play, complete;

int main() {
	scanf("%d", &t);
	for (int a = 0; a < t; a++) {
		scanf("%d", &n);
		for (int i = 0; i < n; i++) scanf("%d %d", &p[i], &c[i]);
		flag = 0;
		play = complete = -1;
		for (int i = 0; i < n; i++) {
			if (p[i] > c[i]) flag = 1;
			if (p[i] < play) flag = 1;
			if (c[i] < complete) flag = 1;
			if (p[i] <= complete && complete >0) flag = 1;
			if (p > c) flag = 1;
			play = p[i];	complete = c[i];
		}
		printf("%s\n", flag == 0 ? "YES" : "NO");
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable: 4996)
#define MAX 100+1

int t, n, p[MAX], c[MAX], flag, play, complete;

int main() {
	scanf("%d", &t);
	for (int a = 0; a < t; a++) {
		scanf("%d", &n);
		for (int i = 0; i < n; i++) scanf("%d %d", &p[i], &c[i]);
		flag = 0;
		play = complete = -1;
		for (int i = 0; i < n; i++) {
			if (c[i] < complete || p[i]<play) flag = 1;
			if (p[i] < c[i]) flag = 1;
			if (p[i] == play && c[i] != complete) flag = 1;
			play = p[i];
			complete = c[i];
		}
		printf("%s\n", flag == 0 ? "YES" : "NO");
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable: 4996)
#define MAX 100+1

int t, n, p[MAX], c[MAX], flag, play, complete;

int main() {
	scanf("%d", &t);
	for (int a = 0; a < t; a++) {
		scanf("%d", &n);
		for (int i = 0; i < n; i++) scanf("%d %d", &p[i], &c[i]);
		flag = 0;
		play = complete = -1;
		for (int i = 0; i < n; i++) {
			if (p[i] > c[i]) flag = 1;
			if (p[i] < play) flag = 1;
			if (c[i] < complete) flag = 1;
			if (p[i] <= complete && complete >0) flag = 1;
			if (p[i] > c[i]) flag = 1;
			play = p[i];	complete = c[i];
		}
		printf("%s\n", flag == 0 ? "YES" : "NO");
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable: 4996)
#define MAX 100+1

int t, n, p[MAX], c[MAX], flag, play, complete;

int main() {
	scanf("%d", &t);
	for (int a = 0; a < t; a++) {
		scanf("%d", &n);
		for (int i = 0; i < n; i++) scanf("%d %d", &p[i], &c[i]);
		flag = 0;
		play = complete = -1;
		for (int i = 0; i < n; i++) {
			if (c[i] < complete || p[i]<play) flag = 1;
			if (p[i] < c[i]) flag = 1;
			play = p[i];
			complete = c[i];
		}
		printf("%s\n", flag == 0 ? "YES" : "NO");
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable: 4996)

int t, n, p, c, far, play, flag;

int main() {
	scanf("%d", &t);
	for (int a = 0; a < t; a++) {
		scanf("%d", &n);
		far = -1;
		flag = 0;
		play = -1;
		for (int i = 0; i < n; i++) {
			scanf("%d %d", &p, &c);
			if (p <= far) flag = 1;
			if (c < far) flag = 1;
			else far = c;
			if (p < play) flag = 1;
			else play = p;
		}
		printf("%s\n", flag == 0 ? "YES" : "NO");
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable: 4996)

int t, n, p, c, far, play, flag;

int main() {
	scanf("%d", &t);
	for (int a = 0; a < t; a++) {
		scanf("%d", &n);
		far = -1;
		flag = 0;
		play = -1;
		for (int i = 0; i < n; i++) {
			scanf("%d %d", &p, &c);
			if (flag == 0) {
				if (c - far > 0 && p - play <= 0) {
					flag = 1;
				}
			}
			if (p <= far) flag = 1;
			if (c < far) flag = 1;
			else far = c;
			if (p < play) flag = 1;
			else play = p;
			if (p < c) flag = 1;
		}
		printf("%s\n", flag == 0 ? "YES" : "NO");
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable: 4996)

int t, n, p[101], c[101], flag, play, complete;

int main() {
	scanf("%d", &t);
	for (int a = 0; a < t; a++) {
		scanf("%d", &n);
		for (int i = 0; i < n; i++) scanf("%d %d", &p[i], &c[i]);
		flag = 0;
		play = complete = -1;
		for (int i = 0; i < n; i++) {
			if (c[i] < complete || p[i]<play) flag = 1;
			if (p[i] < c[i]) flag = 1;
			play = p[i];
			complete = c[i];
		}
		printf("%s\n", flag == 0 ? "YES" : "NO");
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable: 4996)
#define MAX 100+1

int t, n, p[MAX], c[MAX], flag, play, complete;

int main() {
	scanf("%d", &t);
	for (int a = 0; a < t; a++) {
		scanf("%d", &n);
		for (int i = 0; i < n; i++) scanf("%d %d", &p[i], &c[i]);
		flag = 0;
		play = complete = -1;
		for (int i = 0; i < n; i++) {
			if (c[i] < complete || p[i]<play) flag = 1;
			if (p[i] < c[i]) flag = 1;
			if (p[i]- play < c[i]- complete) flag = 1;
			play = p[i];
			complete = c[i];
		}
		printf("%s\n", flag == 0 ? "YES" : "NO");
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable: 4996)

int t, n, p, c, far, play, flag;

int main() {
	scanf("%d", &t);
	for (int a = 0; a < t; a++) {
		scanf("%d", &n);
		far = -1;
		flag = 0;
		play = -1;
		for (int i = 0; i < n; i++) {
			scanf("%d %d", &p, &c);
			if (p <= far) flag = 1;
			if (c < far) flag = 1;
			else far = c;
			if (p < play) flag = 1;
			else play = p;
			if (p < c) flag = 1;
		}
		printf("%s\n", flag == 0 ? "YES" : "NO");
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable: 4996)
#define MAX 100+1

int t, n, p[MAX], c[MAX], flag, play, complete;

int main() {
	scanf("%d", &t);
	for (int a = 0; a < t; a++) {
		scanf("%d", &n);
		for (int i = 0; i < n; i++) scanf("%d %d", &p[i], &c[i]);
		flag = 0;
		play = complete = -1;
		for (int i = 0; i < n; i++) {
			if (p[i] < play) flag = 1;
			if (c[i] < complete) flag = 1;
			if (p[i] <= complete && complete >0) flag = 1;
			if (p > c) flag = 1;
			play = p[i];
			complete = c[i];
		}
		printf("%s\n", flag == 0 ? "YES" : "NO");
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable: 4996)
#define MAX 100+1

int t, n, p[MAX], c[MAX], flag, play, complete;

int main() {
	scanf("%d", &t);
	for (int a = 0; a < t; a++) {
		scanf("%d", &n);
		for (int i = 0; i < n; i++) scanf("%d %d", &p[i], &c[i]);
		flag = 0;
		play = complete = -1;
		for (int i = 0; i < n; i++) {
			if (p[i] < play) flag = 1;
			if (c[i] < complete) flag = 1;
			if (p[i] <= complete) flag = 1;
			if (p > c) flag = 1;
			play = p[i];
			complete = c[i];
		}
		printf("%s\n", flag == 0 ? "YES" : "NO");
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable: 4996)

int t, n, p, c, far, play, flag;

int main() {
	scanf("%d", &t);
	for (int a = 0; a < t; a++) {
		scanf("%d", &n);
		far = -1;
		flag = play = 0;
		for (int i = 0; i < n; i++) {
			scanf("%d %d", &p, &c);
			if (p <= far) flag = 1;
			if (c < far) flag = 1;
			else far = c;
			if (p < play) flag = 1;
			else play = p;
		}
		printf("%s\n", flag == 0?"YES" : "NO");
	}
	return 0;
}


#include <bits/stdc++.h>

const int M=2e5+9;
const int MOD=1e9+7;
const long long N=1e2+7;

using namespace std;

//vector<long long>primes;

/*void sieve(){
    vis[0]=vis[1]=1;
    for(long long i=2;i*i<=M;++i){
        if(vis[i]==0){
            primes.push_back(i);
            for(long long j=i*i;j<=M;j+=i)
                vis[j]=1;
        }
    }
}

bool isprime(long long n){
    if(n==2)return true;
    else if(!(n&1))return false;
    for(long long i=3;i*i<=n;i+=2)
        if(n%i==0)
            return false;
    return true;
}

long long pwr(long long b,int p){
    if(p==0)return 1;
    long long sq=pwr(b,p>>1);
    sq=(((sq%MOD)*(sq%MOD))%MOD);
    if(p&1)
        sq=(((sq%MOD)*(b%MOD))%MOD);
    return sq;
}*/
int t,n;
vector<pair<int,int> >ps,pssor;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        while(n--){
            int pp,ss;
            scanf("%d %d",&pp,&ss);
            ps.push_back(make_pair(pp,ss));
        }
        int sz=ps.size();
        bool f=true;
        for(int i=0;i<sz-1;++i){
            if(ps[i].first>ps[i+1].first||ps[i].second>ps[i+1].second){
                f=false;
                break;
            }
            if(ps[i].second>ps[i].first){
                f=false;
                break;
            }

        }
        if(f&&ps[sz-1].second>ps[sz-1].first)
                f=false;
        if(!f)
            puts("NO");
        else
            puts("YES");
        ps.clear();
        pssor.clear();
    }

    return 0;
}


#include <bits/stdc++.h>

const int M=2e5+9;
const int MOD=1e9+7;
const long long N=1e2+7;

using namespace std;

//vector<long long>primes;

/*void sieve(){
    vis[0]=vis[1]=1;
    for(long long i=2;i*i<=M;++i){
        if(vis[i]==0){
            primes.push_back(i);
            for(long long j=i*i;j<=M;j+=i)
                vis[j]=1;
        }
    }
}

bool isprime(long long n){
    if(n==2)return true;
    else if(!(n&1))return false;
    for(long long i=3;i*i<=n;i+=2)
        if(n%i==0)
            return false;
    return true;
}

long long pwr(long long b,int p){
    if(p==0)return 1;
    long long sq=pwr(b,p>>1);
    sq=(((sq%MOD)*(sq%MOD))%MOD);
    if(p&1)
        sq=(((sq%MOD)*(b%MOD))%MOD);
    return sq;
}*/
int fin(string s,char t){
    static int i=-1;

    for(int j=i+1;s[j];++j,++i)
        if(s[j]==t)return j;
    return -1;
}

int t,n;
vector<pair<int,int> >ps,pssor;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        while(n--){
            int pp,ss;
            scanf("%d %d",&pp,&ss);
            ps.push_back(make_pair(pp,ss));
            pssor.push_back(make_pair(pp,ss));
        }
        sort(pssor.begin(),pssor.end());
        int sz=ps.size();
        bool f=true;
        for(int i=0;i<sz-1;++i){
            //cout<<ps[i].first<<" "<<ps[i].second<<" "<<ps[i+1].first<<" "<<ps[i+1].second<<endl;
            if(ps[i].first>ps[i+1].first||ps[i].second>ps[i+1].second){
                f=false;
                break;
            }
            if(ps[i].second>ps[i].first){
                f=false;
                break;
            }

        }
        if(f&&ps[sz-1].second>ps[sz-1].first)
                f=false;
        if(!f)
            puts("NO");
        else
            puts("YES");
        ps.clear();
        pssor.clear();
    }

    return 0;
}


#include <bits/stdc++.h>

const int M=2e5+9;
const int MOD=1e9+7;
const long long N=1e2+7;

using namespace std;

//vector<long long>primes;

/*void sieve(){
    vis[0]=vis[1]=1;
    for(long long i=2;i*i<=M;++i){
        if(vis[i]==0){
            primes.push_back(i);
            for(long long j=i*i;j<=M;j+=i)
                vis[j]=1;
        }
    }

bool isprime(long long n){
    if(n==2)return true;
    else if(!(n&1))return false;
    for(long long i=3;i*i<=n;i+=2)
        if(n%i==0)
            return false;
    return true;
}

long long pwr(long long b,int p){
    if(p==0)return 1;
    long long sq=pwr(b,p>>1);
    sq=(((sq%MOD)*(sq%MOD))%MOD);
    if(p&1)
        sq=(((sq%MOD)*(b%MOD))%MOD);
    return sq;
}*/
int t,n;
vector<pair<int,int> >ps,pssor;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        while(n--){
            int pp,ss;
            scanf("%d %d",&pp,&ss);
            ps.push_back(make_pair(pp,ss));
        }
        int sz=ps.size();
        bool f=true;
        for(int i=0;i<sz-1;++i){
            if(ps[i].first>ps[i+1].first||ps[i].second>ps[i+1].second){
                f=false;
                break;
            }
            if(ps[i].second>ps[i].first){
                f=false;
                break;
            }

        }
        if(f&&ps[sz-1].second>ps[sz-1].first)
                f=false;
        if(!f)
            puts("NO");
        else
            puts("YES");
        ps.clear();
        pssor.clear();
    }

    return 0;
}


#include <bits/stdc++.h>

const int M=2e5+9;
const int MOD=1e9+7;
const long long N=1e2+7;

using namespace std;

//vector<long long>primes;

/*void sieve(){
    vis[0]=vis[1]=1;
    for(long long i=2;i*i<=M;++i){
        if(vis[i]==0){
            primes.push_back(i);
            for(long long j=i*i;j<=M;j+=i)
                vis[j]=1;
        }
    }
}

bool isprime(long long n){
    if(n==2)return true;
    else if(!(n&1))return false;
    for(long long i=3;i*i<=n;i+=2)
        if(n%i==0)
            return false;
    return true;
}

long long pwr(long long b,int p){
    if(p==0)return 1;
    long long sq=pwr(b,p>>1);
    sq=(((sq%MOD)*(sq%MOD))%MOD);
    if(p&1)
        sq=(((sq%MOD)*(b%MOD))%MOD);
    return sq;
}*/
int t,n;
vector<pair<int,int> >ps,pssor;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        while(n--){
            int pp,ss;
            scanf("%d %d",&pp,&ss);
            ps.push_back(make_pair(pp,ss));
        }
        int sz=ps.size();
        bool f=true;
        for(int i=1;i<sz;++i){
            if(ps[i].first<ps[i-1].first||ps[i].second<ps[i-1].second){
                f=false;
                break;
            }
            if(ps[i].first-ps[i-1].first<ps[i].second-ps[i-1].second){
                f=false;
                break;
            }

        }
        if(ps[0].first<ps[i].second)
            f=false;
        if(!f)
            puts("NO");
        else
            puts("YES");
        ps.clear();
        pssor.clear();
    }

    return 0;
}


#include <bits/stdc++.h>

const int M=2e5+9;
const int MOD=1e9+7;
const long long N=1e2+7;

using namespace std;

//vector<long long>primes;

/*void sieve(){
    vis[0]=vis[1]=1;
    for(long long i=2;i*i<=M;++i){
        if(vis[i]==0){
            primes.push_back(i);
            for(long long j=i*i;j<=M;j+=i)
                vis[j]=1;
        }
    }
}

bool isprime(long long n){
    if(n==2)return true;
    else if(!(n&1))return false;
    for(long long i=3;i*i<=n;i+=2)
        if(n%i==0)
            return false;
    return true;
}

long long pwr(long long b,int p){
    if(p==0)return 1;
    long long sq=pwr(b,p>>1);
    sq=(((sq%MOD)*(sq%MOD))%MOD);
    if(p&1)
        sq=(((sq%MOD)*(b%MOD))%MOD);
    return sq;
}*/
int t,n;
vector<pair<int,int> >ps,pssor;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        while(n--){
            int pp,ss;
            scanf("%d %d",&pp,&ss);
            ps.push_back(make_pair(pp,ss));
        }
        int sz=ps.size();
        bool f=true;
        for(int i=0;i<sz-1;++i){
            if(ps[i].first>ps[i+1].first||ps[i].second>ps[i+1].second){
                f=false;
                break;
            }
            if(ps[i+1].first-ps[i].first<ps[i+1].second-ps[i].second){
                f=false;
                break;
            }

        }
        if(ps[sz-1].second>ps[sz-1].first)
                f=false;
        if(!f)
            puts("NO");
        else
            puts("YES");
        ps.clear();
        pssor.clear();
    }

    return 0;
}


#include <bits/stdc++.h>

const int M=2e5+9;
const int MOD=1e9+7;
const long long N=1e2+7;

using namespace std;

//vector<long long>primes;

/*void sieve(){
    vis[0]=vis[1]=1;
    for(long long i=2;i*i<=M;++i){
        if(vis[i]==0){
            primes.push_back(i);
            for(long long j=i*i;j<=M;j+=i)
                vis[j]=1;
        }
    }
}

bool isprime(long long n){
    if(n==2)return true;
    else if(!(n&1))return false;
    for(long long i=3;i*i<=n;i+=2)
        if(n%i==0)
            return false;
    return true;
}

long long pwr(long long b,int p){
    if(p==0)return 1;
    long long sq=pwr(b,p>>1);
    sq=(((sq%MOD)*(sq%MOD))%MOD);
    if(p&1)
        sq=(((sq%MOD)*(b%MOD))%MOD);
    return sq;
}*/
int fin(string s,char t){
    static int i=-1;

    for(int j=i+1;s[j];++j,++i)
        if(s[j]==t)return j;
    return -1;
}

int t,n;
vector<int>p,s,psor,ssor;

int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        while(n--){
            int pp,ss;
            scanf("%d %d",&pp,&ss);
            p.push_back(pp);
            psor.push_back(pp);
            s.push_back(ss);
            ssor.push_back(ss);
        }
        sort(psor.begin(),psor.end());
        sort(ssor.begin(),ssor.end());
        int sz=p.size();
        bool f=true;
        for(int i=0;i<sz;++i){
            if(p[i]!=psor[i]){
                f=false;
                break;
            }
            if(s[i]!=ssor[i]){
                f=false;
                break;
            }
            if(s[i]>p[i]){
                f=false;
                break;
            }

        }
        if(!f)
            puts("NO");
        else
            puts("YES");
        p.clear();
        s.clear();
        psor.clear();
        ssor.clear();
    }

    return 0;
}


#include <bits/stdc++.h>

const int M=2e5+9;
const int MOD=1e9+7;
const long long N=1e2+7;

using namespace std;

//vector<long long>primes;

/*void sieve(){
    vis[0]=vis[1]=1;
    for(long long i=2;i*i<=M;++i){
        if(vis[i]==0){
            primes.push_back(i);
            for(long long j=i*i;j<=M;j+=i)
                vis[j]=1;
        }
    }
}

bool isprime(long long n){
    if(n==2)return true;
    else if(!(n&1))return false;
    for(long long i=3;i*i<=n;i+=2)
        if(n%i==0)
            return false;
    return true;
}

long long pwr(long long b,int p){
    if(p==0)return 1;
    long long sq=pwr(b,p>>1);
    sq=(((sq%MOD)*(sq%MOD))%MOD);
    if(p&1)
        sq=(((sq%MOD)*(b%MOD))%MOD);
    return sq;
}*/
int t,n;
vector<pair<int,int> >ps,pssor;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        while(n--){
            int pp,ss;
            scanf("%d %d",&pp,&ss);
            ps.push_back(make_pair(pp,ss));
        }
        int sz=ps.size();
        bool f=true;
        for(int i=0;i<sz-1;++i){
            if(ps[i].first>ps[i+1].first||ps[i].second>ps[i+1].second){
                f=false;
                break;
            }
            if(ps[i+1].first-ps[i].first<ps[i+1].second-ps[i].second){
                f=false;
                break;
            }

        }
        if(!f)
            puts("NO");
        else
            puts("YES");
        ps.clear();
        pssor.clear();
    }

    return 0;
}


#include <bits/stdc++.h>

const int M=2e5+9;
const int MOD=1e9+7;
const long long N=1e2+7;

using namespace std;

//vector<long long>primes;

/*void sieve(){
    vis[0]=vis[1]=1;
    for(long long i=2;i*i<=M;++i){
        if(vis[i]==0){
            primes.push_back(i);
            for(long long j=i*i;j<=M;j+=i)
                vis[j]=1;
        }
    }
}

bool isprime(long long n){
    if(n==2)return true;
    else if(!(n&1))return false;
    for(long long i=3;i*i<=n;i+=2)
        if(n%i==0)
            return false;
    return true;
}

long long pwr(long long b,int p){
    if(p==0)return 1;
    long long sq=pwr(b,p>>1);
    sq=(((sq%MOD)*(sq%MOD))%MOD);
    if(p&1)
        sq=(((sq%MOD)*(b%MOD))%MOD);
    return sq;
}*/
int t,n;
vector<pair<int,int> >ps,pssor;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        while(n--){
            int pp,ss;
            scanf("%d %d",&pp,&ss);
            ps.push_back(make_pair(pp,ss));
        }
        int sz=ps.size();
        bool f=true;
        for(int i=1;i<sz;++i){
            if(ps[i].first<ps[i-1].first||ps[i].second<ps[i-1].second){
                f=false;
                break;
            }
            if(ps[i].first-ps[i-1].first<ps[i].second-ps[i-1].second){
                f=false;
                break;
            }

        }
        if(ps[0].first<ps[0].second)
            f=false;
        if(!f)
            puts("NO");
        else
            puts("YES");
        ps.clear();
        pssor.clear();
    }

    return 0;
}


#include <bits/stdc++.h>

const int M=2e5+9;
const int MOD=1e9+7;
const long long N=1e2+7;

using namespace std;

//vector<long long>primes;

/*void sieve(){
    vis[0]=vis[1]=1;
    for(long long i=2;i*i<=M;++i){
        if(vis[i]==0){
            primes.push_back(i);
            for(long long j=i*i;j<=M;j+=i)
                vis[j]=1;
        }
    }
}

bool isprime(long long n){
    if(n==2)return true;
    else if(!(n&1))return false;
    for(long long i=3;i*i<=n;i+=2)
        if(n%i==0)
            return false;
    return true;
}

long long pwr(long long b,int p){
    if(p==0)return 1;
    long long sq=pwr(b,p>>1);
    sq=(((sq%MOD)*(sq%MOD))%MOD);
    if(p&1)
        sq=(((sq%MOD)*(b%MOD))%MOD);
    return sq;
}*/
int fin(string s,char t){
    static int i=-1;

    for(int j=i+1;s[j];++j,++i)
        if(s[j]==t)return j;
    return -1;
}

int t,n;
vector<pair<int,int> >ps,pssor;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        while(n--){
            int pp,ss;
            scanf("%d %d",&pp,&ss);
            ps.push_back(make_pair(pp,ss));
            pssor.push_back(make_pair(pp,ss));
        }
        sort(pssor.begin(),pssor.end());
        int sz=ps.size();
        bool f=true;
        for(int i=0;i<sz;++i){
            if(ps[i].first!=pssor[i].first||ps[i].second!=pssor[i].second){
                f=false;
                break;
            }
            if(ps[i].second>ps[i].first){
                f=false;
                break;
            }
        }
        if(!f)
            puts("NO");
        else
            puts("YES");
        ps.clear();
        pssor.clear();
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef vector<vector<string>> vvs;
typedef vector<string> vs;

const char input_separator = ' ';
template <typename T> vector<T> get1DValues(char ch);
template <typename T> vector<vector<T>> get2DValues(char separator, int M);
template <typename T> void print1D(vector<T> input, char separator);
template <typename T> void print2D(vector<vector<T>> input, char separator);

typedef set<int> si;
typedef set<char> sc;
typedef set<string> ss;

typedef map<int, int> mii;
typedef map<int, char> mic;
typedef map<char, int> mci;

// Driver function to sort the 2D vector
// on basis of a particular column
bool sortcol(const vector<int> &v1, const vector<int> &v2) {
  return v1[0] < v2[0];
}

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, i, j, k, sum_1 = 0, sum_2 = 0, is_no = 0;
    cin >> n;
    cin.ignore(1, '\n');
    vvi m = get2DValues<int>(input_separator, n);
    Fo(i, 1, n) {
      sum_1 += m[i][0];
      sum_2 += m[i][1];
      if (sum_2 > sum_1) {
        cout << "NO"
             << "\n";
        is_no = 1;
      } else if (m[i][0] == m[i - 1][0] && m[i][1] != m[i - 1][1]) {
        cout << "NO"
             << "\n";
        is_no = 1;
        break;
      } else if (m[i][0] > m[i - 1][0]) {
        continue;
      } else if (m[i][0] < m[i - 1][0]) {
        cout << "NO"
             << "\n";
        is_no = 1;
        break;
      } else if (m[i][0] == m[i - 1][0] && m[i][1] == m[i - 1][1]) {
        continue;
      }
    }
    if (!is_no) {
      cout << "YES"
           << "\n";
    }
  }

  return 0;
}

// cin.ignore();
// vvi m = get2DValues<int>(input_separator, 3);
// vc arr = get1DValues<char>(input_separator);
// vi arr = get1DValues<int>(input_separator);
// sort(m.begin(), m.end(), sortcol);
// print1D<char>(arr, input_separator);
// print2D<int>(m, input_separator);
// vector<string> arr = get1DValues<string>(input_separator);
// print1D<string>(arr, input_separator);
// vvs m = get2DValues<string>(input_separator, 3);
// print2D(m, input_separator);

template <typename T> void print1D(const vector<T> input, char separator) {
  for (const auto elem : input) {
    cout << elem << separator;
  }
  cout << "\n";
}

template <typename T>
void print2D(const vector<vector<T>> input, char separator) {
  for (const auto row : input) {
    print1D(row, separator);
  }
}

template <typename T>
vector<vector<T>> get2DValues(char separator, int num_rows) {
  vector<vector<T>> result;
  for (int i = 0; i < num_rows; ++i) {
    result.push_back(get1DValues<T>(separator));
  }
  return result;
}

template <typename T> vector<T> get1DValues(char separator) {
  stringstream ss;
  string str;
  getline(cin, str);
  replace(str.begin(), str.end(), separator, ' ');
  ss << str;

  T value{0};
  vector<T> values;
  while (ss >> value) {
    values.push_back(value);
  }

  return values;
}


#include <bits/stdc++.h>

using namespace std;

#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef vector<vector<string>> vvs;
typedef vector<string> vs;

const char input_separator = ' ';
template <typename T> vector<T> get1DValues(char ch);
template <typename T> vector<vector<T>> get2DValues(char separator, int M);
template <typename T> void print1D(vector<T> input, char separator);
template <typename T> void print2D(vector<vector<T>> input, char separator);

typedef set<int> si;
typedef set<char> sc;
typedef set<string> ss;

typedef map<int, int> mii;
typedef map<int, char> mic;
typedef map<char, int> mci;

// Driver function to sort the 2D vector
// on basis of a particular column
bool sortcol(const vector<int> &v1, const vector<int> &v2) {
  return v1[0] < v2[0];
}

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, i, j, k, sum_1 = 0, sum_2 = 0, is_no = 0;
    cin >> n;
    cin.ignore(1, '\n');
    vvi m = get2DValues<int>(input_separator, n);
    Fo(i, 1, n) {
      sum_1 += m[i][0];
      sum_2 += m[i][1];
      if (sum_2 > sum_1) {
        cout << "NO"
             << "\n";
        is_no = 1;
      } else if (m[i][0] == m[i - 1][0] && m[i][1] != m[i - 1][1]) {
        cout << "NO"
             << "\n";
        is_no = 1;
        break;
      } else if (m[i][0] > m[i - 1][0]) {
        continue;
      } else if (m[i][0] < m[i - 1][0]) {
        cout << "NO"
             << "\n";
        is_no = 1;
        break;
      } else if (m[i][0] < m[i][1]) {
        cout << "NO"
             << "\n";
        is_no = 1;
        break;
      } else if (m[i][0] == m[i - 1][0] && m[i][1] == m[i - 1][1]) {
        continue;
      }
    }
    if (!is_no) {
      cout << "YES"
           << "\n";
    }
  }

  return 0;
}

// cin.ignore();
// vvi m = get2DValues<int>(input_separator, 3);
// vc arr = get1DValues<char>(input_separator);
// vi arr = get1DValues<int>(input_separator);
// sort(m.begin(), m.end(), sortcol);
// print1D<char>(arr, input_separator);
// print2D<int>(m, input_separator);
// vector<string> arr = get1DValues<string>(input_separator);
// print1D<string>(arr, input_separator);
// vvs m = get2DValues<string>(input_separator, 3);
// print2D(m, input_separator);

template <typename T> void print1D(const vector<T> input, char separator) {
  for (const auto elem : input) {
    cout << elem << separator;
  }
  cout << "\n";
}

template <typename T>
void print2D(const vector<vector<T>> input, char separator) {
  for (const auto row : input) {
    print1D(row, separator);
  }
}

template <typename T>
vector<vector<T>> get2DValues(char separator, int num_rows) {
  vector<vector<T>> result;
  for (int i = 0; i < num_rows; ++i) {
    result.push_back(get1DValues<T>(separator));
  }
  return result;
}

template <typename T> vector<T> get1DValues(char separator) {
  stringstream ss;
  string str;
  getline(cin, str);
  replace(str.begin(), str.end(), separator, ' ');
  ss << str;

  T value{0};
  vector<T> values;
  while (ss >> value) {
    values.push_back(value);
  }

  return values;
}


#include <bits/stdc++.h>

using namespace std;

#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef vector<vector<string>> vvs;
typedef vector<string> vs;

const char input_separator = ' ';
template <typename T> vector<T> get1DValues(char ch);
template <typename T> vector<vector<T>> get2DValues(char separator, int M);
template <typename T> void print1D(vector<T> input, char separator);
template <typename T> void print2D(vector<vector<T>> input, char separator);

typedef set<int> si;
typedef set<char> sc;
typedef set<string> ss;

typedef map<int, int> mii;
typedef map<int, char> mic;
typedef map<char, int> mci;

// Driver function to sort the 2D vector
// on basis of a particular column
bool sortcol(const vector<int> &v1, const vector<int> &v2) {
  return v1[0] < v2[0];
}

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, i, j, k, sum_1 = 0, sum_2 = 0, is_no = 0;
    cin >> n;
    cin.ignore(1, '\n');
    vvi m = get2DValues<int>(input_separator, n);
    Fo(i, 1, n) {
      if (m[i][0] < m[i][1]) {
        is_no = 1;
        cout << "NO"
             << "\n";
        break;
      }
      if (m[i][0] == m[i - 1][0] && m[i][1] > m[i - 1][1]) {
        is_no = 1;
        cout << "NO"
             << "\n";
        break;
      }
      if (m[i][1] - m[i - 1][1] > m[i][0] - m[i - 1][0]) {
        is_no = 1;
        cout << "NO"
             << "\n";
        break;
      }
      if (m[i][0] >= m[i - 1][0] && m[i][1] >= m[i - 1][1]) {
        continue;
      } else {
        is_no = 1;
        cout << "NO"
             << "\n";
        break;
      }
    }
    if (n == 1 && m[0][0] < m[0][1]) {
      cout << "NO"
           << "\n";
    } else if (!is_no) {
      cout << "YES"
           << "\n";
    }
  }

  return 0;
}

// cin.ignore();
// vvi m = get2DValues<int>(input_separator, 3);
// vc arr = get1DValues<char>(input_separator);
// vi arr = get1DValues<int>(input_separator);
// sort(m.begin(), m.end(), sortcol);
// print1D<char>(arr, input_separator);
// print2D<int>(m, input_separator);
// vector<string> arr = get1DValues<string>(input_separator);
// print1D<string>(arr, input_separator);
// vvs m = get2DValues<string>(input_separator, 3);
// print2D(m, input_separator);

template <typename T> void print1D(const vector<T> input, char separator) {
  for (const auto elem : input) {
    cout << elem << separator;
  }
  cout << "\n";
}

template <typename T>
void print2D(const vector<vector<T>> input, char separator) {
  for (const auto row : input) {
    print1D(row, separator);
  }
}

template <typename T>
vector<vector<T>> get2DValues(char separator, int num_rows) {
  vector<vector<T>> result;
  for (int i = 0; i < num_rows; ++i) {
    result.push_back(get1DValues<T>(separator));
  }
  return result;
}

template <typename T> vector<T> get1DValues(char separator) {
  stringstream ss;
  string str;
  getline(cin, str);
  replace(str.begin(), str.end(), separator, ' ');
  ss << str;

  T value{0};
  vector<T> values;
  while (ss >> value) {
    values.push_back(value);
  }

  return values;
}


#include <bits/stdc++.h>

using namespace std;

#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef vector<vector<string>> vvs;
typedef vector<string> vs;

const char input_separator = ' ';
template <typename T> vector<T> get1DValues(char ch);
template <typename T> vector<vector<T>> get2DValues(char separator, int M);
template <typename T> void print1D(vector<T> input, char separator);
template <typename T> void print2D(vector<vector<T>> input, char separator);

typedef set<int> si;
typedef set<char> sc;
typedef set<string> ss;

typedef map<int, int> mii;
typedef map<int, char> mic;
typedef map<char, int> mci;

// Driver function to sort the 2D vector
// on basis of a particular column
bool sortcol(const vector<int> &v1, const vector<int> &v2) {
  return v1[0] < v2[0];
}

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, i, j, k, sum_1 = 0, sum_2 = 0, is_no = 0;
    cin >> n;
    cin.ignore(1, '\n');
    vvi m = get2DValues<int>(input_separator, n);
    Fo(i, 1, n) {
      if (m[i][0] == m[i - 1][0] && m[i][1] > m[i - 1][1]) {
        is_no = 1;
        cout << "NO"
             << "\n";
        break;
      }
      if (m[i][0] >= m[i - 1][0] && m[i][1] >= m[i - 1][1]) {
        continue;
      } else {
        is_no = 1;
        cout << "NO"
             << "\n";
        break;
      }
    }
    if (!is_no) {
      cout << "YES"
           << "\n";
    }
  }

  return 0;
}

// cin.ignore();
// vvi m = get2DValues<int>(input_separator, 3);
// vc arr = get1DValues<char>(input_separator);
// vi arr = get1DValues<int>(input_separator);
// sort(m.begin(), m.end(), sortcol);
// print1D<char>(arr, input_separator);
// print2D<int>(m, input_separator);
// vector<string> arr = get1DValues<string>(input_separator);
// print1D<string>(arr, input_separator);
// vvs m = get2DValues<string>(input_separator, 3);
// print2D(m, input_separator);

template <typename T> void print1D(const vector<T> input, char separator) {
  for (const auto elem : input) {
    cout << elem << separator;
  }
  cout << "\n";
}

template <typename T>
void print2D(const vector<vector<T>> input, char separator) {
  for (const auto row : input) {
    print1D(row, separator);
  }
}

template <typename T>
vector<vector<T>> get2DValues(char separator, int num_rows) {
  vector<vector<T>> result;
  for (int i = 0; i < num_rows; ++i) {
    result.push_back(get1DValues<T>(separator));
  }
  return result;
}

template <typename T> vector<T> get1DValues(char separator) {
  stringstream ss;
  string str;
  getline(cin, str);
  replace(str.begin(), str.end(), separator, ' ');
  ss << str;

  T value{0};
  vector<T> values;
  while (ss >> value) {
    values.push_back(value);
  }

  return values;
}


#include <bits/stdc++.h>

using namespace std;

#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef vector<vector<string>> vvs;
typedef vector<string> vs;

const char input_separator = ' ';
template <typename T> vector<T> get1DValues(char ch);
template <typename T> vector<vector<T>> get2DValues(char separator, int M);
template <typename T> void print1D(vector<T> input, char separator);
template <typename T> void print2D(vector<vector<T>> input, char separator);

typedef set<int> si;
typedef set<char> sc;
typedef set<string> ss;

typedef map<int, int> mii;
typedef map<int, char> mic;
typedef map<char, int> mci;

// Driver function to sort the 2D vector
// on basis of a particular column
bool sortcol(const vector<int> &v1, const vector<int> &v2) {
  return v1[0] < v2[0];
}

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, i, j, k, sum_1 = 0, sum_2 = 0, is_no = 0;
    cin >> n;
    cin.ignore(1, '\n');
    vvi m = get2DValues<int>(input_separator, n);
    Fo(i, 1, n) {
      if (m[i][0] == m[i - 1][0] && m[i][1] > m[i - 1][1]) {
        is_no = 1;
        cout << "NO"
             << "\n";
        break;
      }
      if (m[i][0] >= m[i - 1][0] && m[i][1] >= m[i - 1][1]) {
        continue;
      } else {
        is_no = 1;
        cout << "NO"
             << "\n";
        break;
      }
    }
    if (n == 1 && m[0][0] < m[0][1]) {
      cout << "NO"
           << "\n";
    } else if (!is_no) {
      cout << "YES"
           << "\n";
    }
  }

  return 0;
}

// cin.ignore();
// vvi m = get2DValues<int>(input_separator, 3);
// vc arr = get1DValues<char>(input_separator);
// vi arr = get1DValues<int>(input_separator);
// sort(m.begin(), m.end(), sortcol);
// print1D<char>(arr, input_separator);
// print2D<int>(m, input_separator);
// vector<string> arr = get1DValues<string>(input_separator);
// print1D<string>(arr, input_separator);
// vvs m = get2DValues<string>(input_separator, 3);
// print2D(m, input_separator);

template <typename T> void print1D(const vector<T> input, char separator) {
  for (const auto elem : input) {
    cout << elem << separator;
  }
  cout << "\n";
}

template <typename T>
void print2D(const vector<vector<T>> input, char separator) {
  for (const auto row : input) {
    print1D(row, separator);
  }
}

template <typename T>
vector<vector<T>> get2DValues(char separator, int num_rows) {
  vector<vector<T>> result;
  for (int i = 0; i < num_rows; ++i) {
    result.push_back(get1DValues<T>(separator));
  }
  return result;
}

template <typename T> vector<T> get1DValues(char separator) {
  stringstream ss;
  string str;
  getline(cin, str);
  replace(str.begin(), str.end(), separator, ' ');
  ss << str;

  T value{0};
  vector<T> values;
  while (ss >> value) {
    values.push_back(value);
  }

  return values;
}


#include <bits/stdc++.h>

using namespace std;

#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef vector<vector<string>> vvs;
typedef vector<string> vs;

const char input_separator = ' ';
template <typename T> vector<T> get1DValues(char ch);
template <typename T> vector<vector<T>> get2DValues(char separator, int M);
template <typename T> void print1D(vector<T> input, char separator);
template <typename T> void print2D(vector<vector<T>> input, char separator);

typedef set<int> si;
typedef set<char> sc;
typedef set<string> ss;

typedef map<int, int> mii;
typedef map<int, char> mic;
typedef map<char, int> mci;

// Driver function to sort the 2D vector
// on basis of a particular column
bool sortcol(const vector<int> &v1, const vector<int> &v2) {
  return v1[0] < v2[0];
}

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, i, j, k, sum_1 = 0, sum_2 = 0, is_no = 0;
    cin >> n;
    cin.ignore(1, '\n');
    vvi m = get2DValues<int>(input_separator, n);
    Fo(i, 1, n) {
      if (m[i][0] == m[i - 1][0] && m[i][1] > m[i - 1][1]) {
        is_no = 1;
        cout << "NO"
             << "\n";
        break;
      }
      if (m[i][1] - m[i - 1][1] > m[i][0] - m[i - 1][0]) {
        is_no = 1;
        cout << "NO"
             << "\n";
        break;
      }
      if (m[i][0] >= m[i - 1][0] && m[i][1] >= m[i - 1][1]) {
        continue;
      } else {
        is_no = 1;
        cout << "NO"
             << "\n";
        break;
      }
    }
    if (n == 1 && m[0][0] < m[0][1]) {
      cout << "NO"
           << "\n";
    } else if (!is_no) {
      cout << "YES"
           << "\n";
    }
  }

  return 0;
}

// cin.ignore();
// vvi m = get2DValues<int>(input_separator, 3);
// vc arr = get1DValues<char>(input_separator);
// vi arr = get1DValues<int>(input_separator);
// sort(m.begin(), m.end(), sortcol);
// print1D<char>(arr, input_separator);
// print2D<int>(m, input_separator);
// vector<string> arr = get1DValues<string>(input_separator);
// print1D<string>(arr, input_separator);
// vvs m = get2DValues<string>(input_separator, 3);
// print2D(m, input_separator);

template <typename T> void print1D(const vector<T> input, char separator) {
  for (const auto elem : input) {
    cout << elem << separator;
  }
  cout << "\n";
}

template <typename T>
void print2D(const vector<vector<T>> input, char separator) {
  for (const auto row : input) {
    print1D(row, separator);
  }
}

template <typename T>
vector<vector<T>> get2DValues(char separator, int num_rows) {
  vector<vector<T>> result;
  for (int i = 0; i < num_rows; ++i) {
    result.push_back(get1DValues<T>(separator));
  }
  return result;
}

template <typename T> vector<T> get1DValues(char separator) {
  stringstream ss;
  string str;
  getline(cin, str);
  replace(str.begin(), str.end(), separator, ' ');
  ss << str;

  T value{0};
  vector<T> values;
  while (ss >> value) {
    values.push_back(value);
  }

  return values;
}


#include <bits/stdc++.h>

using namespace std;

#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef vector<vector<string>> vvs;
typedef vector<string> vs;

const char input_separator = ' ';
template <typename T> vector<T> get1DValues(char ch);
template <typename T> vector<vector<T>> get2DValues(char separator, int M);
template <typename T> void print1D(vector<T> input, char separator);
template <typename T> void print2D(vector<vector<T>> input, char separator);

typedef set<int> si;
typedef set<char> sc;
typedef set<string> ss;

typedef map<int, int> mii;
typedef map<int, char> mic;
typedef map<char, int> mci;

// Driver function to sort the 2D vector
// on basis of a particular column
bool sortcol(const vector<int> &v1, const vector<int> &v2) {
  return v1[0] < v2[0];
}

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, i, j, k, sum_1 = 0, sum_2 = 0, is_no = 0;
    cin >> n;
    cin.ignore(1, '\n');
    vvi m = get2DValues<int>(input_separator, n);
    Fo(i, 0, n) {
      if (m[i][0] < m[i][1]) {
        is_no = 1;
        cout << "NO"
             << "\n";
        break;
      }
      if (i > 0) {
        if (m[i][0] == m[i - 1][0] && m[i][1] > m[i - 1][1]) {
          is_no = 1;
          cout << "NO"
               << "\n";
          break;
        }
        if (m[i][1] - m[i - 1][1] > m[i][0] - m[i - 1][0]) {
          is_no = 1;
          cout << "NO"
               << "\n";
          break;
        }
        if (m[i][0] >= m[i - 1][0] && m[i][1] >= m[i - 1][1]) {
          continue;
        } else {
          is_no = 1;
          cout << "NO"
               << "\n";
          break;
        }
      }
    }
    if (n == 1 && m[0][0] < m[0][1]) {
      cout << "NO"
           << "\n";
    } else if (!is_no) {
      cout << "YES"
           << "\n";
    }
  }

  return 0;
}

// cin.ignore();
// vvi m = get2DValues<int>(input_separator, 3);
// vc arr = get1DValues<char>(input_separator);
// vi arr = get1DValues<int>(input_separator);
// sort(m.begin(), m.end(), sortcol);
// print1D<char>(arr, input_separator);
// print2D<int>(m, input_separator);
// vector<string> arr = get1DValues<string>(input_separator);
// print1D<string>(arr, input_separator);
// vvs m = get2DValues<string>(input_separator, 3);
// print2D(m, input_separator);

template <typename T> void print1D(const vector<T> input, char separator) {
  for (const auto elem : input) {
    cout << elem << separator;
  }
  cout << "\n";
}

template <typename T>
void print2D(const vector<vector<T>> input, char separator) {
  for (const auto row : input) {
    print1D(row, separator);
  }
}

template <typename T>
vector<vector<T>> get2DValues(char separator, int num_rows) {
  vector<vector<T>> result;
  for (int i = 0; i < num_rows; ++i) {
    result.push_back(get1DValues<T>(separator));
  }
  return result;
}

template <typename T> vector<T> get1DValues(char separator) {
  stringstream ss;
  string str;
  getline(cin, str);
  replace(str.begin(), str.end(), separator, ' ');
  ss << str;

  T value{0};
  vector<T> values;
  while (ss >> value) {
    values.push_back(value);
  }

  return values;
}


#include <bits/stdc++.h>

using namespace std;

#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef vector<vector<string>> vvs;
typedef vector<string> vs;

const char input_separator = ' ';
template <typename T> vector<T> get1DValues(char ch);
template <typename T> vector<vector<T>> get2DValues(char separator, int M);
template <typename T> void print1D(vector<T> input, char separator);
template <typename T> void print2D(vector<vector<T>> input, char separator);

typedef set<int> si;
typedef set<char> sc;
typedef set<string> ss;

typedef map<int, int> mii;
typedef map<int, char> mic;
typedef map<char, int> mci;

// Driver function to sort the 2D vector
// on basis of a particular column
bool sortcol(const vector<int> &v1, const vector<int> &v2) {
  return v1[0] < v2[0];
}

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, i, j, k, sum_1 = 0, sum_2 = 0, is_no = 0;
    cin >> n;
    cin.ignore(1, '\n');
    vvi m = get2DValues<int>(input_separator, n);
    Fo(i, 1, n) {
      sum_1 += m[i][0];
      sum_2 += m[i][1];
      if (sum_2 > sum_1) {
        cout << "NO"
             << "\n";
        is_no = 1;
      } else if (m[i][0] == m[i - 1][0] && m[i][1] != m[i - 1][1]) {
        cout << "NO"
             << "\n";
        is_no = 1;
        break;
      } else if (m[i][0] > m[i - 1][0] && m[i][1] >= m[i - 1][1]) {
        continue;
      } else if (m[i][0] > m[i - 1][0] && m[i][1] < m[i - 1][1]) {
        cout << "NO"
             << "\n";
        is_no = 1;
        break;
      } else if (m[i][0] < m[i - 1][0]) {
        cout << "NO"
             << "\n";
        is_no = 1;
        break;
      } else if (m[i][0] < m[i][1]) {
        cout << "NO"
             << "\n";
        is_no = 1;
        break;
      } else if (m[i][0] == m[i - 1][0] && m[i][1] == m[i - 1][1]) {
        continue;
      }
    }
    if (!is_no) {
      cout << "YES"
           << "\n";
    }
  }

  return 0;
}

// cin.ignore();
// vvi m = get2DValues<int>(input_separator, 3);
// vc arr = get1DValues<char>(input_separator);
// vi arr = get1DValues<int>(input_separator);
// sort(m.begin(), m.end(), sortcol);
// print1D<char>(arr, input_separator);
// print2D<int>(m, input_separator);
// vector<string> arr = get1DValues<string>(input_separator);
// print1D<string>(arr, input_separator);
// vvs m = get2DValues<string>(input_separator, 3);
// print2D(m, input_separator);

template <typename T> void print1D(const vector<T> input, char separator) {
  for (const auto elem : input) {
    cout << elem << separator;
  }
  cout << "\n";
}

template <typename T>
void print2D(const vector<vector<T>> input, char separator) {
  for (const auto row : input) {
    print1D(row, separator);
  }
}

template <typename T>
vector<vector<T>> get2DValues(char separator, int num_rows) {
  vector<vector<T>> result;
  for (int i = 0; i < num_rows; ++i) {
    result.push_back(get1DValues<T>(separator));
  }
  return result;
}

template <typename T> vector<T> get1DValues(char separator) {
  stringstream ss;
  string str;
  getline(cin, str);
  replace(str.begin(), str.end(), separator, ' ');
  ss << str;

  T value{0};
  vector<T> values;
  while (ss >> value) {
    values.push_back(value);
  }

  return values;
}


#include <bits/stdc++.h>

using namespace std;

#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef vector<vector<string>> vvs;
typedef vector<string> vs;

const char input_separator = ' ';
template <typename T> vector<T> get1DValues(char ch);
template <typename T> vector<vector<T>> get2DValues(char separator, int M);
template <typename T> void print1D(vector<T> input, char separator);
template <typename T> void print2D(vector<vector<T>> input, char separator);

typedef set<int> si;
typedef set<char> sc;
typedef set<string> ss;

typedef map<int, int> mii;
typedef map<int, char> mic;
typedef map<char, int> mci;

// Driver function to sort the 2D vector
// on basis of a particular column
bool sortcol(const vector<int> &v1, const vector<int> &v2) {
  return v1[0] < v2[0];
}

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, i, j, k, sum_1 = 0, sum_2 = 0, is_no = 0;
    cin >> n;
    cin.ignore(1, '\n');
    vvi m = get2DValues<int>(input_separator, n);
    Fo(i, 0, n) {
      if (m[i][0] < m[i][1]) {
        is_no = 1;
        cout << "NO"
             << "\n";
        break;
      }
      if (i > 0) {
        if (m[i][0] == m[i - 1][0] && m[i][1] > m[i - 1][1]) {
          is_no = 1;
          cout << "NO"
               << "\n";
          break;
        }
        if (m[i][1] - m[i - 1][1] > m[i][0] - m[i - 1][0]) {
          is_no = 1;
          cout << "NO"
               << "\n";
          break;
        }
        if (m[i][0] >= m[i - 1][0] && m[i][1] >= m[i - 1][1]) {
          continue;
        } else {
          is_no = 1;
          cout << "NO"
               << "\n";
          break;
        }
      }
    }
    if (!is_no && n == 1 && m[0][0] < m[0][1]) {
      cout << "NO"
           << "\n";
    } else if (!is_no) {
      cout << "YES"
           << "\n";
    }
  }

  return 0;
}

// cin.ignore();
// vvi m = get2DValues<int>(input_separator, 3);
// vc arr = get1DValues<char>(input_separator);
// vi arr = get1DValues<int>(input_separator);
// sort(m.begin(), m.end(), sortcol);
// print1D<char>(arr, input_separator);
// print2D<int>(m, input_separator);
// vector<string> arr = get1DValues<string>(input_separator);
// print1D<string>(arr, input_separator);
// vvs m = get2DValues<string>(input_separator, 3);
// print2D(m, input_separator);

template <typename T> void print1D(const vector<T> input, char separator) {
  for (const auto elem : input) {
    cout << elem << separator;
  }
  cout << "\n";
}

template <typename T>
void print2D(const vector<vector<T>> input, char separator) {
  for (const auto row : input) {
    print1D(row, separator);
  }
}

template <typename T>
vector<vector<T>> get2DValues(char separator, int num_rows) {
  vector<vector<T>> result;
  for (int i = 0; i < num_rows; ++i) {
    result.push_back(get1DValues<T>(separator));
  }
  return result;
}

template <typename T> vector<T> get1DValues(char separator) {
  stringstream ss;
  string str;
  getline(cin, str);
  replace(str.begin(), str.end(), separator, ' ');
  ss << str;

  T value{0};
  vector<T> values;
  while (ss >> value) {
    values.push_back(value);
  }

  return values;
}


#include "bits/stdc++.h"

using namespace std;

int main(){
    #ifndef ONLINE_JUDGE
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    int tc,t(1);
    for(cin>>tc; tc; ++t,--tc){
        int n;
        cin>>n;
        int a,b,mxa=INT_MIN,mxb=INT_MIN;
        bool res=true;

        for(int i=1; i<=n; ++i)  {

            cin>>a>>b;

            if(a<mxa or b<mxb){
                res = false;
            }

            mxb=max(mxb,b);
            mxa=max(mxa,a);

            if(mxa<mxb){
                res = false;
            }

        }

        cout<<(res?"YES":"NO")<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
#define vii vector<pair<ll,ll>>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define sep(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

void solve()
{
    ll n;
    cin>>n;
    vector<ll>p(n,0),c(n,0);
    rep(i,0,n)
    cin>>p[i]>>c[i];
    if(p[0]<c[0])
    {cout<<"NO\n";return;}
    rep(i,1,n)
    if(p[i]<p[i-1]||c[i]<c[i-1]||p[i]<c[i])
    {cout<<"NO" << endl;return;}
    cout<<"YES" << "\n";return;
}

 main()
{
    const int NN = 20098;
    set<int> ss;
    for(int i = 0; i <= NN; ++i)
        ss.insert((i+3)/4);
    int t;
    cin>>t;
    while(t--)
        solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

 main() {
    const int NN = 20098;
    set<int> ss;
    for(int i = 0; i <= NN; ++i)
        ss.insert((i+3)/4);
	int t,n;
	cin>>t;
	while(t--){
		cin>>n;
		int a[n][2],play,clear,flag=0;
		for(int i=0;i<n;++i)
		for(int j=0;j<2;j++)
		cin>>a[i][j];
		play=a[0][0],clear=a[0][1];
		for(int i=1;i<n;i++){
		for(int j=0;j<=1;++j){
			if(a[i][0]<play || a[i][0]<a[i][1] || a[i][1]<clear){
				flag=1;
				cout<<"NO"<<"\n";
				break;
			}
			play=a[i][0];
			clear=a[i][1];
		}}
		if(flag==1)
		cout<<"YES"<<'\n';
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

 main() {
      ios :: sync_with_stdio(0);
    cin.tie(0);
    const int NN = 20098;
    set<int> ss;
    for(int i = 0; i <= NN; ++i)
        ss.insert((i+3)/4);
	int t;
	cin>>t;
	while(t--) {
		int n;
		cin>>n;
		int p[n], c[n];
		for(int i=0;i<n;i++) {
			cin>>p[i]>>c[i];
		}
		bool isValid = true;
		for(int i=1;i<n;i++) {
			if(p[i] < p[i-1] || c[i] < c[i-1]) {
				isValid = false;
				break;
			}
		}
		if(isValid)
			cout << "YES" << endl;
		else
			cout << "NO\n";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string sss;
string ssss;
const int N = 1e5 + 5;

void solve()
{
    int n;
    bool ok = true;
    cin >> n;
    int c0, p0;
    cin >> c0, p0;
    for(int i = 2; i <= n; i++)
    {
        int c, p;
        cin >> c >> p;
        if(c < c0 || p < p0) ok = 0;else
        if(p > p0 && c == c0) ok = false;
    }
    if(ok != 0) cout << "YES\n";else cout << "NO\n";
    return ;
}
int main()
{
    const int NN = 20098;
    set<int> ss;
    for(int i = 0; i <= NN; ++i)
        ss.insert((i+3)/4);
    int TT;
    cin >> TT;
    while(TT--)
        solve();
    return 0;
}


#include<bits/stdc++.h>
#define tr(type,c,it) for(type::iterator it=c.begin();it!=c.end();++it)
#define all(c) c.begin(),c.end()
#define mod 1000000007
#define itor(c) c::iterator
#define ll long long
#define vi vector<int>
#define vs vector<string>
#define si set<int>
#define msi multiset<int>
#define ii pair<int,int>
#define sii set<ii>
#define vii vector<ii>
#define vvi vector<vi>
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;

using namespace std;
int main()
{
    ll i,j,k,m,n,p,c,l,mp,mc,f;
    int t;
    cin>>t;
    while(t--)
    {
        cin>>n;
        mp=0;
        mc=0;
        l=0;
        f=0;
        for(j=0; j<n; ++j)
        {
            cin>>p>>c;

            if((p>=mp)&&(c>=mc)&&(c<=p)&&(c<=p-l))
            {
                l=p-c;
                mp=p;
                mc=c;

            }
            else
            {
                f=1;

            }

        }
        if(!f)
            cout<<"YES\n";
        else
            cout<<"NO"<<endl;

    }

}


#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;

 ll p[200099];
 ll c[200099];

 main()
{
      ios :: sync_with_stdio(0);
    cin.tie(0);
    const int NN = 20098;
    set<int> ss;
    for(int i = 0; i <= NN; ++i)
        ss.insert((i+3)/4);
    ll t;
    cin>>t;
    while(t--)
    {

        ll n;
        cin>>n;

        for(int i=0;i<n;i++)
        {
            cin>>p[i]>>c[i];
        }
        int flag=0;

        for(int i=1;i<n;i++)
        {
            if(p[i]==p[i-1] && c[i]!=c[i-1])
            {
                flag=1;
                break;
            }

            if(p[i]<p[i-1] || c[i]<c[i-1])
            {
                flag=1;
            }
        }

        if(flag==1)
        {
            cout<<"NO"<<endl;
        }
        else
        {
            cout<<"YES"<<endl;
        }
    }

    return 0;
}


#include<bits/stdc++.h>
#define tr(type,c,it) for(type::iterator it=c.begin();it!=c.end();++it)
#define vi vector<int>
#define vs vector<string>
typedef long long ll;

using namespace std;
 main()
{
    ll i,j,k,m,n,p,c,l,mp,mc,f;
    int t;
    cin>>t;
    while(t--)
    {
        cin>>n;
        mp=0;
        mc=0;
        l=0;
        f=0;
        for(j=0; j<n; ++j)
        {
            cin>>p>>c;

            if((p>=mp)&&(c>=mc)&&(c<=p)&&(c<=p-l))
            {
                l=p-c;
                mp=p;
                mc=c;

            }
            else
            {
                f=1;

            }

        }
        if(!f)
            cout<<"YES\n";
        else
            cout<<"NO"<<endl;

    }

}


#include<bits/stdc++.h>
using namespace std;
#define int long long int

 main()
{
    const int NN = 20098;
    set<int> ss;
    for(int i = 0; i <= NN; ++i)
        ss.insert((i+3)/4);
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		int p[n],c[n];
		for(int j=0;j<n;j++)
		{
			cin>>p[j]>>c[j];
		}
		int arr=0;
		for(int j=1;j<n;j++)
		{
			if(p[j]<p[j-1]||c[j]<c[j-1])
			{
			arr++;
			break;
			}
			if(p[j]-p[j-1]<c[j]-c[j-1])
			{
				arr++;
				break;
			}
		}
		if(arr==0)
		cout<<"YES"<<"\n";
		else
		cout<<"NO"<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

 main() {
      ios :: sync_with_stdio(0);
    cin.tie(0);
    const int NN = 20098;
    set<int> ss;
    for(int i = 0; i <= NN; ++i)
        ss.insert((i+3)/4);
	int t,n,a,b,c,d,h;
	cin>>t;
	while(t--){
		cin>>n;
		c=0;
		d=0;
		while(n--){
			cin>>a>>b;
			if(a>=c && b>=d && (b-d)<=(c-a)){
				h=1;
			}else{
				h=0;
			}
			c=a;
			d=b;
		}
		if(h){
			cout<<"YES"<<"\n";
		}else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
#define int long long int
typedef long long ll;
using namespace std;

 main() {
	 ios :: sync_with_stdio(0);
    cin.tie(0);
    const int NN = 20098;
    set<int> ss;
    for(int i = 0; i <= NN; ++i)
        ss.insert((i+3)/4);
	ll q;
	cin>>q;
	while(q--)
	{
		ll n;
		cin>>n;
		int arr[n],brr[n];
		int a=INT_MIN,b=INT_MIN+1;
		int t=0;
		for(int i=0;i<n;i++)
		{
			int c,d;
			cin>>c>>d;
			if(c<a||d<b||d>c)
			{
				t=9;
			}
			a=c;b=d;
		}
		if(t==0)
		cout<<"YES"<<"\n";
		else
		cout<<"NO"<<endl;
	}
	return 0;
}


#include "bits/stdc++.h"

using namespace std;

template<typename... T>
void read(T&... args) {
    ((cin >> args), ...);
}

template<typename... T>
void write(T&&... args) {
    ((cout << args << " "), ...);
}

#define deb(x) cerr << #x << " " << x <<endl;

#define debs(args ...) cerr << __LINE__ << ": ", err(new istringstream(string(#args)), args), cerr << '\n'
void err(istringstream *iss) {}
template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) {
    string _name;
    *iss >> _name;
    if (_name.back()==',') _name.pop_back();
    cerr << _name << " = " << _val << "; ", err(iss, args ...);
}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    int tc,t(1);
    for(cin>>tc; tc; ++t,--tc){
        int n;
        read(n);
        // cout<<n<<endl;
        int a,b,mxa=INT_MIN,mxb=INT_MIN;
        bool res=true;;

        for(int i=1; i<=n; ++i)  {

            read(a,b);
            cin>>a>>b;

            // cout<<a<<" "<<b<<endl;

            if(a<mxa or b<mxb){
                res = false;
                break;
            }

            mxb=max(mxb,b);
            mxa=max(mxa,a);

            if(mxa<mxb){
                // cout<<a<<" "<<b<<endl;
                res = false;
                break;
            }

        }

        cout<<(res?"YES":"NO")<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
    int t; std::cin >> t;
    while(t--)
    {
        ll n,x,y; cin>>n>>x>>y;
        ll i,b,a,s=0; int v[n];

        if(x>=y)
        {
           for(i=0;i<n-1;i++)
           {
              cin>>a>>b;
             if(a<x) s=1;
             else if(a>=x)
             {
                 if(b<y) s=1;
                 if(a-x>=b-y) continue;
                 else s=1;
             }
            // x=a,y=b;
           }
           if(s==1) cout<<"NO";
           else cout<<"YES";
        }

        else
        {
            cout<<"NO";
       for(i=0;i<n-1;i++)
       { cin>>a>>b; }

        }

         cout<<"\n";

    }
	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
    int t; std::cin >> t;
    while(t--)
    {
        ll n,x,y; cin>>n>>x>>y;
        ll i,b,a,s=0; int v[n];

        if(x>=y)
        {
           for(i=0;i<n-1;i++)
           {
              cin>>a>>b;
             if(a<x) s=1;
             else if(a>=x)
             {
                 if(b<y) s=1;
                 if(a-x>=b-y) continue;
                 else s=1;
             }
             x=a,y=b;
           }
           if(s==1) cout<<"NO";
           else cout<<"YES";
        }

        else
        {
            cout<<"NO";
       for(i=0;i<n-1;i++)
       { cin>>a>>b; }

        }

         cout<<"\n";

    }
	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
    int t; std::cin >> t;
    while(t--)
    {
        ll n,x,y; cin>>n>>x>>y;
        ll i,b,a,s=0;
        if(x>=y)
        {
           for(i=0;i<n-1;i++)
           {
              cin>>a>>b;
             if(a<x) s=1;
             else if(a>=x)
             {
                 if(b<y) s=1;
                 if(a-x>=b-y) continue;
                 else s=1;
             }
           }
           if(s==1) cout<<"NO";
           else cout<<"YES";
        }

        else cout<<"NO";

         cout<<"\n";

    }
	// your code goes here
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

   int t; cin>>t;
   while(t--)
   {   int n; cin>>n;
       multimap<int,int> m;
       int p,c;
       if(n==1)
       {
        cin>>p>>c;
        if(p==c||p>c) cout<<"YES";
        else cout<<"NO";
       }
       else
       {
       for(int i=0;i<n;i++)
       {
           cin>>p>>c; //cout<<p<<c<<"  ";
           m.insert(pair<int,int> (p,c));
       }  int v=0;
     //  for(auto i=m.begin();i!=m.end();i++)
       ///cout<<i->first<<i->second<<" ";

      auto i=m.begin(); p=i->first; c=i->second; i++;
      if(p>=c)
      {
        //cout<<endl;
       for(;i!=m.end();i++)
       {
          if(i->first==p)
          {
              if(i->second!=c) { v++; break;}
          }
         else  if(i->first>p)
          {
              if(i->second<c) { v++; break;}
              if(i->second-c > i->first-p){ v++; break;}
          }

         // cout<<p<<c<<" ";
           p=i->first; c=i->second;
       }
       if(v==1) cout<<"NO";
       else cout<<"YES";
      }
      else cout<<"NO";
       }
       cout<<endl;
   }
    return 0;

}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
    int t; std::cin >> t;
    while(t--)
    {
        ll n,x,y; cin>>n>>x>>y;
        ll i,b,a,s=0; int v[n];
         ll m=0;;
        if(x>=y)
        {
           for(i=0;i<n-1;i++)
           {
              cin>>a>>b;
             if(a<x) s=1;
             else if(a>=x)
             {
                 if(b<y) s=1;
                 if(a-x>=b-y) m=1;
                 else s=1;
             }
             x=a,y=b;
           }
           if(s==1) cout<<"NO";
           else cout<<"YES";
        }

        else
        {
            cout<<"NO";
       for(i=0;i<n-1;i++)
       { cin>>a>>b; }

        }

         cout<<"\n";

    }
	// your code goes here
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

   int t; cin>>t;
   while(t--)
   {   int n; cin>>n;
       multimap<int,int> m;
       int p,c;
       if(n==1)
       {
        cin>>p>>c;
        if(p==c||p>c) cout<<"YES";
        else cout<<"NO";
       }
       else
       {
       for(int i=0;i<n;i++)
       {
           cin>>p>>c; //cout<<p<<c<<"  ";
           m.insert(pair<int,int> (p,c));
       }  int v=0;
     //  for(auto i=m.begin();i!=m.end();i++)
       ///cout<<i->first<<i->second<<" ";

      auto i=m.begin(); p=i->first; c=i->second; i++;
      if(p>=c)
      {
        //cout<<endl;
       for(;i!=m.end();i++)
       {
          if(i->first==p)
          {
              if(i->second!=c) { v++; break;}
          }
         else  if(i->first>p)
          {
              if(i->second<c) { v++; break;}
              if(i->second-c > i->first-c){ v++; break;}
          }

         // cout<<p<<c<<" ";
           p=i->first; c=i->second;
       }
       if(v==1) cout<<"NO";
       else cout<<"YES";
      }
      else cout<<"NO";
       }
       cout<<endl;
   }
    return 0;

}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

   int t; cin>>t;
   while(t--)
   {   int n; cin>>n;

       int p,c;

       int a[n][2];
       cin>>p>>c; int v=0;
       for(int i=1;i<n;i++)
       {
           cin>>a[i][0]>>a[i][1];
           if(p>a[i][0]) v++;
           if(p==a[i][0] )
           {
               if(  c!=a[i][1]) v++;
           }
          if(a[i][0]>p)
          {
              if(a[i][1]-c>a[i][0]-p) v++;
          }

        p=a[i][0],c=a[i][1];
       }
       if(v==0) cout<<"YES";
       else cout<<"NO";
       cout<<endl;
   }
    return 0;

}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

   int t; cin>>t;
   while(t--)
   {   int n; cin>>n;
       multimap<int,int> m;
       int p,c;
       for(int i=0;i<n;i++)
       {
           cin>>p>>c; //cout<<p<<c<<"  ";
           m.insert(pair<int,int> (p,c));
       }  int v=0;
     //  for(auto i=m.begin();i!=m.end();i++)
       ///cout<<i->first<<i->second<<" ";
      auto i=m.begin(); p=i->first; c=i->second; i++;
        //cout<<endl;
       for(;i!=m.end();i++)
       {
          if(i->first==p)
          {
              if(i->second!=c) { v++; break;}
          }
          if(i->first>p)
          {
              if(i->second<c) { v++; break;}
          }
         // cout<<p<<c<<" ";
           p=i->first; c=i->second;
       }
       if(v==1) cout<<"NO";
       else cout<<"YES";
       cout<<endl;
   }
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define w(t) int t;cin>>t;while(t--)
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<n;i++)
#define pii pair<int,int>
#define pb push_back
#define mk make_pair

int main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
w(t){
int n;
cin>>n;
int p[n],c[n];
int f=0;
for(int i=0;i<n;i++)cin>>p[i]>>c[i];
for(int i=0;i<n-1;i++){
if(p[i]>p[i+1])f=1;
else if(c[i]>c[i+1])f=1;
else if(i+1<n && ((p[i+1]-p[i])<(c[i+1]-c[i])))f=1;
else if(p[i]<c[i])f=1;
}
if(f)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define w(t) int t;cin>>t;while(t--)
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<n;i++)
#define pii pair<int,int>
#define pb push_back
#define mk make_pair

int main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
w(t){
int n;
cin>>n;
int p[n],c[n];
int f=0;
for(int i=0;i<n;i++)cin>>p[i]>>c[i];
for(int i=0;i<n-1;i++){
if(p[i]>p[i+1])f=1;
else if(c[i]>c[i+1])f=1;
else (i+1<n && ((p[i+1]-p[i])<(c[i+1]-c[i])))f=1;
else if(p[i]<c[i])f=1;
}
if(f)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define w(t) int t;cin>>t;while(t--)
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<n;i++)
#define pii pair<int,int>
#define pb push_back
#define mk make_pair

int main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
w(t){
int n;
cin>>n;
int p[n],c[n];
int f=0;
for(int i=0;i<n;i++)cin>>p[i]>>c[i];
for(int i=0;i<n-1;i++){
if(i+1<n && p[i]>p[i+1])f=1;
else if(i+1<n && c[i]>c[i+1])f=1;
else (i+1<n && (p[i+1]-p[i])<(c[i+1]-c[i]))f=1;
else if(p[i]<c[i])f=1;
}
if(f)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define w(t) int t;cin>>t;while(t--)
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<n;i++)
#define pii pair<int,int>
#define pb push_back
#define mk make_pair

int main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
w(t){
int n;
cin>>n;
int p[n],c[n];
int f=0;
for(int i=0;i<n;i++)cin>>p[i]>>c[i];
for(int i=0;i<n-1;i++){
if(p[i]>p[i+1])f=1;
else if(c[i]>c[i+1])f=1;
else if((p[i+1]-p[i])<(c[i+1]-c[i]))f=1;
else if(p[i]<c[i])f=1;
}
if(f)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define w(t) int t;cin>>t;while(t--)
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<n;i++)
#define pii pair<int,int>
#define pb push_back
#define mk make_pair

int main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
w(t){
int n;
cin>>n;
int p[n],c[n];
int f=0;
for(int i=0;i<n;i++)cin>>p[i]>>c[i];
for(int i=0;i<n-1;i++){
if(p[i]>p[i+1])f=1;
else if(c[i]>c[i+1])f=1;
else ((p[i+1]-p[i])<(c[i+1]-c[i]))f=1;
else if(p[i]<c[i])f=1;
}
if(f)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define w(t) int t;cin>>t;while(t--)
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<n;i++)
#define pii pair<int,int>
#define pb push_back
#define mk make_pair

int main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
w(t){
int n;
cin>>n;
int p[n],c[n];
int f=0;
for(int i=0;i<n;i++)cin>>p[i]>>c[i];
for(int i=0;i<n-1;i++){
if(i+1<n && p[i]>p[i+1])f=1;
else if(i+1<n && c[i]>c[i+1])f=1;
else if(i+1<n && (p[i+1]-p[i])<(c[i+1]-c[i]))f=1;
else if(p[i]<c[i])f=1;
}
if(f)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define w(t) int t;cin>>t;while(t--)
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<n;i++)
#define pii pair<int,int>
#define pb push_back
#define mk make_pair

int main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
w(t){
int n;
cin>>n;
int p[n],c[n];
int f=0;
for(int i=0;i<n;i++)cin>>p[i]>>c[i];
for(int i=0;i<n-1;i++){
if(p[i]>p[i+1])f=1;
else if(c[i]>c[i+1])f=1;
else if((p[i+1]-p[i])<(c[i+1]-c[i]))f=1;
}
if(f)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define w(t) int t;cin>>t;while(t--)
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<n;i++)
#define pii pair<int,int>
#define pb push_back
#define mk make_pair

int main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
w(t){
int n;
cin>>n;
int p[n],c[n];
for(int i=0;i<n;i++){
	cin>>p[i];
	cin>>c[i];
}
int f=0,fn=0,fs=0;
for(int i=0;i<n-1;i++){
	if(p[i]<=p[i+1])continue;
	else {f=1;break;}
}
for(int i=0;i<n-1;i++){
	if(c[i]<=c[i+1])continue;
	else {fn=1;break;}
}
for(int i=0;i<n;i++){
	if(p[i]>=c[i])continue;
	else {fs=1;break;}
}
if(f || fn||fs)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
	return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define w(t) int t;cin>>t;while(t--)
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<n;i++)
#define pii pair<int,int>
#define pb push_back
#define mk make_pair

int main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
w(t){
int n;
cin>>n;
int p[n],c[n];
int f=0;
for(int i=0;i<n;i++)cin>>p[i]>>c[i];
for(int i=0;i<n-1;i++){
if(i+1<n && p[i]>p[i+1])f=1;
else if(i+1<n && c[i]>c[i+1])f=1;
else if(i+1<n && (p[i+1]-p[i])<(c[i+1]-c[i]))f=1;
else if(p[i]<c[i])f=1;
}
if(p[n-1]<c[n-1])f=1;
if(f)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}


#include <iostream>
#include<vector>
using namespace std;

int main() {
    // your code goes here
    int t;
    cin>>t;
    while(t--)
    {
        int n,p=0;
        cin>>n;
        int a[n];
        int c=0;
        int b[n];
        for(int i=0;i<n;i++)
        {
            cin>>a[i]>>b[i];
        }
        if(n==1)
        {
            cout<<"YES"<<endl;
        }
        else{
        for(int i=0;i<n-1;i++)
        {
            if(b[i+1]>b[i])
            {
                if(a[i+1]>a[i])
                {
                    c=1;
                }
                else if(a[i+1]<=a[i])
                {
                    c=0;
                    cout<<"NO"<<endl;
                    break;
                }
            }
            else if(b[i+1]==b[i])
            {
                 if(a[i+1]>=a[i])
                {
                    c=1;
                }
                else if(a[i+1]<a[i])
                {
                    c=0;
                    cout<<"NO"<<endl;
                    break;
                }
            }
          else  if(a[i+1]<a[i])
            {
                c=0;
                cout<<"NO"<<endl;
                    break;

            }
           else if(b[i+1]<b[i])
            {
                c=0;
                cout<<"NO"<<endl;
                    break;
            }
          else  if(a[i+1]>a[i])
            {
                if(b[i+1]>=b[i])
                {
                    c=1;
                }
                else
                {
                    c=0;
                    cout<<"NO"<<endl;
                    break;
                }
            }
              else  if(a[i+1]==a[i])
            {
                if(b[i+1]==b[i])
                {
                    c=1;
                }
                else
                {
                    c=0;
                    cout<<"NO"<<endl;
                    break;
                }
            }

        }
        if(c==1)
        {
             cout<<"YES"<<endl;

        }
    }
}
    return 0;
}


#include <iostream>
#include<vector>
using namespace std;

int main() {
    // your code goes here
    int t;
    cin>>t;
    while(t--)
    {
        int n,p=0;
        cin>>n;
      int a[n];
        int c=0;
        int b[n];
        for(int i=0;i<n;i++)
        {
            cin>>a[i]>>b[i];
        }
         for(int i=0;i<n;i++)
        {
            if(a[i]>=b[i])
            {
                p++;
            }
            else{
                p=0;
                 cout<<"NO"<<endl;
                 break;
            }
    }
        if(n==1)
        {
            if(a[0]>=b[0])
            {
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }

        }

         if(p==n){
        for(int i=0;i<n-1;i++)
        {
            if(b[i+1]>b[i])
            {
                if(a[i+1]>a[i])
                {
                    c=1;
                }
                else if(a[i+1]<=a[i])
                {
                    c=0;
                    cout<<"NO"<<endl;
                    break;
                }
            }
             if(b[i+1]==b[i])
            {
                 if(a[i+1]>=a[i])
                {
                    c=1;
                }
                else if(a[i+1]<a[i])
                {
                    c=0;
                    cout<<"NO"<<endl;
                    break;
                }
            }
           if(a[i+1]<a[i])
            {
                c=0;
                cout<<"NO"<<endl;
                    break;

            }
            if(b[i+1]<b[i])
            {
                c=0;
                cout<<"NO"<<endl;
                    break;
            }
           if(a[i+1]>a[i])
            {
                if(b[i+1]>=b[i])
                {
                    c=1;
                }
                else
                {
                    c=0;
                    cout<<"NO"<<endl;
                    break;
                }
            }
              if(a[i+1]==a[i])
            {
                if(b[i+1]==b[i])
                {
                    c=1;
                }
                else
                {
                    c=0;
                    cout<<"NO"<<endl;
                    break;
                }
            }

        }
        if(c==1)
        {
             cout<<"YES"<<endl;

        }
    }
}
    return 0;
}


#include <iostream>
#include<vector>
using namespace std;

int main() {
    // your code goes here
    int t;
    cin>>t;
    while(t--)
    {
        int n,p=0;
        cin>>n;
      int a[n];
        int c=0;
        int b[n];
        for(int i=0;i<n;i++)
        {
            cin>>a[i]>>b[i];
        }
         for(int i=0;i<n;i++)
        {
            if(a[i]>=b[i])
            {
                p++;
            }
            else{
                p=0;
                 cout<<"NO"<<endl;
                 break;
            }
    }
        if(n==1 && p!=0)
        {
            if(a[0]>=b[0])
            {
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }

        }

         if(p==n){
        for(int i=0;i<n-1;i++)
        {
            if(b[i+1]>b[i])
            {
                 int x=b[i+1]-b[i];
                if(a[i+1]>a[i] && (x==(a[i+1]-a[i])))
                {
                    c=1;
                }
                else
                {
                    c=0;
                    cout<<"NO"<<endl;
                    break;
                }
            }
             if(b[i+1]==b[i])
            {
                 if(a[i+1]>=a[i])
                {
                    c=1;
                }
                else if(a[i+1]<a[i])
                {
                    c=0;
                    cout<<"NO"<<endl;
                    break;
                }
            }
           if(a[i+1]<a[i])
            {
                c=0;
                cout<<"NO"<<endl;
                    break;

            }
            if(b[i+1]<b[i])
            {
                c=0;
                cout<<"NO"<<endl;
                    break;
            }
           if(a[i+1]>a[i])
            {
                if(b[i+1]>=b[i])
                {
                    c=1;
                }
                else
                {
                    c=0;
                    cout<<"NO"<<endl;
                    break;
                }
            }
              if(a[i+1]==a[i])
            {
                if(b[i+1]==b[i])
                {
                    c=1;
                }
                else
                {
                    c=0;
                    cout<<"NO"<<endl;
                    break;
                }
            }

        }
        if(c==1)
        {
             cout<<"YES"<<endl;

        }
    }
}
    return 0;
}


#include <iostream>
#include<vector>
using namespace std;

int main() {
    // your code goes here
    int t;
    cin>>t;
    while(t--)
    {
        int n,p=0;
        cin>>n;
      int a[n];
        int c=0;
        int b[n];
        for(int i=0;i<n;i++)
        {
            cin>>a[i]>>b[i];
        }
         for(int i=0;i<n;i++)
        {
            if(a[i]>=b[i])
            {
                p++;
            }
            else{
                p=0;
                 cout<<"NO"<<endl;
                 break;
            }
    }
        if(n==1 && p!=0)
        {
            if(a[0]>=b[0])
            {
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }

        }

         if(p==n){
        for(int i=0;i<n-1;i++)
        {
            if(b[i+1]>b[i])
            {
                if(a[i+1]>a[i])
                {
                    c=1;
                }
                else if(a[i+1]<=a[i])
                {
                    c=0;
                    cout<<"NO"<<endl;
                    break;
                }
            }
             if(b[i+1]==b[i])
            {
                 if(a[i+1]>=a[i])
                {
                    c=1;
                }
                else if(a[i+1]<a[i])
                {
                    c=0;
                    cout<<"NO"<<endl;
                    break;
                }
            }
           if(a[i+1]<a[i])
            {
                c=0;
                cout<<"NO"<<endl;
                    break;

            }
            if(b[i+1]<b[i])
            {
                c=0;
                cout<<"NO"<<endl;
                    break;
            }
           if(a[i+1]>a[i])
            {
                if(b[i+1]>=b[i])
                {
                    c=1;
                }
                else
                {
                    c=0;
                    cout<<"NO"<<endl;
                    break;
                }
            }
              if(a[i+1]==a[i])
            {
                if(b[i+1]==b[i])
                {
                    c=1;
                }
                else
                {
                    c=0;
                    cout<<"NO"<<endl;
                    break;
                }
            }

        }
        if(c==1)
        {
             cout<<"YES"<<endl;

        }
    }
}
    return 0;
}