#include #include #include #include #include #include #include #include #include using namespace std; ifstream fin("B.txt"); #define cin fin int table[13][3] = { {0, 0, 1}, {0, 1, 0}, {1, 0, 0}, {1, 1, 0}, {1, 0, 1}, {0, 1, 1}, {1, -1, 0}, {1, 0, -1}, {0, 1, -1}, {1, 1, 1}, {1, 1, -1}, {1, -1, 1}, {-1, 1, 1}, }; bool winner_decided(int n, int m, int bw, int field[7][7][7]) { for (int x = 0; x < n; ++x) { for (int y = 0; y < n; ++y) { for (int z = 0; z < n; ++z) { for (int i = 0; i < 13; ++i) { int j; for (j = 0; j < m; ++j) { int xx = x + table[i][0] * j; int yy = y + table[i][1] * j; int zz = z + table[i][2] * j; if (xx < 0 || n <= xx) { break; } if (yy < 0 || n <= yy) { break; } if (zz < 0 || n <= zz) { break; } if (field[xx][yy][zz] != bw) break; } if (j == m) { return true; } } } } } return false; } void solve(int n, int m, int p, const vector >& hands) { int field[7][7][7] = { 0 }; for (int i = 0; i < hands.size(); ++i) { int wb = (i % 2) ? -1 : 1; for (int k = 0; k < n; ++k) { if (field[hands[i].first][hands[i].second][k] == 0) { field[hands[i].first][hands[i].second][k] = wb; break; } } bool b = winner_decided(n, m, wb, field); if (b) { if (i % 2 == 0) { cout << "Black " << (i + 1) << endl; return; } else { cout << "White " << (i + 1) << endl; return; } } } cout << "Draw" << endl; } int main() { if(!fin) return -1; int n, m, p; while (cin >> n >> m >> p, (n || m || p)) { vector > hands; while (p--) { int x, y; cin >> x >> y; hands.push_back(make_pair(x - 1, y - 1)); } solve(n, m, p, hands); } return 0; }