#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N, K, L;
vector<int> G[2][200000];

int d[2][200000];

int ans[200000];
map<P, int> m;
void bfs(int s, int c, int b){
	queue<int> q;
	q.push(s);
	d[b][s] = c;
	while(!q.empty()){
		int n = q.front(); q.pop();
		rep(i, G[b][n].size()){
			int to = G[b][n][i];
			if(d[b][to] == 0){
				d[b][to] = c;
				q.push(to);
			}
		}
	}
}
void solve(){
	rep(i, 2){
		int c = 1;
		rep(j, N){
			if(d[i][j] == 0){
				bfs(j, c, i);
				c++;
			}
		}
	}
	rep(i, N){
		m[P(d[0][i], d[1][i])]++;
	}
	rep(i, N){
		cout << m[P(d[0][i], d[1][i])] << (i == N - 1 ? '\n' : ' ');
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> K >> L;
	rep(i, K) {
		int p, q;
		cin >> p >> q;
		p--; q--;
		G[0][p].pub(q);
		G[0][q].pub(p);
	}
	rep(i, L) {
		int r, s;
		cin >> r >> s;
		r--; s--;
		G[1][r].pub(s);
		G[1][s].pub(r);
	}
	solve();
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
inline int read()
{
    register int x=0;
    register char ch=getchar();
    while(ch<'0'||ch>'9')
        ch=getchar();
    while(ch>='0'&&ch<='9')
        x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return x;
}
inline void write(int x)
{
	register char st[10];
	register int top=0;
	if(!x)
		putchar('0');
	while(x) 
		st[++top]=(x%10)+48,x/=10;
   	while(top)
		putchar(st[top--]);
	putchar('\n');
}
const int N=200001;
int f1[N],f2[N];
int find(int x,int *f)
{
	return f[x]==x? f[x]:f[x]=find(f[x],f);
}
map<pair<int,int>,int>mp;
int main()
{
	register int n=read(),k=read(),l=read(),a,b;
	for(register int i=1;i<=n;++i)
		f1[i]=f2[i]=i;
	while(k--)
		if(find(a=read(),f1)!=find(b=read(),f1))
			f1[find(a,f1)]=find(b,f1);
	while(l--)
		if(find(a=read(),f2)!=find(b=read(),f2))
			f2[find(a,f2)]=find(b,f2);
	for(register int i=1;i<=n;++i)
		find(i,f1),find(i,f2);
	for(register int i=1;i<=n;++i)
		++mp[make_pair(f1[i],f2[i])];
	for(register int i=1;i<=n;++i)
		write(mp[make_pair(f1[i],f2[i])]);
	return 0;
}