#include "vision.h"
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;
const int N = 40010;
int h, w, k;
int n;
int get_n(int x, int y) { return 0 <= x && x < h && 0 <= y && y < w? x*w + y: -1;}
vector<int> nbr[N];
void construct_network(int H, int W, int K)
{
h = H; w = W; k = K;
n = w*h;
Loop (i,0,h) Loop (j,0,w) {
Loop (c,0,k) {
int x, y;
x = i+k; y = j;
x -= c; y += c;
if (get_n(x, y) >= 0)
nbr[get_n(i, j)].push_back(get_n(x, y));
x = i; y = j+k;
x -= c; y -= c;
if (get_n(x, y) >= 0)
nbr[get_n(i, j)].push_back(get_n(x, y));
x = i-k; y = j;
x += c; y -= c;
if (get_n(x, y) >= 0)
nbr[get_n(i, j)].push_back(get_n(x, y));
x = i; y = j-k;
x += c; y += c;
if (get_n(x, y) >= 0)
nbr[get_n(i, j)].push_back(get_n(x, y));
}
}
//Loop (i,0,n) {
// cout << i << ": ";
// for (int x : nbr[i])
// cout << x << ' ';
// cout << '\n';
//}
Loop (i,0,n)
nbr[i].size()? add_or(nbr[i]): add_not(i);
Loop (i,0,n)
add_and({i, n+i});
vector<int> kooft(n);
iota(kooft.begin(), kooft.end(), 2*n);
add_or(kooft);
}