// 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.435425044499564x):
#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <cmath>

#include <algorithm>

using namespace std;

#define inf (0x3f3f3f3f)

#define ls int len=s.size()

#define ls1 int len1=s1.size()

#define sd(x) scanf("%d",&x)

#define slld(x) scanf("%I64d",&x)

#define reps(i,n) for(int i=1;i<n;i++)

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

#define repn(i,n) for(int i=n-1;i>=0;i--)

typedef long long int LL;

typedef long long int ll;



#include <iostream>

#include <sstream>

#include <vector>

#include <set>

#include <map>

#include <queue>

#include <string>

#include<stack>

#include<ctime>

void g(int t){if(t){g((t-1)/26);putchar(65+(t-1)%26);}}



const int M=2*1e5+100;

int f[M],f1[M],r[M],r1[M];



void init(int n){

    rep(i,n){

        f[i]=i;f1[i]=i;

        r[i]=r1[i]=0;

    }

}

int find(int x){

    return f[x]==x?x:f[x]=find(f[x]);

}

int find1(int x){

    return f1[x]==x?x:f1[x]=find1(f1[x]);

}

void unite(int x,int y){

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

    if(x==y) return;



    if(r[x]<r[y]) f[x]=y;

    else{

        f[y]=x;

        if(r[x]==r[y]) r[x]++;

    }

}

void unite1(int x,int y){

    x=find1(x);y=find1(y);

    if(x==y) return;

    if(r1[x]<r1[y]) f1[x]=y;

    else{

        f1[y]=x;

        if(r1[x]==r1[y]) r1[x]++;

    }

}



map<pair<int,int>,int>mp;



int main()

{

#ifdef LOCAL

    freopen("data.h", "r", stdin);

    //freopen("1.h","w",stdout);

#endif

    int n,K,L;

    scanf("%d%d%d",&n,&K,&L);

    init(n);

    rep(i,K){

        int v,u;

        scanf("%d%d",&v,&u);

        unite(v,u);

    }

    rep(i,L){

        int v,u;

        scanf("%d%d",&v,&u);

        unite1(v,u);

    }

    mp.clear();

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

        mp[make_pair(find(i),find1(i))]++;

    }



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

        printf("%d ",mp[make_pair(find(i),find1(i))]);

    }

    cout<<endl;

}