Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int64;


int height[7][7];
int field[7][7][7];
int n, m;
bool IsEnd(bool color) {
  static const int dx[] = { 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1};
  static const int dy[] = { 0, 1, 0, 1,-1, 0, 0, 1, 1, 1, 1,-1,-1};
  static const int dz[] = { 0, 0, 1, 0, 0, 1,-1, 1,-1, 1,-1, 1,-1};
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      for(int k = 0; k < n; k++) {
        for(int l = 0; l < 13; l++) {
          int x = i, y = j, z = k;
          int cnt = 0;
          while(0 <= x && x < n && 0 <= y && y < n && 0 <= z && z < n && field[y][x][z] == color) {
            x += dx[l];
            y += dy[l];
            z += dz[l];
            ++cnt;
          }
          if(cnt >= m) return(true);
        }
      }
    }
  }
  return(false);
}

int main() {
  int p;
  int x[7 * 7 * 7], y[7 * 7 * 7];

  while(cin >> n >> m >> p, n){ 
    fill_n(**height, 7 * 7, 0);
    fill_n(*field, 7 * 7 * 7, -1);
    for(int i = 0; i < p; i++) {
      cin >> x[i] >> y[i];
      --x[i], --y[i];
    }
    bool color = false;
    bool printed = false;
    for(int i = 0; i < p; i++, color = !color) {
      field[y[i]][x[i]][height[y[i]][x[i]]] = color;
      ++height[y[i]][x[i]];
      if(IsEnd(color)) {
        printed = true;
        cout << (color ? "White " : "Black ") << i + 1 << endl;
        break;
      }
    }
    if(!printed) cout << "Draw" << endl;
  }
}

Compiler output:
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of '_OI std::fill_n(_OI, _Size, const _Tp&) [with _OI = int; _Size = int; _Tp = int]':
a.cc:38:11:   required from here
   38 |     fill_n(**height, 7 * 7, 0);
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1184:56: error: no matching function for call to '__iterator_category(int&)'
 1184 |                                std::__iterator_category(__first));
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:65:
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: note: candidate: 'template<class _Iter> constexpr typename std::iterator_traits< <template-parameter-1-1> >::iterator_category std::__iterator_category(const _Iter&)'
  239 |     __iterator_category(const _Iter&)
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_iterator_base_types.h: In substitution of 'template<class _Iter> constexpr typename std::iterator_traits< <template-parameter-1-1> >::iterator_category std::__iterator_category(const _Iter&) [with _Iter = int]':
/usr/include/c++/14/bits/stl_algobase.h:1184:35:   required from '_OI std::fill_n(_OI, _Size, const _Tp&) [with _OI = int; _Size = int; _Tp = int]'
 1184 |                                std::__iterator_category(__first));
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
a.cc:38:11:   required from here
   38 |     fill_n(**height, 7 * 7, 0);
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: error: no type named 'iterator_category' in 'struct std::iterator_traits<int>'
  239 |     __iterator_category(const _Iter&)
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int (*)[7]; _Tp = int; typename __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type = void]':
/usr/include/c++/14/bits/stl_algobase.h:998:21:   required from 'void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = int (*)[7]; _Tp = int]'
  998 |     { std::__fill_a1(__first, __last, __value); }
      |       ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1154:20:   required from '_OutputIterator std::__fill_n_a(_OutputIterator, _Size, const _Tp&, random_access_iterator_tag) [with _OutputIterator = int (*)[7]; _Size = int; _Tp = int]'
 1154 |       std::__fill_a(__first, __first + __n, __value);
      |       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1183:29:   required from '_OI std::fill_n(_OI, _Size, const _Tp&) [with _OI = int (*)[7]; _Size = int; _Tp = int]'
 1183 |       return std::__fill_n_a(__first, std::__size_to_integer(__n), __value,
      |              ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1184 |                                std::__iterator_category(__first));
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:39:11:   required from here
   39 |     fill_n(*field, 7 * 7 * 7, -1);
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:952:18: error: incompatible types in assignment of 'const int' to 'int [7]'
  952 |         *__first = __tmp;
      |         ~~~~~~~~~^~~~~~~