// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



const int maxn = 200010;



int fa1[maxn], fa2[maxn], r1[maxn], r2[maxn];



map<pair<int, int>, int> mp;



void kexin_init() {

	for (int i=1; i<=maxn; ++i) {fa1[i] = i; fa2[i] = i;}

	memset(r1, 0, sizeof r1);

	memset(r2, 0, sizeof r2);

}



int kexin_find_road(int x) {

	if (fa1[x] == x) return x;

	return fa1[x] = kexin_find_road(fa1[x]);

}

void kexin_Union_road(int x, int y) {

	x = kexin_find_road(x);

	y = kexin_find_road(y);

	if (x == y) return ;

	if (r1[x] < r1[y]) swap(x, y);

	fa1[y] = x;

	if (r1[x] == r1[y]) r1[x]++;

}



int kexin_find_railway(int x) {

	if (fa2[x] == x) return x;

	return fa2[x] = kexin_find_railway(fa2[x]);

}

void kexin_Union_railway(int x, int y) {

	x = kexin_find_railway(x);

	y = kexin_find_railway(y);

	if (x == y) return ;

	if (r2[x] < r2[y]) swap(x, y);

	fa2[y] = x;

	if (r2[x] == r2[y]) r2[x]++;

}

int main() {

	int n, k, l;

	scanf("%d%d%d", &n, &k, &l);

	

	kexin_init();

	for (int i=1; i<=k; ++i) {

		int x, y;

		scanf("%d%d", &x, &y);

		kexin_Union_road(x, y);

	}

	for (int i=1; i<=l; ++i) {

		int x, y;

		scanf("%d%d", &x, &y);

		kexin_Union_railway(x, y);

	}

	

	mp.clear();



	for (int i=1; i<=n; ++i) mp[make_pair(kexin_find_road(i), kexin_find_railway(i))]++;

	for (int i=1; i<n; ++i) printf("%d ", mp[make_pair(kexin_find_road(i), kexin_find_railway(i))]);

	printf("%d\n", mp[make_pair(kexin_find_road(n), kexin_find_railway(n))]);



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.2545766833702645x):
#include <algorithm>

#include <assert.h>

#include <bitset>

#include <cstdio>

#include <cstring>

#include <iostream>

#include <map>

#include <queue>

#include <set>

#include <vector>

#define MP make_pair

#define ls (o << 1)

#define rs (o << 1 | 1)

#define mid ((L + R) >> 1)

#define eps (1e-5)

using namespace std;

typedef long long LL;

const LL mod = 1e9 + 7;

typedef pair<int, int> PII;

int n, k, l;

int f[200010], g[200010], h[200010], ans[200010];

int findfa(int *w, int o) {

    if (w[o] == o)

        return o;

    return w[o] = findfa(w, w[o]);

}

bool cmp(const int &o, const int &p) {

    int fa = findfa(f, o);

    int fb = findfa(f, p);

    if (fa != fb)

        return fa < fb;

    fa = findfa(h, o);

    fb = findfa(h, p);

    return fa < fb;

}

int main() {

    scanf("%d%d%d", &n, &k, &l);

    for (int i = 1; i <= n; ++i) {

        f[i] = i;

        g[i] = i;

        h[i] = i;

    }

    for (int i = 0; i < k; ++i) {

        int u, v;

        scanf("%d%d", &u, &v);

        int fa = findfa(f, u);

        int fb = findfa(f, v);

        f[fa] = fb;

    }

    for (int i = 0; i < l; ++i) {

        int u, v;

        scanf("%d%d", &u, &v);

        int fa = findfa(h, u);

        int fb = findfa(h, v);

        h[fa] = fb;

    }

    sort(g + 1, g + n + 1, cmp);

    for (int i = 1; i <= n;) {

        int j = i;

        while (j <= n && findfa(f, g[i]) == findfa(f, g[j]) &&

               findfa(h, g[i]) == findfa(h, g[j])) {

            j++;

        }

        for (int k = i; k < j; ++k) {

            ans[g[k]] = j - i;

        }

        i = j;

    }

    for (int i = 1; i <= n; ++i) {

        printf("%d%c", ans[i], i == n ? '\n' : ' ');

    }

    return 0;

}