#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <set>
#define maxn 200005
using namespace std;
int size[maxn];
int n,k,l;
struct Edge{
		int from,to;
		Edge(int from,int to):from(from),to(to){}
};
int fa1[maxn];
int find1(int x){
		if(x == fa1[x]) return x;
		return fa1[x] = find1(fa1[x]);
}

int fa2[maxn];
int find2(int x){
		if(x == fa2[x]) return x;
		return fa2[x] = find2(fa2[x]);
}
int main(){
		//freopen("main.in","r",stdin);
		cin >> n >> k >> l;
		for(int i = 1; i <= n; i++) fa1[i] = i;
		for(int i = 1; i <= k; i++){
				int x,y; cin >> x >> y;
				int f1 = find1(x);
				int f2 = find1(y);
				if(f1 != f2){
						fa1[f1] = f2;
				}
		}
		for(int i = 1; i <= n; i++) {fa2[i] = i;size[i] = 1;}
		for(int i = 1; i <= l; i++){
				int x,y; cin >> x >> y;
				int ff1 = find1(x);
				int ff2 = find1(y);
				int f1 = find2(x);
				int f2 = find2(y);
				if(f1 != f2 && ff1 == ff2){
						fa2[f1] = f2;
						size[f2] += size[f1];
				}
		}
		for(int i = 1; i <= n; i++){
				int x = find2(i);
				cout << size[x] << " ";
		}
		cout << endl;
		return 0;
}