#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-8;
const double Pi = acos(-1.0);
const int N = 100005;
struct Node {
  int x, y;
} node[N];
int pic[1005][1005];
int n, m, k;
bool judge(Node a) {
  if (pic[a.x - 1][a.y] && pic[a.x - 1][a.y + 1] && pic[a.x][a.y + 1])
    return true;
  if (pic[a.x - 1][a.y] && pic[a.x][a.y - 1] && pic[a.x - 1][a.y - 1])
    return true;
  if (pic[a.x + 1][a.y] && pic[a.x][a.y + 1] && pic[a.x + 1][a.y + 1])
    return true;
  if (pic[a.x][a.y - 1] && pic[a.x + 1][a.y] && pic[a.x + 1][a.y - 1])
    return true;
  return false;
}
int main() {
  while (~scanf("%d %d %d", &n, &m, &k)) {
    memset(pic, 0, sizeof(pic));
    for (int i = 1; i <= k; i++) scanf("%d %d", &node[i].x, &node[i].y);
    int flag = 0;
    for (int i = 1; i <= k; i++) {
      pic[node[i].x][node[i].y] = 1;
      if (judge(node[i])) {
        flag = 1;
        printf("%d\n", i);
        break;
      }
    }
    if (!flag) puts("0");
  }
}
