#include <bits/stdc++.h>
using namespace std;
const int MAXI = numeric_limits<int>::max() / 2;
const int MINI = numeric_limits<int>::min() / 2;
const long long MAXL = numeric_limits<long long>::max() / 2;
const long long MINL = numeric_limits<long long>::min() / 2;
static const int N = 1010;
bool a[N][N];
int n, m, dx[] = {0, 1, 1, 0}, dy[] = {0, 0, 1, 1};
bool in(int r, int c) { return 0 <= r && r < n && 0 <= c && c < m; }
bool judge(int r, int c) {
  if (!in(r, c)) return false;
  int i;
  for ((i) = (0); (i) < (4); ++(i)) {
    int x = r + dx[i], y = c + dy[i];
    if (!(in(x, y) && a[x][y])) return false;
  }
  return true;
}
bool solve(int r, int c) {
  a[r][c] = true;
  if (judge(r - 1, c - 1) || judge(r, c - 1) || judge(r - 1, c) || judge(r, c))
    return true;
  return false;
}
int main(int argc, char* argv[]) {
  int i, r, c, k;
  cin >> n >> m >> k;
  for ((i) = (0); (i) < (k); ++(i)) {
    cin >> r >> c;
    --r;
    --c;
    if (solve(r, c)) break;
  }
  cout << (i >= k ? 0 : i + 1) << endl;
  return 0;
}
