#include using namespace std; #include using namespace atcoder; using ll=long long; #define MOD 998244353 using Graph=vector>>; #define INF 1000000000 #define MAX 200000 vector ans; bool dfs(Graph &G,int v,int p,vector &seen,int &g){ seen[v]=1; for(auto e:G[v]){ int nv=e.first; if(nv==p){ continue; } if(seen[nv]==1){ g=nv; ans.push_back(e.second); return true; }else{ if(dfs(G,nv,v,seen,g)){ if(g!=-1){ ans.push_back(e.second); if(g==v){ g=-1; } } return true; } } } return false; } int main(){ int H,W,N; cin>>H>>W>>N; vector x(N),y(N); Graph G(H+W); for(int i=0;i>x[i]>>y[i]; x[i]--;y[i]--; G[x[i]].push_back(make_pair(H+y[i],i)); G[H+y[i]].push_back(make_pair(x[i],i)); } vector seen(H+W,0); for(int i=0;i