func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m, k, x, y, a, b, d[2010][2010], v[2010][2010];   bool solve(int x, int y, int k) {     int l = max(1, x - k), r = min(x + k, n), t;     for (int i = l; i < r + 1; i++) {       t = k - abs(i - x);       if (y - t > 0 && !v[i][y - t]) return a = i, b = y - t, 1;       if (y + t <= m && !v[i][y + t]) return a = i, b = y + t, 1;     }     return 0;   }   int main() {     cin >> n >> m >> k;     for (int t = 0; t < k; t++) {       cin >> x >> y;       for (int i = -2; i < 3; i++)         for (int j = -2; j < 3; j++) {           if (x + i < 1 || x + i > n || y + j < 1 || y + j > m) continue;           d[x][y] = max(d[x][y], d[x + i][y + j] - abs(i) - abs(j));         }       while (!solve(x, y, d[x][y])) d[x][y]++;       cout << a <<     << b << endl;       v[a][b] = 1;     }   }   