#include #include #include #include #include using namespace std; int main() { unsigned short q; cin >> q; while (q--) { unsigned short n; cin >> n; int x[n], y[n]; int vx = 0, vy = 0; bool ok = true; for (int t1 = 0; t1 < n; ++t1) { cin >> x[t1] >> y[t1]; if (t1) { if (x[t1] != x[t1-1]) ++vx; if (y[t1] != y[t1-1]) ++vy; } } if (vx+vy <= n) cout << "YES\n"; else cout << "NO\n"; } return 0; }