#include using namespace std; using Int=long long; using Real=long double; templateinline bool chmin(T&A,S B){if(A>B){A=B;return true;}else{return false;}} templateinline bool chmax(T&A,S B){if(AA[3]; void sol() { cin>>N; A[0]={2,8}; A[1]={3,9}; A[2]={7,9}; REP(i,N) { int a,b,c,d;cin>>a>>b>>c>>d; REP(j,3)if(A[j]==pair{a,b})A[j]={c,d}; } cout<<(A[0]==pair{5,8}&&A[1]==pair{4,8}&&A[2]==pair{6,8}?"YES":"NO")<<"\n"; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout<>T; while(T--)sol(); }