// Slower C++ solution:
#include <algorithm>

#include <iostream>

#include <iomanip>

#include <cstring>

#include <string>

#include <vector>

#include <queue>

#include <cmath>

using namespace std;



const int MAXN = 200000 + 10;

const int MAXL = 100000 + 10;



struct DSU

{

    int fa[MAXN];



    int find(int x)

    {

        if(x == fa[x])

            return x;

        return fa[x] = find(fa[x]);

    }



    void merge(int x, int y)

    {

        fa[find(x)] = find(y);

    }

}d1, d2;



int tmp[MAXN], ans[MAXN], cnt[MAXN];



void init(DSU & d)

{

    for(int i = 0; i < MAXN; i++)

        d.fa[i] = i;

}



int N, K, L;

int main()

{

    init(d1);

    init(d2);

    int u, v;

    cin >> N >> K >> L ;



    for(int i = 1; i <= K; i++)

        cin >> u >> v, d1.merge(u, v);

    for(int i = 1; i <= L; i++)

        cin >> u >> v, d2.merge(u, v);



    for(int i = 1; i <= N; i++)

        d1.fa[i] = d1.find(i),

        d2.fa[i] = d2.find(i);

    for(int i = 1; i <= N; i++)

        tmp[i] = i;

    sort(tmp+1, tmp+N+1, [](int x, int y)-> bool {return d1.fa[x] < d1.fa[y];});





    for(int i = 1; i <= N; i++)

    {

        int j = i;

        while(j < N && d1.fa[tmp[j]] == d1.fa[tmp[j+1]])

            j++;



        for(int t = i; t <= j; t++)

            cnt[d2.fa[tmp[t]]]++;

        for(int t = i; t <= j; t++)

            ans[tmp[t]] = cnt[d2.fa[tmp[t]]];

        for(int t = i; t <= j; t++)

            cnt[d2.fa[tmp[t]]]--;

        i = j ;

    }



    for(int i = 1; i <= N; i++)

        cout << ans[i] << " " ;



    return 0;

}


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

#include<ctime>

#include<cstdio>

#include<cstring>

#include<iostream>

#include<algorithm>

#define mp make_pair

using namespace std;



map<pair<int,int>,int> m;



struct dsu

{

    int fa[200010],rank[200010];

    

    void init(int n)

    {

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

        {

            fa[i]=i;

        }

    }

    

    int find(int x)

    {

        if(fa[x]==x)

        {

            return x;

        }

        return fa[x]=find(fa[x]);

    }

    

    void union_(int x,int y)

    {

        int fx=find(x);

        int fy=find(y);

        if(fx==fy)

        {

            return ;

        }

        if(rank[fx]<rank[fy])

        {

            fa[fx]=fy;

        }

        else

        {

            fa[fy]=fx;

            if(rank[fx]==rank[fy])

            {

                rank[x]++;

            }

        }

    }

    

    int same(int x,int y)

    {

        return find(x)==find(y);

    }

}a,b;



int main()

{

    //give the fucking vjudge a flying fucking

    int n,x,y;

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

    a.init(n);

    b.init(n);

    int from,to;

    for(int i=1;i<=x;i++)

    {

        scanf("%d%d",&from,&to);

        a.union_(from,to);

    }

    for(int i=1;i<=y;i++)

    {

        scanf("%d%d",&from,&to);

        b.union_(from,to);

    }

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

    {

        m[mp(a.find(i),b.find(i))]++;

    }

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

    {

        printf("%d ",m[mp(a.find(i),b.find(i))]);

    }

}