import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.Scanner; public class Rookie4 { public static void main(String []args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int d = n-1; int [][]hj = new int[d][d]; NodeKnight hh = new NodeKnight(); for(int i=1;i h = new HashSet(); KnightL(h,d,d,i,j,n,n); int count = 1; int k = 0; HashSet hs = new HashSet(); while(count!=-1&&!h.contains(hh)) { HashSet h1 = new HashSet(); HashSet h2 = new HashSet(); Iterator itr = h.iterator(); hh.x=0; hh.y= 0 ; while(itr.hasNext()) { NodeKnight sum = itr.next(); int x = sum.x; int y = sum.y; hs.add(sum); KnightL(h1,x,y,i,j,n,n); if(h1.contains(hh)) { count++; break; } } // itr = h.iterator(); // while(itr.hasNext()) // { // NodeKnight rr = itr.next(); // System.out.print(rr.x+" "+rr.y); // } // System.out.println(); // itr = h1.iterator(); // while(itr.hasNext()) // { // NodeKnight rr = itr.next(); // System.out.print(rr.x+" "+rr.y); // } // System.out.println(); // itr = hs.iterator(); // while(itr.hasNext()) // { // NodeKnight rr = itr.next(); // System.out.print(rr.x+" "+rr.y); // } // System.out.println(); if(h1.contains(hh)) { break; } else if(h1.size()==0) { count=-1; break; } else { h.clear(); h1.removeAll(hs); h.addAll(h1); count++; //System.out.println(">>>>"+h.size()); } // itr = h.iterator(); // while(itr.hasNext()) // { // NodeKnight rr = itr.next(); // System.out.print(rr.x+" "+rr.y); // } // System.out.println(); } // System.out.println(); // System.out.println(count); hj[i-1][j-1]=count; hj[j-1][i-1]=count; } } } for(int i=0;i=0) { if(yp=0) { NodeKnight k = new NodeKnight(); k.x = xp; k.y = yp; h.add(k); } if(yn>=0&&yn=0&&xn=0) { NodeKnight k = new NodeKnight(); //System.out.println(">>>>>>>>>>"); k.x = xn; k.y = yp; h.add(k); } if(yn>=0&&yn=0) { if(ypr=0) { NodeKnight k = new NodeKnight(); k.x = xpr; k.y = ypr; h.add(k); } if(ynr>=0&&ynr=0&&xnr=0) { NodeKnight k = new NodeKnight(); k.x = xnr; k.y = ypr; h.add(k); } if(ynr>=0&&ynr