#include <bits/stdc++.h>
#define ll  long long

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, "\e[31;1m"); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\e[0m")
#else
    #define eprintf(...) 42
#endif

#define DEBUG   false

#if true
using Graph = std::vector<std::vector<int>>;
using Visited = std::vector<int>;

void dfs(const Graph& G, Visited& V, int n, int id)
{
    V[n] = id;
    for (auto next : G[n])
    {
        if (-1 != V[next])
        {
            continue;
        }
        dfs(G, V, next, id);
    }
}

int main(void)
{
    int N, K, L;
    std::cin >> N >> K >> L;

    Graph R(N);
    for (int i = 0; i < K; i++)
    {
        int x, y;
        std::cin >> x >> y;
        R[x - 1].push_back(y - 1);
        R[y - 1].push_back(x - 1);
    }

    Visited RV(N, -1);
    int id = 0;
    for (int i = 0; i < N; i++)
    {
        if (-1 != RV[i])
        {
            continue;
        }
        dfs(R, RV, i, id++);
    }

    Graph T(N);
    for (int i = 0; i < L; i++)
    {
        int x, y;
        std::cin >> x >> y;
        T[x - 1].push_back(y - 1);
        T[y - 1].push_back(x - 1);
    }

    Visited TV(N, -1);
    id = 0;
    for (int i = 0; i < N; i++)
    {
        if (-1 != TV[i])
        {
            continue;
        }
        dfs(T, TV, i, id++);
    }

    std::map<std::pair<ll, ll>, int> n;
    for (int i = 0; i < N; i++)
    {
        n[{RV[i], TV[i]}]++;
    }
    for (int i = 0; i < N; i++)
    {
        if (0 != i)
        {
            std::cout << " ";
        }
        std::cout << n[{RV[i], TV[i]}];
    }
    std::cout << std::endl;

    return EXIT_SUCCESS;
}
#else

struct UnionFind
{
private:

    std::vector<int> parent;

public:

    UnionFind(int N)
        : parent(N)
    {
        for (int i = 0; i < N; i++)
        {
            parent[i] = i;
        }
    }

    friend std::ostream& operator << (std::ostream& a, const UnionFind& b)
    {
        a << "{";
        for (int i = 0; i < b.parent.size(); i++)
        {
            if (0 != i)
            {
                a << ", ";
            }
            a << i << ": " << b.parent[i];
        }
        a << "}";
        return a;
    }

    int root(int x)
    {
        if (parent[x] == x)
        {
            return x;
        }
        return parent[x] = root(parent[x]);
    }

    void unite(int x, int y)
    {
        if (same(x, y))
        {
            return;
        }
        parent[root(x)] = root(y);
    }

    bool same(int x, int y)
    {
        return root(x) == root(y);
    }

};

int main(void)
{
    int N, K, L;
    std::cin >> N >> K >> L;

    UnionFind ar(N);
    for (int i = 0; i < K; i++)
    {
        int x, y;
        std::cin >> x >> y;
        ar.unite(x - 1, y - 1);
    }
#if DEBUG
    std::cout << "ar: " << ar << std::endl;
#endif

    UnionFind br(N);
    for (int i = 0; i < L; i++)
    {
        int x, y;
        std::cin >> x >> y;
        br.unite(x - 1, y - 1);
    }
#if DEBUG
    std::cout << "br: " << br << std::endl;
#endif

    std::map<std::pair<ll, ll>, ll> n;
    for (int i = 0; i < N; i++)
    {
        ll a = ar.root(i);
        ll b = br.root(i);
        n[{a, b}]++;
    }
#if DEBUG
    std::cout << "ar: " << ar << std::endl;
#endif
#if DEBUG
    std::cout << "br: " << br << std::endl;
#endif
#if DEBUG
    for (int i = 0; i < N; i++)
    {
        ll a = ar.root(i);
        ll b = br.root(i);
        std::cout << a << "-" << b << ": " << n[{a, b}] << std::endl;
    }
#endif
    for (int i = 0; i < N; i++)
    {
        if (0 != i)
        {
            std::cout << " ";
        }
        ll a = ar.root(i);
        ll b = br.root(i);
        std::cout << n[{a, b}];
    }
    std::cout << std::endl;

    return EXIT_SUCCESS;
}
#endif

Measured memory_bytes: 27776