#include using namespace std; using ll = long long; bool solve() { int a; cin >> a; for (int i = 0; i < a; i++) { ll x1, x2, x3, x4, x5; cin >> x1>>x2>>x3>>x4>>x5; if (x1!=x3) return false; if (x2!=x4 || x2!=x5 || x4!=x5) return false; if (x1==x2) return false; } return true; } int main() { int t; cin >> t; while (t--) { if (solve()) cout << "Yes" << endl; else cout << "No" << endl; } }