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

#include <string.h>

#include <iostream>

#include <algorithm>

#include <queue>

#include <vector>

#include <string>

#include <set>

#include <map>

#define ll long long

#define ull unsigned long long

#define rep(i, to) for(int i = 0; i < (to); ++i)

#define rep1(i, to) for(int i = 1; i <= (to); ++i)

#define ms(x, v) memset(x, v, sizeof(x))

using namespace std;

const int N = 200005;

int pa1[N], pa2[N];

int fpa1(int x){ return pa1[x] == x ? x : pa1[x] = fpa1(pa1[x]); }

int fpa2(int x){ return pa2[x] == x ? x : pa2[x] = fpa2(pa2[x]); }

void lnk1(int x, int y) {x = fpa1(x), y = fpa1(y); if(x != y) pa1[x] = y;}

void lnk2(int x, int y) {x = fpa2(x), y = fpa2(y); if(x != y) pa2[x] = y;}

int ans[N];

vector<int> v[N];

int main()

{

#ifdef LOCAL

    freopen("in", "r", stdin);

#endif

//    ios::sync_with_stdio(0);

    int n, k, l, a, b;

    while(scanf("%d%d%d", &n, &k, &l) > 0)

    {

        ms(ans, 0);

        rep1(i, n) pa1[i] = pa2[i] = i, v[i].clear();

        rep1(i, k)

        {

            scanf("%d%d", &a, &b);

            lnk1(a, b);

        }

        rep1(i, l)

        {

            scanf("%d%d", &a, &b);

            lnk2(a, b);

        }

        rep1(i, n) v[fpa1(i)].push_back(i);

        rep1(i, n)

        {

            if(v[i].size())

            {

                map<int, int> mp;

                rep(j, (int)v[i].size()) mp[fpa2(v[i][j])]++;

                rep(j, (int)v[i].size())

                {

                    ans[v[i][j]] = mp[fpa2(v[i][j])];

                }

            }

        }

        rep1(i, n) printf("%d ", ans[i]);

        puts("");

    }

    return 0;

}


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

#include <cstdio>

#include <algorithm>

#include <vector>

#include <stack>

#include <queue>

#include <map>

#include <set>

#include <string>

#include <cstring>

#include <bitset>

#define ll long long

#define rep(x,n) for(ll (x)=0;(x)<n;(x)++)

#define rep1(x,n) for(ll (x)=1;(x)<=n;(x)++)

using namespace std;



const ll N=200002;



struct node

{

    int id,pa1,pa2;

    node(int _id=0,int _pa1=0,int _pa2=0)

    {

        id=_id;pa1=_pa1;pa2=_pa2;

    }

    bool operator < (const node b) const

    {

        return pa1<b.pa1;

    }

};



int n,pa1[N],pa2[N],ans[N]={0};

vector<node> S[N];



int fpa1(int x)

{

    return pa1[x]==x?x:pa1[x]=fpa1(pa1[x]);

}



int fpa2(int x)

{

    return pa2[x]==x?x:pa2[x]=fpa2(pa2[x]);

}



int main()

{

    #ifdef LOCAL

        freopen("C_data","r",stdin);

    #endif

    int k,l,a,b;

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

    rep1(i,n) pa1[i]=i,pa2[i]=i;

    while(k--)

    {

        scanf("%d%d",&a,&b);

        if(fpa1(b)!=fpa1(a))

            pa1[fpa1(b)]=fpa1(a);

    }

    while(l--)

    {

        scanf("%d%d",&a,&b);

        if(fpa2(b)!=fpa2(a))

            pa2[fpa2(b)]=fpa2(a);

    }

    rep1(i,n)

    {

        S[fpa2(i)].push_back(node(i,fpa1(i),fpa2(i)));

    }

    rep1(i,n)

    {

        sort(S[i].begin(),S[i].end());

        int st=0;

        while(st<S[i].size())

        {

            int t=st,cnt=1;

            while(t+1<S[i].size() && S[i][t+1].pa1==S[i][t].pa1) t++,cnt++;

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

            {

                ans[S[i][j].id]=cnt;

            }

            st=t+1;

        }

    }

    rep1(i,n) cout<<ans[i]<<' ';

    cout<<endl;

    return 0;

}