#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define ll long long
using namespace std;

const int maxn = 200010;
int n, m1, m2, u, v;
int f1[maxn], f2[maxn], vis[maxn], cnt[maxn], res[maxn];
vector <int> G[maxn];

int Find1 (int x) {
	if (f1[x] == x) return x;
	return f1[x] = Find1(f1[x]);
}

int Find2 (int x) {
	if (f2[x] == x) return x;
	return f2[x] = Find2(f2[x]);
}

int main () {
	scanf ("%d%d%d", &n, &m1, &m2);
	for (int i = 1; i <= n; i++) f1[i]= f2[i] = i;
	for (int i = 0; i < m1; i++) {
        scanf ("%d%d", &u, &v);
        f1[Find1(u)] = Find1(v);
	}
	for (int i = 0; i < m2; i++) {
        scanf ("%d%d", &u, &v);
        f2[Find2(u)] = Find2(v);
	}
    for (int i = 1; i <= n; i++) G[Find1(i)].push_back(i);
    for (int i = 1; i <= n; i++) if(G[i].size()) {
        for (int j = 0; j < G[i].size(); j++) {
            int t = Find2(G[i][j]);
            if (vis[t] != i) {
                vis[t] = i;
                cnt[t] = 0;
            }
            cnt[t]++;
        }
        for (int j = 0; j < G[i].size(); j++) {
            int t = Find2(G[i][j]);
            res[G[i][j]] = cnt[t];
        }
    }
    for (int i = 1; i <= n; i++) printf("%d%c", res[i], i==n?'\n':' ');
	return 0;
}
