#include using namespace std; #define rep(i,n) for (int i=0;i<(int)(n);i++) #define all(v) v.begin(),v.end() using ll=long long; using pll=pair; using tll=tuple; const ll INF=(1ll<<60); template void chmin(T &a,T b){ if(a>b){ a=b; } } template void chmax(T &a,T b){ if(a cell(6,0); while(t--){ vector cnt(6,0); rep(i,6){ int d; cin >> d; d--; cnt[d]++; } vector> v; rep(i,6){ v.emplace_back(cnt[i],i); } sort(all(v)); reverse(all(v)); for(auto &[a,b]:v){ if(cell[b]<=5){ cout << b+1 << " " << cell[b]+1 << endl; cell[b]++; break; } } } }