// Slower C++ solution:
#include <algorithm>

#include <assert.h>

#include <bitset>

#include <cstdio>

#include <cstring>

#include <iostream>

#include <map>

#include <queue>

#include <set>

#include <vector>

#define MP make_pair

#define ls (o << 1)

#define rs (o << 1 | 1)

#define mid ((L + R) >> 1)

#define eps (1e-5)

using namespace std;

typedef long long LL;

const LL mod = 1e9 + 7;

typedef pair<int, int> PII;

int n, k, l;

int f[200010], g[200010], h[200010], ans[200010];

int findfa(int *w, int o) {

    if (w[o] == o)

        return o;

    return w[o] = findfa(w, w[o]);

}

bool cmp(const int &o, const int &p) {

    int fa = findfa(f, o);

    int fb = findfa(f, p);

    if (fa != fb)

        return fa < fb;

    fa = findfa(h, o);

    fb = findfa(h, p);

    return fa < fb;

}

int main() {

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

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

        f[i] = i;

        g[i] = i;

        h[i] = i;

    }

    for (int i = 0; i < k; ++i) {

        int u, v;

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

        int fa = findfa(f, u);

        int fb = findfa(f, v);

        f[fa] = fb;

    }

    for (int i = 0; i < l; ++i) {

        int u, v;

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

        int fa = findfa(h, u);

        int fb = findfa(h, v);

        h[fa] = fb;

    }

    sort(g + 1, g + n + 1, cmp);

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

        int j = i;

        while (j <= n && findfa(f, g[i]) == findfa(f, g[j]) &&

               findfa(h, g[i]) == findfa(h, g[j])) {

            j++;

        }

        for (int k = i; k < j; ++k) {

            ans[g[k]] = j - i;

        }

        i = j;

    }

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

        printf("%d%c", ans[i], i == n ? '\n' : ' ');

    }

    return 0;

}

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

#include<string.h>

#include<set>

#include<stdlib.h>

#include<algorithm>

using namespace std;

int n,m1,m2;

int a1[400005],a2[400005];

int f1(int i){

	if(i==a1[i])return i;

	return a1[i]=f1(a1[i]);

}

int f2(int i){

	if(i==a2[i])return i;

	return a2[i]=f2(a2[i]);

}



long long line[1400005],g[400005],h[4000005],num;

int find(long long k){

	int i=1,mid,j=num;

	while(j-i>1){

		mid=(i+j)/2;

		if(k>line[mid])

		     i=mid;

		else j=mid;

		

	}

	if(line[i]==k)return h[i];

	return h[j];

	

}

int main(){

	

	scanf("%d%d%d",&n,&m1,&m2);

	for(int q=1;q<=n;q++)a1[q]=a2[q]=q;

	for(int q=1;q<=m1;q++){

		int i,j;

		scanf("%d%d",&i,&j);

		a1[f1(i)]=f1(j);

		

	}

	for(int q=1;q<=m2;q++){

		int i,j;

		scanf("%d%d",&i,&j);

		a2[f2(i)]=f2(j);

		

	}

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

		int i1=f1(q),i2=f2(q);

		long long ppp=i1;

		ppp=ppp*1000000+i2;

		g[q]=ppp;

		

	}

	sort(g+1,g+1+n);

	

	for(int q=1;q<=n;){

		

		line[++num]=g[q];

		int z=1;

		q++;

		while(g[q]==g[q-1]){

			q++;z++;

		}

		h[num]=z;

		if(q>n)break;

	}

	

	

	for(int q=1;q<=1;q++){

		int i1=f1(q),i2=f2(q);

		long long ppp=i1;

		ppp=ppp*1000000+i2;

		int ans=find(ppp);

		printf("%d",ans);

		

	}

	for(int q=2;q<=n;q++){

		int i1=f1(q),i2=f2(q);

		long long ppp=i1;

		ppp=ppp*1000000+i2;

		int ans=find(ppp);

		printf(" %d",ans);

		

	}

	printf("\n");

	

	return 0;

}