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