// 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: 1.5386103095628343x):
#include <iostream>

#include <cstdio>

#include <cstring>

#include <cmath>

#include <algorithm>

#include <vector>

#include <queue>

#include <string>

#include <stack>

#include <map>

#include <ctime>

#include <set>

#include <bitset>

#include <ctime>

#define X first

#define Y second

#define clr(u,v); memset(u,v,sizeof(u));

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

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

#define Clear(Q); while (!Q.empty()) Q.pop();

#define pb push_back

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<char, int> pci;

const int maxn = 2e5 + 10;

const int INF = 0x3f3f3f3f;

int f[maxn];

int f2[maxn];

int f3[maxn];



int sum[maxn];

void init(int n)

{

    for (int i = 0; i < maxn; i++)

        f[i] = i, f2[i] = i, f3[i] = i, sum[i] = 1;

}

int find(int x)

{

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

}

int find2(int x)

{

    return f2[x] == x ? x : f2[x] = find2(f2[x]);

}



int find3(int x)

{

    return f3[x] == x ? x : f3[x] = find3(f3[x]);

}





void mix(int x, int y)

{

    int fx = find(x), fy = find(y);

    if (fx == fy) return ;

    f[fx] = fy;

}

void mix2(int x, int y)

{

    int fx = find2(x), fy = find2(y);

    if (fx == fy) return ;

    f2[fx] = fy;

}

void mix3(int x, int y)

{

    int fx = find3(x), fy = find3(y);

    if (fx == fy) return ;

    f3[fx] = fy;

    sum[fy] += sum[fx];

}

map <pii, int> M;



int main()

{

#ifdef LOCAL

//    in();

#endif

    int n, k, l, a, b;

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

    init(n);

    while (k--)

    {

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

        mix(a, b);

    }

    while (l--)

    {

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

        mix2(a, b);

//        else mix3(a,b);

    }

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

        M[make_pair(find(i), find2(i))]++;



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

        printf("%d ", M[make_pair(find(i), find2(i))]);

    puts("");

    return 0;

}