// Copyright (C) 2016 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <cassert>
#include <ctime>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <functional>
#include <string>

#define x first
#define y second
#define MP std::make_pair
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

typedef long long LL;
typedef std::pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
std::string procStatus()
{
    std::ifstream t("/proc/self/status");
    return std::string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        if (ch == '-')
            f = -1;
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

#include <vector>

const int MAXN = 2e5 + 5;

int N, M1, M2;
Pii E1[MAXN], E2[MAXN];
int fa1[MAXN], fa2[MAXN];

int getFather(int *fa, int u)
{
    return fa[u] == u ? u : fa[u] = getFather(fa, fa[u]);
}

std::vector<Pii> set[MAXN];

void input()
{
    read(N); read(M1); read(M2);
    for (int i = 1; i <= M1; ++i) {
        read(E1[i].x); read(E1[i].y);
    }
    for (int i = 1; i <= M2; ++i) {
        read(E2[i].x); read(E2[i].y);
    }
}

void solve()
{
    for (int i = 1; i <= N; ++i) {
        fa1[i] = fa2[i] = i;
    }
    for (int i = 1; i <= M1; ++i) {
        int u = E1[i].x, v = E1[i].y;
        int fu = getFather(fa1, u), fv = getFather(fa1, v);
        if (fu != fv)
            fa1[fu] = fv;
    }
    for (int i = 1; i <= M2; ++i) {
        int u = E2[i].x, v = E2[i].y;
        // printf("(%d, %d)\n", u, v);
        int fu = getFather(fa2, u), fv = getFather(fa2, v);
        if (fu != fv)
            fa2[fu] = fv;
    }

    for (int i = 1; i <= N; ++i) {
        // printf("%d:, fa1 = %d, fa2 = %d\n", i, getFather(fa1, i), getFather(fa2, i));
        set[getFather(fa1, i)].push_back(MP(getFather(fa2, i), i));
    }

    static int ans[MAXN];

    for (int i = 1; i <= N; ++i) {
        if (fa1[i] == i) {
            std::sort(set[i].begin(), set[i].end());
            int last = 0;
            for (int j = 0; j < set[i].size(); ++j) {
                if (set[i][j].x != set[i][last].x) {
                    for (int k = last; k < j; ++k) {
                        ans[set[i][k].y] = j - last;
                    }
                    last = j;
                }
            }
            for (int k = last; k < set[i].size(); ++k) {
                ans[set[i][k].y] = set[i].size() - last;
            }
        }
    }

    for (int i = 1; i <= N; ++i) {
        write(ans[i]); putchar(' ');
    }
    putchar('\n');
}

int main()
{
#ifdef __DEBUG
    freopen("D.in", "r", stdin);
    freopen("D.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}


Measured memory_bytes: 15744