#include <bits/stdc++.h>
using namespace std;
#define LL long long
const int maxn = 1e5+10;
int n, k, l;
map<LL, int> num;
int fa[2][maxn];
int Find (int x, int mod) {
    if (fa[mod][x] == x) return x;
    else return fa[mod][x] = Find (fa[mod][x], mod);
}
void Comb (int x, int y, int mod) {
    fa[mod][Find(x, mod)] = Find (y, mod);
}
LL id (int x) {
    return Find(x,0) * 1e6 + Find (x, 1);
}
int main (void) {
    scanf ("%d%d%d", &n, &k, &l);
    for (int i = 1; i <= n; i++) {
        fa[0][i] = i;
        fa[1][i] = i;
    }
    for (int i=  0; i < k; i++) {
        int a, b;
        scanf ("%d%d", &a, &b);
        Comb (a, b, 0);
    }
    for (int i = 0; i < l; i++) {
        int a, b;
        scanf ("%d%d", &a, &b);
        Comb (a, b, 1);
    };
    for (int i=  1; i <= n; i++) {
        num[id(i)]++;
    }
    for (int i = 1; i <= n; i++) {
        printf ("%d", num[id(i)]);
        if (i != n) printf (" ");
        else printf ("\n");
    }
    return 0;
}