/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package horsemeet; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.AbstractQueue; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Deque; import java.util.PriorityQueue; import java.util.StringTokenizer; /** * * @author cteam063 */ public class Horsemeet { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer row1 = new StringTokenizer(in.readLine()); //ArrayList whiteK = new ArrayList<>(); int wx = Integer.parseInt(row1.nextToken()); int wy = Integer.parseInt(row1.nextToken()); int whiteK = (wx-1) * 10 + (wy-1); //ArrayList blackK = new ArrayList<>(); StringTokenizer row2 = new StringTokenizer(in.readLine()); int bx = Integer.parseInt(row2.nextToken()); int by = Integer.parseInt(row2.nextToken()); int blackK = (bx-1) * 10 + (by-1); int[][] white = new int[8][8]; int[][] black = new int[8][8]; int[][] visited = new int[8][8]; int[][] visitedB = new int[8][8]; for (int i = 0; i <8 ; i++){ for (int j=0; j<8; j++){ visited[i][j] = -1; } } for (int i = 0; i <8 ; i++){ for (int j=0; j<8; j++){ visitedB[i][j] = -1; } } ArrayDeque q = new ArrayDeque<>(); q.add(whiteK); visited[whiteK/10][whiteK%10] = 0; int tmp = 0; //int tmpB = 0; while(!q.isEmpty()){ tmp =q.poll(); //System.out.println("pos "+tmp); if (test((tmp/10) - 2,(tmp%10) + 1, visited)) { //System.out.print("1 "); q.add(((tmp/10) - 2) * 10 + (tmp%10) + 1); visited[(tmp/10)-2][(tmp%10)+1]= visited[tmp/10][tmp%10]+1; } if (test((tmp/10) - 1,(tmp%10) + 2, visited)) { //System.out.print("2 "); q.add(((tmp/10) - 1)*10 + (tmp%10) + 2); visited[(tmp/10)-1][(tmp%10)+2]= visited[tmp/10][tmp%10]+1; } if (test((tmp/10) +1,(tmp%10) + 2, visited)) { //System.out.print("3 "); q.add(((tmp/10) +1)*10 + (tmp%10) + 2); visited[(tmp/10)+1][(tmp%10)+2]= visited[tmp/10][tmp%10]+1; } if (test((tmp/10) +2,(tmp%10) + 1, visited)) { //System.out.print("4 "); q.add(((tmp/10) + 2)*10 + (tmp%10) + 1); visited[(tmp/10)+2][(tmp%10)+1]= visited[tmp/10][tmp%10]+1; } if (test((tmp/10) + 2,(tmp%10) - 1, visited)) { //System.out.print("5 "); q.add(((tmp/10) + 2)*10 + (tmp%10) - 1); visited[(tmp/10)+2][(tmp%10)-1]= visited[tmp/10][tmp%10]+1; } if (test((tmp/10) + 1,(tmp%10) - 2, visited)) { //System.out.print("6 "); q.add(((tmp/10) + 1)*10 + (tmp%10) - 2); visited[(tmp/10)+1][(tmp%10)-2]= visited[tmp/10][tmp%10]+1; } if (test((tmp/10) - 1,(tmp%10) -2, visited)) { //System.out.print("7 "); q.add(((tmp/10) - 1)*10 + (tmp%10) - 2); visited[(tmp/10)-1][(tmp%10)-2]= visited[tmp/10][tmp%10]+1; } if (test((tmp/10) - 2,(tmp%10) - 1, visited)) { q.add(((tmp/10) - 2)*10 + (tmp%10) -1 ); visited[(tmp/10)-2][(tmp%10)-1]= visited[tmp/10][tmp%10]+1; } } q.add(blackK); visitedB[blackK/10][blackK%10] = 0; tmp = 0; while(!q.isEmpty()){ tmp =q.poll(); //System.out.println("pos "+tmp); if (test((tmp/10) - 2,(tmp%10) + 1, visitedB)) { // System.out.print("1 "); q.add(((tmp/10) - 2) * 10 + (tmp%10) + 1); visitedB[(tmp/10)-2][(tmp%10)+1]= visitedB[tmp/10][tmp%10]+1; } if (test((tmp/10) - 1,(tmp%10) + 2, visitedB)) { //System.out.print("2 "); q.add(((tmp/10) - 1)*10 + (tmp%10) + 2); visitedB[(tmp/10)-1][(tmp%10)+2]= visitedB[tmp/10][tmp%10]+1; } if (test((tmp/10) +1,(tmp%10) + 2, visitedB)) { // System.out.print("3 "); q.add(((tmp/10) +1)*10 + (tmp%10) + 2); visitedB[(tmp/10)+1][(tmp%10)+2]= visitedB[tmp/10][tmp%10]+1; } if (test((tmp/10) +2,(tmp%10) + 1, visitedB)) { //System.out.print("4 "); q.add(((tmp/10) + 2)*10 + (tmp%10) + 1); visitedB[(tmp/10)+2][(tmp%10)+1]= visitedB[tmp/10][tmp%10]+1; } if (test((tmp/10) + 2,(tmp%10) - 1, visitedB)) { //System.out.print("5 "); q.add(((tmp/10) + 2)*10 + (tmp%10) - 1); visitedB[(tmp/10)+2][(tmp%10)-1]= visitedB[tmp/10][tmp%10]+1; } if (test((tmp/10) + 1,(tmp%10) - 2, visitedB)) { // System.out.print("6 "); q.add(((tmp/10) + 1)*10 + (tmp%10) - 2); visitedB[(tmp/10)+1][(tmp%10)-2]= visitedB[tmp/10][tmp%10]+1; } if (test((tmp/10) - 1,(tmp%10) -2, visitedB)) { // System.out.print("7 "); q.add(((tmp/10) - 1)*10 + (tmp%10) - 2); visitedB[(tmp/10)-1][(tmp%10)-2]= visitedB[tmp/10][tmp%10]+1; } if (test((tmp/10) - 2,(tmp%10) - 1, visitedB)) { q.add(((tmp/10) - 2)*10 + (tmp%10) -1 ); visitedB[(tmp/10)-2][(tmp%10)-1]= visitedB[tmp/10][tmp%10]+1; } } int whitewin=0; int blackwin=0; for (int i = 0; i <8 ; i++){ for (int j=0; j<8; j++){ //System.out.print(visitedB[i][j] + " "); if ((visited[i][j]+visitedB[i][j]) % 2 == 0) blackwin++; else whitewin++; } //System.out.println(); } if (whitewin > blackwin) System.out.println("white"); else if (whitewin < blackwin) System.out.println("black"); else System.out.println("draw"); } static boolean test(int x, int y, int [][] v){ if ((x < 0) || (x > 7) || (y < 0) || (y > 7) || (v[x][y] != -1)) return false; else return true; } }