#include #include #include #include #include using namespace std; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(n); i++) int H,W,N; vector solve(vector> P){ vector ans; vector> E(W); vector> D(H); rep(i,N){ auto p = P[i]; E[p.second].push_back(i); D[p.first].push_back(i); } rep(x,H){ vector YI; for(auto i : D[x]){ int y = P[i].second; if(E[y].size() >= 2) YI.push_back(i); } if(YI.size() < 2) continue; ans.resize(4); ans[1] = YI[0]; ans[2] = YI[1]; for(int e : E[P[YI[0]].second]) if(e != YI[0]) ans[0] = e; for(int e : E[P[YI[1]].second]) if(e != YI[1]) ans[3] = e; return ans; } return ans; } int main() { cin >> H >> W >> N; vector> P(N); rep(i,N){ int y,x; cin >> y >> x; y--; x--; P[i] = {y,x}; } vector ans; //rep(t,2){ //rep(i,N) swap(P[i].first,P[i].second); //swap(H,W); ans = solve(P); //if(!ans.empty()) break; //} if(ans.empty()){ cout << "-1\n"; } else{ cout << "4\n"; rep(i,4){ if(i) cout << " "; cout << (ans[i]+1); } cout << "\n"; } return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_instance;