#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, 0, -1, 0, -1, 1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
int main(int argc, char const* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a[1010][1010], n, m, k;
  map<pair<int, int>, int> dp;
  cin >> n >> m >> k;
  int sol = 0;
  for (int i = 0; i < k; ++i) {
    int a, b;
    cin >> a >> b;
    dp[{a, b}] = 1;
    bool f = false;
    if (dp.count({a, b + 1}) != 0 && dp.count({a + 1, b}) != 0 &&
        dp.count({a + 1, b + 1}) != 0)
      f = true;
    if (dp.count({a, b + 1}) != 0 && dp.count({a - 1, b}) != 0 &&
        dp.count({a - 1, b + 1}) != 0)
      f = true;
    if (dp.count({a - 1, b}) != 0 && dp.count({a - 1, b - 1}) != 0 &&
        dp.count({a, b - 1}) != 0)
      f = true;
    if (dp.count({a + 1, b}) != 0 && dp.count({a + 1, b - 1}) != 0 &&
        dp.count({a, b - 1}) != 0)
      f = true;
    if (f && sol == 0) sol = i + 1;
  }
  cout << sol << endl;
  return 0;
}
