#include using namespace std; #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << std::endl; } template void __f(const char* names, Arg1&& arg1, Args&&... args){ const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...); } //#define mod 1000000007 ///*******/// #define int long long ///*****//// const int mod=1e9+7; #define pi pair #define pb emplace_back #define F first #define S second #define fills(x,y) memset(x,y,sizeof x) #define rep(i,n) for(i=0;i static void amin(T &x, U y) { if(y < x) x = y; } template static void amax(T &x, U y) { if(x < y) x = y; } template void scan(T &x){x=0;bool neg=0;register T c=inchar();if(c=='-') neg=1,c=inchar();while((c<48)||(c>57))c=inchar();for(;c<48||c>57;c=inchar()); for(;c>47&&c<58;c=inchar())x=(x<<3)+(x<<1)+(c&15);if(neg)x*=-1;} template void output(T n){bool neg=0;if(n<0)n*=-1,neg=1;char snum[65];int i=0;do {snum[i++]=n%10+'0';n/=10;}\ while(n);i=i-1; if(neg)putchar('-'); while(i>=0)outchar(snum[i--]);outchar('\n');} inline void instr(char *str){register char c=0;register int i=0;while(c<33)c=inchar();while (c!='\n'&&c!=' '&&c!=EOF){\ str[i]=c;c=inchar();++i;}str[i]='\0';} template T lcm(T a, T b){return (a*(b/__gcd(a,b)));} template inline T MOD(T a, T b) {return (a T add(T a, T b, T c){T x=a+b;return (x>=c ? x-c : x);} template T mod_neg(T a, T b) {a=MOD(a, b);if(a<0){a+=b;}return a;} template T expo(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;} template T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=MOD(x*p,m);p=MOD(p*p,m);n>>=1;}return x;} template T exted_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;t=xx;\ xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;} template T mod_inverse(T a, T n){T x,y;T d = exted_euclid(a, n, x, y);return (d>1?-1:mod_neg(x,n));} #define tcsolve() int tcs; cin>>tcs;while(tcs--) solve(); //inline string to_string(int num){stringstream ss;ss<=n or b<0 or b>=n or vis[a][b])?0 : 1; } struct bansal { int f, s, time; }last[MAX][MAX]; void bfs(int n,int a, int b, int c, int d) { queue >q; q.push({a,b}); last[a][b]={-1,-1,-1}; vis[a][b]=1; vectorvec; while(!q.empty()) { int x = q.front().first, y=q.front().second; q.pop(); for(int i=0; i<6; ++i) { int new_x = x+dx[i], new_y = y+dy[i]; if(check(new_x, new_y, n)) { if(new_x ==c and new_y == d) { vec.pb(i); while(last[x][y].time !=-1) { vec.pb(last[x][y].time); int k1 = last[x][y].f; int k2= last[x][y].s; x=k1, y=k2; } cout<>n>>a>>b>>c>>d; bfs(n,a,b,c,d); } int32_t main() { fastio; #ifdef LOCAL freopen("in.c","r",stdin); //freopen("out.c","w",stdout); #endif solve(); return 0; }