#pragma GCC optimize("Ofast") #include using namespace std; #include using namespace atcoder; #define REP(i,n) for(int i=0;i<(n);i++) #define RREP(i,n) for(int i=(n-1);i>=0;i--) #define ALL(v) v.begin(),v.end() int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n,m,l;cin>>n>>m>>l; mf_graph fl(n+m+2); int S=n+m,T=n+m+1; REP(_,l){ int s,t;cin>>s>>t;s--;t--; fl.add_edge(s,n+t,1); } REP(i,n)fl.add_edge(S,i,1); REP(j,m)fl.add_edge(n+j,T,1); fl.flow(S,T); scc_graph g(n+m); auto edges=fl.edges(); dsu uf(n+m),uf2(n+m+2); REP(i,l){ auto [from,to,cap,flow]=edges[i]; if(flow)g.add_edge(from,to); else g.add_edge(to,from); uf2.merge(from,to); } auto A=g.scc(); REP(i,n){ auto [from,to,cap,flow]=edges[l+i]; if(flow)uf2.merge(n+m,to); else uf2.merge(n+m+1,to); } REP(j,m){ auto [from,to,cap,flow]=edges[l+n+j]; if(flow)uf2.merge(n+m,from); else uf2.merge(n+m+1,from); } for(auto v:A)for(int p:v)uf.merge(v[0],p); REP(i,l){ auto [from,to,cap,flow]=edges[i]; if(flow||uf.same(from,to)||uf2.same(from,n+m)||uf2.same(to,n+m))cout<<"Yes\n"; else cout<<"No\n"; } }