// Slower C++ solution:
#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;

}


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

#include <cstdio>

#include <cstring>

#include <queue>

#include <map>

#include <vector>

#include <algorithm>

#include <cstdlib>

#include <cmath>

#include <bitset>

#define pb push_back

#define mp make_pair

#define x first

#define y second

#define pii pair<int,int>

#define pdd pair<db,db>



using namespace std;



typedef long long ll;

typedef double db;



const int N = 1e5+10,M=1e4+10,MOD = 1e9+7;



int fa[N*2],fb[2*N];

//int ans[N*2];



void init(int n){

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

        fa[i]=fb[i]=i;

}



int finda(int x){

    if(fa[x]!=x)fa[x]=finda(fa[x]);

    return fa[x];

}

int findb(int x){

    if(fb[x]!=x)fb[x]=findb(fb[x]);

    return fb[x];

}



int main()

{

    int n,k,l;

    while(~scanf("%d%d%d",&n,&k,&l)){

        init(n);

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

            int x,y;

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

            int fx=finda(x),fy=finda(y);

            if(fx!=fy)fa[fx]=fy;

        }

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

            int x,y;

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

            int fx=findb(x),fy=findb(y);

            if(fx!=fy)fb[fx]=fy;

        }

        map<int,pii> m1;

        map<pii,int> m2;

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

            int xa=finda(i),xb=findb(i);

           //cout<<xa<<" "<<xb<<endl;

            m1[i]=mp(xa,xb);

            m2[mp(xa,xb)]++;

           // cout<<"("<<m1[i].x<<","<<m1[i].y<<") "<<m2[mp(xa,xb)]<<endl<<endl;

        }



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

            cout<<m2[m1[i]]<<" ";

        }

        cout<<endl;

       

    }

}