//>>>BaZ<< queue = new LinkedList(); int xs = ni(),ys = ni(),xd = ni(),yd = ni(); min[xd][yd] = 0; queue.add(new Pair(xd,yd)); while(!queue.isEmpty()) { Pair curr = queue.poll(); for(int i=0;i<6;++i) { int nx = curr.x+dx[i]; int ny = curr.y+dy[i]; if(nx>=0 && nx=0 && ny=0 && ny>=0 && nx= '0' && c <= '9'); if (neg) return -ret; return ret; } public long nextLong() throws IOException { long ret = 0; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (neg) return -ret; return ret; } public double nextDouble() throws IOException { double ret = 0, div = 1; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (c == '.') while ((c = read()) >= '0' && c <= '9') ret += (c - '0') / (div *= 10); if (neg) return -ret; return ret; } private void fillBuffer() throws IOException { bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); if (bytesRead == -1) buffer[0] = -1; } private byte read() throws IOException { if (bufferPointer == bytesRead) fillBuffer(); return buffer[bufferPointer++]; } public void close() throws IOException { if (din == null) return; din.close(); } } static class MyFileReader //File input template { StringTokenizer st; BufferedReader br; MyFileReader() throws IOException { br = new BufferedReader(new FileReader("C://Users/Aman deep/Desktop/input.txt")); } String nextLine() throws IOException { return br.readLine(); } String next() throws IOException { if(st==null || !st.hasMoreTokens()) st = new StringTokenizer(nextLine()); return st.nextToken(); } int nextInt() throws IOException { return Integer.parseInt(next()); } long nextLong() throws IOException { return Long.parseLong(next()); } double nextDouble() throws IOException { return Double.parseDouble(next()); } } static class MyFileReader1 //File input template { StringTokenizer st; BufferedReader br; MyFileReader1() throws IOException { br = new BufferedReader(new FileReader("C://Users/Aman deep/Desktop/output.txt")); } String nextLine() throws IOException { return br.readLine(); } String next() throws IOException { if(st==null || !st.hasMoreTokens()) st = new StringTokenizer(nextLine()); return st.nextToken(); } int nextInt() throws IOException { return Integer.parseInt(next()); } long nextLong() throws IOException { return Long.parseLong(next()); } double nextDouble() throws IOException { return Double.parseDouble(next()); } } }