#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(); REP(i,l){ auto [from,to,cap,flow]=edges[i]; if(flow)g.add_edge(from,to); else g.add_edge(to,from); } auto A=g.scc(); dsu uf(n+m); 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))cout<<"Yes\n"; else cout<<"No\n"; } }