#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int n,k,l,last,ans[210000],num[210000],u,v;
struct node{
	int fa1,fa2,id;
}a[210000];
bool cmp(node a,node b)
{
	return a.fa1<b.fa1;
}
int get2(int x) 
{
	return a[x].fa2==x?x:a[x].fa2=get2(a[x].fa2);
}
void un2(int x,int y)
{
	int X=get2(x); int Y=get2(y);
	if(X!=Y) a[X].fa2=Y;
}
int get1(int x) 
{
	return a[x].fa1==x?x:a[x].fa1=get1(a[x].fa1);
}
void un1(int x,int y)
{
	int X=get1(x); int Y=get1(y);
	if(X!=Y) a[X].fa1=Y;
}
int main()
{
	scanf("%d%d%d",&n,&k,&l);
	for(int i=1;i<=n;++i) 
	{
		a[i].fa1=i;
		a[i].fa2=i;
		a[i].id=i;
	}
	for(int i=1;i<=k;++i)
	{
		scanf("%d%d",&u,&v);
		un1(u,v);
	}
	for(int i=1;i<=l;++i)
	{
		scanf("%d%d",&u,&v);
		un2(u,v);
	}
	for(int i=1;i<=n;++i) 
	{
		a[i].fa1=get1(i);
		a[i].fa2=get2(i);
	}
	sort(a+1,a+n+1,cmp);
	last=1;
	for(int i=1;i<=n;++i)
	{
		if(a[i].fa1!=a[i+1].fa1)
		{
			for(int j=last;j<=i;++j)
			{
				num[a[j].fa2]++;
			}
			for(int j=last;j<=i;++j)
			{
				ans[a[j].id]=num[a[j].fa2];
			}
			for(int j=last;j<=i;++j)
			{
				num[a[j].fa2]=0;
			}
			last=i+1;
		}
	}
	for(int i=1;i<n;++i) printf("%d ",ans[i]); printf("%d",ans[n]);
	return 0;
}