#include #include #include #include using namespace std; typedef long double n_t; typedef vector>> m_t; static const vector> kMoveModifs = { // row, col { -2, -1 }, { -2, 1 }, { -1, 2 }, { 1, 2 }, { 2, 1 }, { 2, -1 }, { -1, -2 }, { 1, -2 }, }; static m_t black_grid(8, vector>(8, unordered_map())); static m_t white_grid(8, vector>(8, unordered_map())); static void PrecalcProb(const n_t& curr_prob, int r, int c, m_t& grid, int step) { if (step == 9) return; grid[r][c][step] = curr_prob; vector> moves; moves.reserve(8); for (const auto& m : kMoveModifs) { auto new_r = r + m[0]; auto new_c = c + m[1]; if ((min(new_r, new_c) < 0) || (max(new_r, new_c) > 7)) continue; moves.emplace_back(new_r, new_c); } auto next_prob = curr_prob * (1.0L / static_cast(moves.size())); auto next_step = step + 1; for (const auto& p : moves) PrecalcProb(next_prob, p.first, p.second, grid, next_step); } static n_t CalcWhiteWinningProb() { n_t prob = 1.0; for (int i = 0; i < 8; ++i) { for (int j = 0; j < 8; ++j) { for (const auto& p : white_grid[i][j]) { auto iter(black_grid[i][j].find(p.first - 1)); if (iter == black_grid[i][j].end()) continue; prob *= p.second * iter->second; } } } return prob; } int main() { ios_base::sync_with_stdio(false); int r_1, c_1, r_2, c_2; cin >> r_1 >> c_1 >> r_2 >> c_2; --r_1, --c_1, --r_2, --c_2; PrecalcProb(1.0, r_1, c_1, white_grid, 0); PrecalcProb(1.0, r_2, c_2, black_grid, 0); auto prob = CalcWhiteWinningProb(); n_t one_half = 0.5L; auto diff = prob - one_half; if (abs(diff) < 1e-6L) { cout << "draw" << endl; } else { if (diff > 0) cout << "black" << endl; else cout << "white" << endl; } return 0; }