#include <bits/stdc++.h>
using namespace std;
int main() {
  long int k, p = 0, i;
  int n, m, j, r, c1, x, y, flag = 0;
  cin >> n >> m >> k;
  long int a[n + 1][m + 1], b[k + 1], c[k + 1];
  for (i = 1; i <= k; i++) {
    cin >> b[i] >> c[i];
  }
  for (r = 1; r <= n; r++) {
    for (c1 = 1; c1 <= m; c1++) {
      a[r][c1] = 0;
    }
  }
  for (i = 1; i <= k; i++) {
    x = b[i];
    y = c[i];
    a[x][y] = 1;
    if (x != 1 && y != m && a[x][y + 1] == 1 && a[x - 1][y] == 1 &&
        a[x - 1][y + 1] == 1) {
      flag = 1;
      p = i;
      break;
    } else if (x != 1 && y != 1 && a[x][y - 1] == 1 && a[x - 1][y] == 1 &&
               a[x - 1][y - 1] == 1) {
      flag = 1;
      p = i;
      break;
    } else if (x != n && y != m && a[x][y + 1] == 1 && a[x + 1][y] == 1 &&
               a[x + 1][y + 1] == 1) {
      flag = 1;
      p = i;
      break;
    } else if (x != n && y != 1 && a[x][y - 1] == 1 && a[x + 1][y] == 1 &&
               a[x + 1][y - 1] == 1) {
      flag = 1;
      p = i;
      break;
    }
  }
  cout << p << endl;
  return 0;
}
