#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

typedef pair<int, int> pii;
#define mp make_pair

const int N = 200200;
int n;
vector<int> g[N];
int col[2][N];
int m, k;
int C;

map<pii, int> a;

void dfs(int v, int it)
{
	col[it][v] = C;
	for (int u : g[v])
		if (col[it][u] == -1)
			dfs(u, it);
	return;
}

int main()
{
	scanf("%d%d%d", &n, &m, &k);
	for (int it = 0; it < 2; it++)
	{
		for (int i = 0; i < n; i++)
			g[i].clear();
		for (int i = 0; i < n; i++)
			col[it][i] = -1;
		C = 0;
		while(m--)
		{
			int v, u;
			scanf("%d%d", &v, &u);
			v--;u--;
			g[v].push_back(u);
			g[u].push_back(v);
		}
		for (int v = 0; v < n; v++)
			if (col[it][v] == -1)
			{
				dfs(v, it);
				C++;
			}
		swap(m, k);
	}
	for (int i = 0; i < n; i++)
		a[mp(col[0][i], col[1][i])]++;
	for (int i = 0; i < n; i++)
		printf("%d ", a[mp(col[0][i], col[1][i])]);

	return 0;
}