Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int dx[7] = {1,1,0,0,1,1,0};
int dy[7] = {0,1,1,0,0,1,1};
int dz[7] = {0,0,0,1,1,1,1};
int n,m,p;
int data[8][8][8];
int high[8][8];
int bnum,wnum;
void bpush(int x,int y,int col){
	data[x-1][y-1][high[x-1][y-1]] = col;
	high[x-1][y-1]++;
}

bool inrange(int x,int y,int z){
	return (x>-1&&y>-1&&z>-1&&x<n&&y<n&&z<n);
}
bool subcheck(int x,int y,int z,int col,int num,int d){
	if(num==1){???
		return true;
	}else{
		int nx = x+dx[d]; int ny = y+dy[d]; int nz = z+dz[d];
		if(!inrange(nx,ny,nz)) return false;
		if(data[nx][ny][nz]==col) return subcheck(nx,ny,nz,col,num-1,d);
		else return false;
	}
	return true;//dummy
}
void dprint(){
	cout << "----------" << endl;
	REP(i,n){
		REP(j,n){
			REP(k,n){
				if(data[j][k][i]==2) cout << "B ";
				else if(data[j][k][i]==1) cout <<"W ";
				else if(data[j][k][i]==0) cout <<  "X ";
 			}
 			cout << endl;
		}
		cout << endl;
	}
}
void check(){
	REP(i,n){REP(j,n){REP(k,n){
		REP(l,7) if(data[i][j][k]==2) bnum+=subcheck(i,j,k,2,m,l);
	}}}
	REP(i,n){REP(j,n){REP(k,n){
		REP(l,7) if(data[i][j][k]==1) wnum+=subcheck(i,j,k,1,m,l);
	}}}
}
int main(){
	while(1){
		cin >> n >> m >> p;
		if(n==0&&m==0&&p==0) break;
		bnum = 0; wnum = 0;
		REP(i,8){
			REP(j,8){
				REP(k,8) data[i][j][k] = 0;
				high[i][j] = 0;
			}
		}
		bool endflg = false;
		REP(i,p){
			int x,y;
			cin >> x >> y;
			if(i%2==0) bpush(x,y,2);//black
			else bpush(x,y,1);//white

			check();
			//dprint();
			if(!endflg){
				if(bnum!=wnum) endflg = true;
				if(bnum<wnum) cout << "White " << i+1 << endl;
				else if(bnum>wnum) cout << "Black " << i+1 << endl;
			}
		}
		if(!endflg) cout << "Draw" << endl;
 	}
 }

Compiler output:
a.cc: In function 'void bpush(int, int, int)':
a.cc:36:9: error: reference to 'data' is ambiguous
   36 |         data[x-1][y-1][high[x-1][y-1]] = col;
      |         ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:32:5: note:                 'int data [8][8][8]'
   32 | int data[8][8][8];
      |     ^~~~
a.cc: In function 'bool subcheck(int, int, int, int, int, int)':
a.cc:44:20: error: expected primary-expression before '?' token
   44 |         if(num==1){???
      |                    ^
a.cc:44:21: error: expected primary-expression before '?' token
   44 |         if(num==1){???
      |                     ^
a.cc:44:22: error: expected primary-expression before '?' token
   44 |         if(num==1){???
      |                      ^
a.cc:45:17: error: expected primary-expression before 'return'
   45 |                 return true;
      |                 ^~~~~~
a.cc:44:23: error: expected ':' before 'return'
   44 |         if(num==1){???
      |                       ^
      |                       :
   45 |                 return true;
      |                 ~~~~~~ 
a.cc:45:17: error: expected primary-expression before 'return'
   45 |                 return true;
      |                 ^~~~~~
a.cc:44:23: error: expected ':' before 'return'
   44 |         if(num==1){???
      |                       ^
      |                       :
   45 |                 return true;
      |                 ~~~~~~ 
a.cc:45:17: error: expected primary-expression before 'return'
   45 |                 return true;
      |                 ^~~~~~
a.cc:44:23: error: expected ':' before 'return'
   44 |         if(num==1){???
      |                       ^
      |                       :
   45 |                 return true;
      |                 ~~~~~~ 
a.cc:45:17: error: expected primary-expression before 'return'
   45 |                 return true;
      |                 ^~~~~~
a.cc:49:20: error: reference to 'data' is ambiguous
   49 |                 if(data[nx][ny][nz]==col) return subcheck(nx,ny,nz,col,num-1,d);
      |                    ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:32:5: note:                 'int data [8][8][8]'
   32 | int data[8][8][8];
      |     ^~~~
a.cc: In function 'void dprint()':
a.cc:59:36: error: reference to 'data' is ambiguous
   59 |                                 if(data[j][k][i]==2) cout << "B ";
      |                                    ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:32:5: note:                 'int data [8][8][8]'
   32 | int data[8][8][8];
      |     ^~~~
a.cc:60:41: error: reference to 'data' is ambiguous
   60 |                                 else if(data[j][k][i]==1) cout <<"W ";
      |                                         ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:32:5: note:                 'int data [8][8][8]'
   32 | int data[8][8][8];
      |     ^~~~
a.cc:61:41: error: reference to 'data' is ambiguous
   61 |                                 else if(data[j][k][i]==0) cout <<  "X ";
      |                                         ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:32:5: note:                 'int data [8][8][8]'
   32 | int data[8][8][8];
      |     ^~~~
a.cc: In function 'void check()':
a.cc:70:29: error: reference to 'data' is ambiguous
   70 |                 REP(l,7) if(data[i][j][k]==2) bnum+=subcheck(i,j,k,2,m,l);
      |                             ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:32:5: note:                 'int data [8][8][8]'
   32 | int data[8][8][8];
      |     ^~~~
a.cc:73:29: error: reference to 'data' is ambiguous
   73 |                 REP(l,7) if(data[i][j][k]==1) wnum+=subcheck(i,j,k,1,m,l);
      |                             ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<cla