#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
using namespace std;

#define ll long long

#define debug_message 0
#define debug if (debug_message)

#define sz(x) (int)x.size()

struct parent{
	int p1,p2;
	bool operator<(parent a2) const{
		return (p1<a2.p1 || (p1==a2.p1 && p2<a2.p2));
	}
};

int i,t,j;
int n,k,l,nt,p1[200005],p2[200005],v1,v2;
string s,s1,s2;

map<parent,int> mp;

int dsu1(int x){
	if (x==p1[x]) return x;
	else return (p1[x]=dsu1(p1[x]));
}

int dsu2(int x){
	if (x==p2[x]) return x;
	else return (p2[x]=dsu2(p2[x]));
}

int main(){
	scanf("%d%d%d",&n,&k,&l);
	
	for (i=1; i<=n; ++i) p1[i]=p2[i]=i;
	
	for (i=1; i<=k; ++i){
		scanf("%d%d",&v1,&v2);
		p1[dsu1(p1[v1])]=dsu1(p1[v2]);
	}
	
	for (i=1; i<=l; ++i){
		scanf("%d%d",&v1,&v2);
		p2[dsu2(p2[v1])]=dsu2(p2[v2]);
	}
	
	for (i=1; i<=n; ++i){
		++mp[(parent){dsu1(p1[i]),dsu2(p2[i])}];
	}
	
	for (i=1; i<=n; ++i) {
		printf("%d%c",mp[(parent){dsu1(p1[i]),dsu2(p2[i])}],i==n?'\n':' ');
	}
	
	return 0;
}
/*

*/