#include <cstdio>
#include <vector>
using namespace std;

const int N = 2e5 + 5;
int pa1[N], pa2[N], pa3[N];
int find(int* p, int v) { return v == p[v] ? v : p[v] = find(p, p[v]); }
void unite(int* p, int a, int b) { p[find(p, b)] = find(p, a); }

int n, k, l;
// vector<int> e1[N], e2[N];
vector<pair<int, int>> all_e;
int cnt[N];

int main() {
#ifdef D
    freopen("a.in", "r", stdin);
#endif
    for (int i = 0; i < N; i++) {
        pa1[i] = pa2[i] = pa3[i] = i;
    }
    scanf("%d%d%d", &n, &k, &l);
    for (int i = 0; i < k; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        unite(pa1, a, b);
        all_e.push_back({a, b});
        // e1[a].push_back(b);
        // e1[b].push_back(a);
    }
    for (int i = 0; i < l; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        unite(pa2, a, b);
        all_e.push_back({a, b});
        // e2[a].push_back(b);
        // e2[b].push_back(a);
    }

    for (auto it : all_e) {
        int a = it.first, b = it.second;
        if (find(pa1, a) == find(pa1, b) && find(pa2, a) == find(pa2, b)) {
            unite(pa3, a, b);
        }
    }

    for (int i = 1; i <= n; i++) {
        cnt[find(pa3, i)]++;
    }

    for (int i = 1; i <= n; i++) {
        printf("%d ", cnt[find(pa3, i)]);
    }
    puts("");

    return 0;
}
