#include<cstdio>
#include<algorithm>
#include<vector>
#define N 100001
using namespace std;

vector<int>g[N];
int f[N],h[N],a[N];
int ff(int u){return f[u]^u?f[u]=ff(f[u]):u;}
bool cm(int x,int y){return h[x]<h[y];}
int main(){
	int n,k,l;scanf("%d%d%d",&n,&k,&l);
	for(int i=1;i<=n;i++)f[i]=i;
	for(int i=1,u,v;i<=k;i++){
		scanf("%d%d",&u,&v);
		f[ff(u)]=ff(v);
	}
	for(int i=1;i<=n;i++)h[i]=ff(i);
	for(int i=1;i<=n;i++)f[i]=i;
	for(int i=1,u,v;i<=l;i++){
		scanf("%d%d",&u,&v);
		f[ff(u)]=ff(v);
	}
	for(int i=1;i<=n;i++)g[ff(i)].push_back(i);
	for(int i=1;i<=n;i++){
		sort(g[i].begin(),g[i].end(),cm);
		for(int j=0,r=0;j<g[i].size();j=r){
			while(r<g[i].size()&&h[g[i][j]]==h[g[i][r]])r++;
			for(int o=j;o<r;o++)a[g[i][o]]=r-j;
		}
	}
	for(int i=1;i<=n;i++)printf("%d ",a[i]);
}