#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[1020][1020];
  for (int i = 0; i < 1020; i++) {
    for (int j = 0; j < 1020; j++) {
      a[i][j] = '.';
    }
  }
  int n, m, k, flag = 0, x, y, counter = 0;
  cin >> n >> m >> k;
  for (int i = 0; i < k; i++) {
    cin >> x >> y;
    a[x + 5][y + 5] = '*';
    if (flag == 0) {
      if (a[x + 6][y + 5] == '*' && a[x + 6][y + 6] == '*' &&
          a[x + 5][y + 6] == '*') {
        flag = 1;
        counter = i + 1;
      } else if (a[x + 5][y + 4] == '*' && a[x + 6][y + 5] == '*' &&
                 a[x + 6][y + 4] == '*') {
        flag = 1;
        counter = i + 1;
      } else if (a[x + 5][y + 4] == '*' && a[x + 4][y + 5] == '*' &&
                 a[x + 4][y + 4] == '*') {
        flag = 1;
        counter = i + 1;
      } else if (a[x + 5][y + 6] == '*' && a[x + 4][y + 5] == '*' &&
                 a[x + 4][y + 6] == '*') {
        flag = 1;
        counter = i + 1;
      }
    }
  }
  cout << counter;
}
