#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, n, m, k, a, b, step = 0, ans = 0;
  cin >> n >> m >> k;
  bool colour[n + 1][m + 1];
  for (i = 0; i <= n; ++i)
    for (j = 0; j <= m; ++j) colour[i][j] = false;
  while (k--) {
    ++step;
    cin >> a >> b;
    colour[a][b] = true;
    if (!ans && ((a < n && b < m && colour[a + 1][b] && colour[a][b + 1] &&
                  colour[a + 1][b + 1]) ||
                 (a < n && b - 1 > 0 && colour[a + 1][b] &&
                  colour[a + 1][b - 1] && colour[a][b - 1]) ||
                 (a - 1 > 0 && b < m && colour[a - 1][b] &&
                  colour[a - 1][b + 1] && colour[a][b + 1]) ||
                 (a - 1 > 0 && b - 1 > 0 && colour[a][b - 1] &&
                  colour[a - 1][b - 1] && colour[a - 1][b]))) {
      ans = step;
    }
  }
  cout << ans << endl;
  return 0;
}
