#include #include #include #include #include using namespace std; typedef long long LL; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ LL q,n,x,y,i; cin >> q; while(q--) { cin >> n; LL max_x= -1000000,max_y = -1000000,min_x = 1000000,min_y = 100000,flag = 1,b,h,i; LL a[n+1][2]; for(i = 0;i < n;i++) { cin >> x >> y; a[i][0] = x; a[i][1] = y; if(x > max_x) max_x = x; if(x < min_x) min_x = x; if(y < min_y) min_y = y; if(y > max_y) max_y = y; } b = max_x - min_x; h = max_y - min_y; if(n < 3) cout << "YES" << endl; else { flag = 1; for(i = 0; i < n;i++) { if(a[i][0] == max_x || a[i][0] == min_x) { continue; } else if(a[i][1] == min_y || a[i][1] == max_y) continue; else { flag = 0; break; } } if(flag) cout << "YES" << endl; else cout << "NO" << endl; } } return 0; }