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

using namespace std;



const int N = 2e5+10;

int fa1[N],fa2[N];

int findroot1(int u)

{

    return fa1[u]==u?u:fa1[u]=findroot1(fa1[u]);

}

int findroot2(int u)

{

    return fa2[u]==u?u:fa2[u]=findroot2(fa2[u]);

}

set<int>s2[N];

int ans[N];

int main()

{

    int n,k,l;

    int u,v;

    // freopen("in.txt","r",stdin);

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

    for(int i=1;i<=n;i++) fa1[i]=fa2[i]=i;

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

    {

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

        int uu=findroot1(u);

        int vv=findroot1(v);

        if(uu==vv) continue;

        else fa1[vv]=uu;

    }

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

    {

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

        int uu=findroot2(u);

        int vv=findroot2(v);

        if(uu==vv) continue;

        else fa2[vv]=uu;

    }

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

    {

        v=findroot2(i);

        s2[v].insert(i);

    }

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

    {

        if(!s2[i].empty())

        {

            map<int,int>mp;

            for(auto it:s2[i])

            {

                int uu=findroot1(it);

                mp[uu]++;

            }

            for(auto it:s2[i])

            {

                int uu=findroot1(it);

                ans[it]=mp[uu];

            }

        }

    }

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

    {

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

        if(i!=n) printf(" ");

        else printf("\n");

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 11.965504637849701x):
#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;

}