#include <cstdio>
#include <iostream>
#include <algorithm>
#define N 100007
using namespace std;
int n,k,l,p,q,r,s,f1[N],f2[N],a[N],cnt[N],ans[N];
int find1(int x){return f1[x]==x ? x:f1[x]=find1(f1[x]);}
int find2(int x){return f2[x]==x ? x:f2[x]=find2(f2[x]);}
bool cmp(int x,int y){return f1[x]<f1[y];}
int main(){
	scanf("%d%d%d",&n,&k,&l);
	for(int i=1;i<=n;++i)f1[i]=f2[i]=i;
	for(int i=1;i<=k;++i){
		scanf("%d%d",&p,&q);
		f1[find1(p)]=find1(q);
	}
	for(int i=1;i<=l;++i){
		scanf("%d%d",&r,&s);
		f2[find2(r)]=find2(s);
	}
	for(int i=1;i<=n;++i)f1[i]=find1(i),f2[i]=find2(i);
	for(int i=1;i<=n;++i)a[i]=i;
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;++i){
		int j=i;
		while(f1[a[j+1]]==f1[a[j]])++j;
		for(int t=i;t<=j;++t)++cnt[f2[a[t]]];
		for(int t=i;t<=j;++t)ans[a[t]]=cnt[f2[a[t]]];
		for(int t=i;t<=j;++t)--cnt[f2[a[t]]];
		i=j;
	}
	for(int i=1;i<=n;++i)printf("%d ",ans[i]);
}