#include //#include // Common file //#include // Including seg_tree_order_statistics_node_update #include #include using namespace std; //using namespace __gnu_pbds; typedef long long lo; typedef pair ll;//pair typedef vector vl; //vector of long typedef vector vll; //vector of pair typedef priority_queuep_q; typedef vector< vl > vvl; //vector of vectors #define X first #define Y second #define mp(a,b) make_pair((a),(b)) #define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i #define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j #define REPV(a,b,c) for(lo(a)=b;(a)<(c);(a)++)//a is the variable #define IREP(a,b) for(lo i=(a);i>=(b);i--) #define IREPV(a,b,c) for(lo(a)=b;(a)>=(c);(a)--) #define all(v) (v).begin(),(v).end() #define TRV(a) for(auto it : a) #define INF 500 #define MOD 1000000007 #define M 1000000007 #define CHECK_BIT(var,pos) ((var) & (1<<(pos))) #define pb(a) push_back((a)) #define endl "\n" #define eps 1e-9 #define PI 3.141592653589793 template ostream& operator<< ( ostream &o,vector v ) { if ( v.size() >0 )o< ostream& operator<< ( ostream &o,pair p ) { return o<<"("< istream& operator>> ( istream &in,vector &v ) { for ( unsigned i=0; i>v[i]; return in; } template istream& operator>> ( istream &in,pair &p ) { in>>p.X; in>>p.Y; return in; } #define debug(x) cout<<#x<<"="< an={"UL", "UR", "R", "LR", "LL", "L"}; vvl visited(INF,vl(INF,-1)); lo n; void bfs(ll s){ queueq; q.push(s); visited[s.X][s.Y]=0; while(!q.empty()){ lo x=q.front().X; lo y=q.front().Y; q.pop(); REP(0,6){ lo nx=dx[i]+x; lo ny=dy[i]+y; if(nx>=0 and nx=0 and ny>n; ll s; cin>>s; bfs(s); lo x,y; cin>>x>>y; //REPE(0,n,0,n){cout<ans; ll en=mp(x,y); while(en!=s){ ans.pb(an[visited[en.X][en.Y]]); x=en.X; y=en.Y; en.X-=dx[visited[x][y]]; en.Y-=dy[visited[x][y]]; res++; } reverse(all(ans)); cout<