#include using namespace std; int main() { int x; cin>>x; int array[25][25]; for(int i=1;i > q; pair foo; foo=make_pair(0,0); q.push(foo); while(q.size()!=0){ int one=q.front().first; int two=q.front().second; q.pop(); if(one+aarray[one][two]+1){ array[one+a][two+b]=array[one][two]+1; foo=make_pair(one+a,two+b); q.push(foo); }if(one-a>=0&&two+barray[one][two]+1){ array[one-a][two+b]=array[one][two]+1; foo=make_pair(one-a,two+b); q.push(foo); }if(one+a=0&&array[one+a][two-b]>array[one][two]+1){ array[one+a][two-b]=array[one][two]+1; foo=make_pair(one+a,two-b); q.push(foo); }if(one-a>=0&&two-b>=0&&array[one-a][two-b]>array[one][two]+1){ array[one-a][two-b]=array[one][two]+1; foo=make_pair(one-a,two-b); q.push(foo); }if(one+barray[one][two]+1){ array[one+b][two+a]=array[one][two]+1; foo=make_pair(one+b,two+a); q.push(foo); }if(one-b>=0&&two+aarray[one][two]+1){ array[one-b][two+a]=array[one][two]+1; foo=make_pair(one-b,two+a); q.push(foo); }if(one+b=0&&array[one+b][two-a]>array[one][two]+1){ array[one+b][two-a]=array[one][two]+1; foo=make_pair(one+b,two-a); q.push(foo); }if(one-b>=0&&two-a>=0&&array[one-b][two-a]>array[one][two]+1){ array[one-b][two-a]=array[one][two]+1; foo=make_pair(one-b,two-a); q.push(foo); } } if(array[x-1][x-1]==2147483640){ cout<<-1; }else{ cout<