#include <bits/stdc++.h>
using namespace std;
bool check(vector<vector<bool> >& a, int i, int j) {
  if (a[i + 1][j])
    return a[i][j - 1] && a[i + 1][j - 1] || a[i][j + 1] && a[i + 1][j + 1];
  if (a[i - 1][j])
    return a[i][j - 1] && a[i - 1][j - 1] || a[i][j + 1] && a[i - 1][j + 1];
  return false;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<vector<bool> > a(n + 2, vector<bool>(m + 2, false));
  int p = 0;
  while (p < k) {
    int i, j;
    cin >> i >> j;
    a[i][j] = true;
    if (check(a, i, j)) {
      break;
    }
    p++;
  }
  if (p == k)
    cout << 0;
  else
    cout << p + 1;
  return 0;
}
