// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 6.471786553293302x):
#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <cmath>

#include <algorithm>

using namespace std;

#define inf (0x3f3f3f3f)

#define ls int len=s.size()

#define ls1 int len1=s1.size()

#define sd(x) scanf("%d",&x)

#define slld(x) scanf("%I64d",&x)

#define reps(i,n) for(int i=1;i<n;i++)

#define rep(i,n) for(int i=0;i<n;i++)

#define repn(i,n) for(int i=n-1;i>=0;i--)

typedef long long int LL;

typedef long long int ll;



#include <iostream>

#include <sstream>

#include <vector>

#include <set>

#include <map>

#include <queue>

#include <string>

#include<stack>

#include<ctime>

void g(int t){if(t){g((t-1)/26);putchar(65+(t-1)%26);}}



const int M=2*1e5+100;

int f[M],f1[M],r[M],r1[M];



void init(int n){

    rep(i,n){

        f[i]=i;f1[i]=i;

        r[i]=r1[i]=0;

    }

}

int find(int x){

    return f[x]==x?x:f[x]=find(f[x]);

}

int find1(int x){

    return f1[x]==x?x:f1[x]=find1(f1[x]);

}

void unite(int x,int y){

    x=find(x);y=find(y);

    if(x==y) return;



    if(r[x]<r[y]) f[x]=y;

    else{

        f[y]=x;

        if(r[x]==r[y]) r[x]++;

    }

}

void unite1(int x,int y){

    x=find1(x);y=find1(y);

    if(x==y) return;

    if(r1[x]<r1[y]) f1[x]=y;

    else{

        f1[y]=x;

        if(r1[x]==r1[y]) r1[x]++;

    }

}



map<pair<int,int>,int>mp;



int main()

{

#ifdef LOCAL

    freopen("data.h", "r", stdin);

    //freopen("1.h","w",stdout);

#endif

    int n,K,L;

    scanf("%d%d%d",&n,&K,&L);

    init(n);

    rep(i,K){

        int v,u;

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

        unite(v,u);

    }

    rep(i,L){

        int v,u;

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

        unite1(v,u);

    }

    mp.clear();

    for(int i=1;i<=n;i++){

        mp[make_pair(find(i),find1(i))]++;

    }



    for(int i=1;i<=n;i++){

        printf("%d ",mp[make_pair(find(i),find1(i))]);

    }

    cout<<endl;

}