#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
bool vis[N][N];
int n, m, k;
int main() {
  memset(vis, 0, sizeof vis);
  scanf("%d%d%d", &n, &m, &k);
  int ans = -1, x, y;
  for (int t = 0; t < k; t++) {
    scanf("%d%d", &x, &y);
    vis[x][y] = 1;
    if (ans != -1) continue;
    for (int i = x - 1; i <= x; i++)
      for (int j = y - 1; j <= y; j++)
        if (vis[i][j] && vis[i + 1][j] && vis[i][j + 1] && vis[i + 1][j + 1])
          ans = t;
  }
  printf("%d\n", ans + 1);
  return 0;
}
