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

#include <bits/stdc++.h>



using namespace std;



int fa[200005];

int fa1[200005];

int vis[200005];



int find1(int a)

{

    if(fa[a]!=a)

        fa[a]=find1(fa[a]);

    return fa[a];

}

void union1(int a,int b)

{

    fa[find1(a)]=find1(b);

}



int find2(int a)

{

    if(fa1[a]!=a)

        fa1[a]=find2(fa1[a]);

    return fa1[a];

}

void union2(int a,int b)

{

    fa1[find2(a)]=find2(b);

}

map<long long,int> mp;

int main()

{

    int n,k,l;

    cin>>n>>k>>l;

    memset(vis,0,sizeof(vis));

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

    {

        fa[i]=i;

        fa1[i]=i;

    }

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

    {

        int l1,r;

        scanf("%d %d",&l1,&r);

        union1(l1,r);

    }

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

    {

        int l1,r;

        scanf("%d %d",&l1,&r);

        //if(find1(l1)==find1(r))

        union2(l1,r);

        //cout<<find1(l1)<<' '<<find1(r);

    }

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

    {

        if(mp.find((long long)((long long)find1(i)*200005+(long long)find2(i)))==mp.end())

            mp[(long long)((long long)find1(i)*200005+(long long)find2(i))]=0;

        mp[(long long)((long long)find1(i)*200005+(long long)find2(i))]++;

    }

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

        printf("%d ",mp[(long long)((long long)find1(i)*200005+(long long)find2(i))]);

    printf("%d\n",mp[(long long)((long long)find1(n)*200005+(long long)find2(n))]);

    return 0;

}


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

#include<queue>

#include<climits>

#include<algorithm>

#include<cstdlib>

#include<cmath>

#include<cstring>

#include<string>

#include<ctype.h>

#include<set>

#include<vector>

#include<map>

#include<time.h>

#include<list>

#include<stack>

#include<iostream>

using namespace std;

#define mod 1000000007

#define mem(x,k ) memset(x, (k) ,sizeof(x))

#define mp(A, B) make_pair(A, B)

#define pb push_back

#define sca scanf

#define pri printf

#define fi first

#define se second



typedef long long LL;

typedef long double LD;

typedef pair< int , int  > pii;



const LL INFLL=0x3f3f3f3f3f3f3f3fll;

const int INF=0x7fffffff;

const double PI=acos(-1.0);

const double  eps=1e-9;

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

//freopen("D.out","w",stdout);

int n,m,k;

int f[200005];

int f2[200005];

map<pair<int ,int >,int> G;

int Father(int k)

{

    if (k==f[k]) return k;

	return f[k]=Father(f[k]);

}



void Union(int x,int y)

{

    if (Father(x)==Father(y)) return;

    else

    {

        f[ f[x] ]=f[y];

        return;

    }

}

int Father2(int k)

{

    if (k==f2[k]) return k;

	return f2[k]=Father2(f2[k]);

}



void Union2(int x,int y)

{

    if (Father2(x)==Father2(y)) return;

    else

    {

        f2[ f2[x] ]=f2[y];

        return;

    }

}

int main(){

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

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

        f[i]=f2[i]=i;

    }

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

        int u,v;

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

        Union2(u,v);

    }

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

        int u,v;

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

        Union(u,v);

    }

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

        G[make_pair(Father(i),Father2(i))]++;

    }

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

        //printf("@%d@",Father(i));

        printf("%d",G[make_pair(Father(i),Father2(i))]);

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

    }

    printf("\n");

    return 0;

}