#include #include using namespace std; int wx, wy, bx, by; unsigned tah = 0; double bestWprob = 1.0; double bestBprob = 1.0; double poleW[2][8][8]; double poleB[2][8][8]; double winW = 0.0; double winB = 0.0; double getProb(int x, int y) { double p = 0; if (x-2 < 0 || y-1 < 0) p-=1; if (x-2 < 0 || y+1 > 7) p-=1; if (x+2 > 7 || y-1 < 0) p-=1; if (x+2 > 7 || y+1 > 7) p-=1; if (x-1 < 0 || y-2 < 0) p-=1; if (x-1 < 0 || y+2 > 7) p-=1; if (x+1 > 7 || y-2 < 0) p-=1; if (x+1 > 7 || y+2 > 7) p-=1; return 1.0/(8+p); } void makeTah(int x, int y, double pole[8][8], double p) { int px[8] = {-2,-2, 2,2,-1,-1, 1,1}; int py[8] = {-1, 1,-1,1,-2, 2,-2,2}; for (int i=0;i<8; ++i) { int xx = x+px[i]; int yy = y+py[i]; if (xx < 0 || xx > 7 || yy < 0 || yy > 7) continue; pole[xx][yy] = p; } } double eval(double pole1[8][8], double pole2[8][8]) { double prob = 0.0; for (int i=0; i< 8; ++i) for (int j=0; j<8; ++j) { if (pole1[i][j] && pole2[i][j]) { double p = pole1[i][j] * pole2[i][j]; if (p > prob) prob = p; } } return prob; } const double PROB_LIMIT = 0.000001; int main(int, char**) { cin >> wx; wx -= 1; cin >> wy; wy -= 1; cin >> bx; bx -= 1; cin >> by; by -=1 ; for (int i=0; i<2; ++i) for (int j=0; j<8; ++j) for (int k=0; k<8; ++k) { poleW[i][j][k] = 0; poleB[i][j][k] = 0; } poleW[0][wx][wy] = 1.0; poleB[0][bx][by] = 1.0; while (bestBprob*bestWprob > PROB_LIMIT) { unsigned t = tah % 2; unsigned nT = (tah+1)%2; // white // spocist prob double bp = 0; for (int x = 0; x < 8; ++x) for (int y=0 ; y < 8; ++y) if (poleW[t][x][y] > 0) { double p = poleW[t][x][y]; double wp = getProb(x, y) * p; //cout << wp << endl;; makeTah(x,y,poleW[nT],wp); if (wp > bp) bp = wp; } bestWprob = bp; bp = eval(poleW[nT], poleB[t]); if (bp > winW) winW = bp; bp = 0; for (int x = 0; x < 8; ++x) for (int y=0 ; y < 8; ++y) if (poleB[t][x][y] > 0) { double p = poleB[t][x][y]; double wp = getProb(x, y) * p; //cout << wp << endl;; makeTah(x,y,poleB[nT],wp); if (wp > bp) bp = wp; } bestBprob = bp; bp = eval(poleB[nT], poleW[nT]); if (bp > winB) winB = bp; //cout << tah << " " << winW << " x " << winB << endl; tah += 1; if (tah > 20) break; } double diff = winW - winB; diff *= (diff < 0 ? -1 : 1); if (diff < PROB_LIMIT) cout << "draw"; else if (winW > winB) cout << "white"; else cout << "black"; cout << endl; return 0; }