#include <stdio.h>
#include <map>
using namespace std;

int N, K[2],p[2][200010];
map<pair<int, int>, int> chk;

int find(int *p, int x)
{
	if (p[x] != x) p[x] = find(p, p[x]);
	return p[x];
}

int main()
{
	scanf("%d", &N);
	scanf("%d %d", &K[0], &K[1]);
	for (int k = 0; k < 2; k++){
		int M = K[k];
		for (int i = 0; i < N; i++) p[k][i] = i;
		for (int i = 0; i < M; i++){
			int x, y; scanf("%d %d", &x, &y); x--; y--;
			p[k][find(p[k], x)] = find(p[k], y);
		}
	}

	for (int i = 0; i < N; i++) chk[{find(p[0], i), find(p[1], i)}]++;
	for (int i = 0; i < N; i++) printf("%d ", chk[{find(p[0], i), find(p[1], i)}]);
	puts("");

	return 0;
}