#ifndef INCLUDED_MAIN #define INCLUDED_MAIN #include __FILE__ using namespace nskr; using mint = modint<0>; int main(void){ int t; cin >> t; int h, w; cin >> h >> w; int x, y; cin >> x >> y; if(x == h){ cout << h-1 << " " << 1 << endl; cin >> x >> y; cout << h-1 << " " << y << endl; }else if(y == w){ cout << 1 << " " << w-1 << endl; cin >> x >> y; cout << x << " " << w-1 << endl; }else if(h==3){ cout << 1 << " " << w-2 << endl; cin >>x >> y; if(x == h && y == w){ cout << 2 << " " << w-2 << endl; }else if(x == h){ cout << x-1 << " " << y-1 << endl; cin >> x >> y; cout << 2 << " " << w-1 << endl; }else{ cout << 1 << " " << w-1 << endl; cin >> x >> y; cout << 2 << " " << w-1 << endl; } }else if(w==3){ cout << h-2 <<" " << 1 << endl; cin >> x >> y; if(x==h&&y==w){ cout << h-2 << " " << 2 << endl; } else if(y == w){ cout << x-1 << " " << y-1 << endl; cin >> x >> y; cout << h-1 << 2 << endl; }else{ cout << h-1 << " " << 1 << endl; cin >> x >> y; cout << h-1 << " " << 2 << endl; } }else{ cout << h-2 << " " << 1 << endl; cin >>x >> y; if(x == h && y == w){ cout << h-2 << " " << w-1 << endl; }else if(y == w){ cout << x-1 << " " << y-1 << endl; cin >> x >> y; cout << h-1 << " " << w-1 << endl; }else{ cout << h-2 << " " << w-2 << endl; cin >> x >> y; cout << h-1 << " " << w-1 << endl; } } cin >> x >> y; } #else #include using namespace std; using ll = long long; using ld = long double; #define rep(i,n) for(i=0;i<(n);i++) #define all(a) a.begin(), a.end() namespace nskr{ //nyaan氏の実装をかなり参考にした template struct modint{ int v; static int& MOD(){ static int mod = 998244353; return mod; } static int get_mod() { return MOD(); } static void set_mod(int m) { MOD() = m; } modint() :v(0){} modint(long long x) : v( (x>=0 ? x%MOD() : (x%MOD() + MOD()))){} long long val() const {return v;} modint& operator+=(const modint& x){if((v+=x.v) >= MOD()) v-=MOD(); return *this; } modint& operator-=(const modint& x){if((v-=x.v) < 0 ) v+=MOD(); return *this; } modint& operator*=(const modint& x){v = (int)(1ll * v * x.v % MOD()); return *this;} modint& operator/=(const modint& x){v = (int)(1ll * v * x.inv().val() % MOD()); return *this;} modint operator-() const {return modint(-v);} modint operator+() const {return *this;} modint operator+(const modint& x) const {return modint(*this)+=x;} modint operator-(const modint& x) const {return modint(*this)-=x;} modint operator*(const modint& x) const {return modint(*this)*=x;} modint operator/(const modint& x) const {return modint(*this)/=x;} bool operator== (const modint& x) const {return v==x.v;} bool operator!= (const modint& x) const {return v!=x.v;} friend ostream &operator<<(ostream &os, const modint &p) { return os << p.v; } friend istream &operator>>(istream &is, modint &a) { int t; is >> t; a = modint(t); return (is); } modint pow(unsigned long long n) const { modint ret(1), mul(v); while(n){ if(n&1) ret *= mul; mul *= mul; n >>=1; } return ret; } modint inv() const{ //参考: https://qiita.com/sesame0224/items/f2ac77c367f588c0d29d int a = v, b = MOD(), u = 1, w = 0; while(b){ int t = a/b; swap(a -= t*b, b); swap(u -= t*w, w); } u%=MOD(); return(u<0?u+MOD():u); } }; template struct combination{ vector fac; combination():fac({mint(1)}){} void preculc(int n){ fac.reserve(n); while(fac.size() <= n){ fac.push_back( (*fac.rbegin()) * mint(fac.size()) ); } return; } mint comb(int n, int r){ if(r>n || r<0 || n<0) return 0; if(n-r < r) r = n-r; if(fac.size() > n) return fac[n] * fac[r].inv() * fac[n-r].inv(); else{ mint ret = fac[r].inv(); for(;r--;) ret *= (n-r+1); return ret; } } }; } #endif