#include using namespace std; const long long INF = 1LL << 60; // 10^18 より大きい const int inf = 1<<30; // 10^9 より大きい const long long MOD1 = 1000000007; const long long MOD2 = 998244353; typedef long long ll; //a:97, A:65 const int dx[]={1,0,-1,0,-1,1,1,-1}; const int dy[]={0,1,0,-1,-1,-1,1,1}; const double PI = acos(-1); #define Yes cout << "Yes\n" #define No cout << "No\n" typedef pair pll; typedef pair pii; typedef vector> vvi; typedef vector> vvll; // priority_queue,greater> q; template inline bool chmin(T& a, const U& b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, const U& b) { if (a < b) { a = b; return true; } return false; } /* 好きなマスからスタート 同じマスを訪れない。 */ int N=20,T=400; int A[400][400]; vector> best_ans,ans2; vvi best_used; int best_score=-1; void solve(int sy,int sx){ int y=sy,x=sx; // 初期位置 int score=A[y][x]; vvi used(N,vector(N,0)); vector ans; ans.push_back({y,x}); used[y][x]=1; for(int t=0;t> dummy >> T; int TT=T; for(int i=0;i> A[i][j]; for(int i=0;i=0;i--){ cnt++; cout << best_ans[i].first << " " << best_ans[i].second << "\n"; if(cnt==TT) return 0; } for(auto [y,x]:ans2){ cnt++; cout << y << " " << x << "\n"; if(cnt==TT) return 0; } }