// Slower C++ solution:
//#include <bits/stdc++.h>

#include <stdio.h>

#include <iostream>

#include <string.h>

#include <math.h>

#include <stdlib.h>

#include <limits.h>

#include <algorithm>

#include <queue>

#include <vector>

#include <set>

#include <map>

#include <stack>

#include <bitset>

#include <string>

#include <time.h>

using namespace std;

long double esp=1e-11;

//#pragma comment(linker, "/STACK:1024000000,1024000000")

#define fi first

#define se second

#define all(a) (a).begin(),(a).end()

#define cle(a) while(!a.empty())a.pop()

#define mem(p,c) memset(p,c,sizeof(p))

#define mp(A, B) make_pair(A, B)

#define pb push_back

#define lson l , m , rt << 1

#define rson m + 1 , r , rt << 1 | 1

typedef long long int LL;

const long double PI = acos((long double)-1);

const LL INF=0x3f3f3f3f3f3f3f3fll;

const int MOD =1000000007ll;

const int maxn=210100;

int ro1[maxn];

int up1(int u){return(ro1[u]==u)?u:ro1[u]=up1(ro1[u]);}

int ro2[maxn];

int up2(int u){return(ro2[u]==u)?u:ro2[u]=up2(ro2[u]);}

vector<pair<int,int> >node[maxn];

int c[maxn][2];

int ans[maxn];

int main()

{

    //freopen("in9.txt", "r", stdin);

    //freopen("in9.txt", "r", stdin);

    //freopen("out9.txt", "w", stdout);

    //::iterator iter;                  %I64d

    //for(int x=1;x<=n;x++)

    //for(int y=1;y<=n;y++)

    //scanf("%d",&a);

    //printf("%d\n",ans);

    int n,k,l;

    scanf("%d%d%d",&n,&k,&l);

    for(int x=1;x<=n;x++)ro1[x]=ro2[x]=x,node[x].clear();

    for(int x=1;x<=k;x++)

    {

        int u,v;

        scanf("%d%d",&u,&v);

        ro1[up1(u)]=up1(v);

    }

    for(int x=1;x<=n;x++)

        node[up1(x)].pb(mp(x,0));

    for(int x=1;x<=l;x++)

    {

        int u,v;

        scanf("%d%d",&u,&v);

        ro2[up2(u)]=up2(v);

    }

    mem(ans,0);

    mem(c,0);

    for(int x=1;x<=n;x++)

    {

    	for(int y=0;y<node[x].size();y++)

		{

			node[x][y].se=up2(node[x][y].fi);

			if(c[node[x][y].se][1]!=x)

			{

				c[node[x][y].se][1]=x;

				c[node[x][y].se][0]=0;

			}

			c[node[x][y].se][0]++;

		}

		for(int y=0;y<node[x].size();y++)

			ans[node[x][y].fi]=c[node[x][y].se][0];

    }

    for(int x=1;x<=n;x++)

        printf("%d%c",ans[x]," \n"[x==n]);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.4856859070793154x):
#include <bits/stdc++.h>

using namespace std;



#define X first

#define Y second

#define LL long long

#define ULL unsigned long long

#define PB push_back

#define MP make_pair

#define VI vector<int>

#define PII pair<int,int>

#define IOS ios::sync_with_stdio(0);cin.tie(0);

#define IN freopen("in", "r", stdin);

#define OUT freopen("out", "w", stdout);



const int maxn=200010;



int fa1[maxn],fa2[maxn];

int ans[maxn];

VI v[maxn];



int find1(int x)

{

	if (fa1[x]!=x) fa1[x]=find1(fa1[x]);

	return fa1[x];

}



int find2(int x)

{

	if (fa2[x]!=x) fa2[x]=find2(fa2[x]);

	return fa2[x];

}



bool cmp(int a,int b)

{

	return find1(a)<find1(b);

}



int main()

{

	IOS;

	int n,m1,m2;

	cin>>n>>m1>>m2;

	for (int j=1;j<=n;++j)

	{

		fa1[j]=j;

		fa2[j]=j;

	}

	for (int j=1;j<=m1;++j)

	{

		int x,y;

		cin>>x>>y;

		int fx=find1(x);

		int fy=find1(y);

		if (fx!=fy) fa1[fx]=fy;

	}

	for (int j=1;j<=m2;++j)

	{

		int x,y;

		cin>>x>>y;

		int fx=find2(x);

		int fy=find2(y);

		if (fx!=fy) fa2[fx]=fy;

	}

	for (int j=1;j<=n;++j)

	{

		int fj=find2(j);

		v[fj].PB(j);

	}

	for (int j=1;j<=n;++j)

	{

		if (find2(j)!=j) continue;

		sort(v[j].begin(),v[j].end(),cmp);

		for (int k=0;k<v[j].size();++k)

		{

			int p=k;

			while (p<v[j].size()-1&&find1(v[j][p+1])==find1(v[j][k])) ++p;

			int add=p-k+1;

			for (int l=k;l<=p;++l)

				ans[v[j][l]]+=add;

			k=p;

		}

	}

	for (int j=1;j<=n;++j)

		cout<<ans[j]<<" ";

	cout<<endl;

	return 0;

}