#include <bits/stdc++.h>
using namespace std;
const int lx = 3e5 + 123;
const long long int mod = 1e9 + 7;
void solve() {
  int n, m, k, i = 0, j, l, x, y;
  cin >> n >> m >> k;
  int a[n + 5][m + 5];
  memset(a, 0, sizeof(a));
  for (l = 1; l <= k; l++) {
    j = 0;
    cin >> x >> y;
    a[x][y] = 1;
    if (a[x - 1][y] && a[x - 1][y + 1] && a[x][y + 1]) j++;
    if (a[x + 1][y] && a[x + 1][y + 1] && a[x][y + 1]) j++;
    if (a[x - 1][y] && a[x - 1][y - 1] && a[x][y - 1]) j++;
    if (a[x + 1][y] && a[x + 1][y - 1] && a[x][y - 1]) j++;
    if (j && !i) i = l;
  }
  cout << i << "\n";
}
void init_code() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
