#include<bits/stdc++.h> using namespace std; const int maxn=1e6+5; int P[maxn]; int s,m,n; int u,v; int i; void init(){ for(i=1;i<=s;++i) P[i]=i; } int find(int x) { int son,tmp; son=x; while(x!=P[x]){ x=P[x]; } while(son!=x){ tmp=P[son]; P[son]=x; son=tmp; } return x; } void join(int x,int y) { int fx=find(x),fy=find(y); if(fx!=fy){ P[fx]=fy; } } int main() { ios::sync_with_stdio(false);cin.tie(0); cin>>s>>m>>n; init(); while(m--){ cin>>u>>v; join(u,v); } while(n--){ cin>>u>>v; if(find(u)!=find(v))cout<<"0\n"; else cout<<"1\n"; } return 0; }