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

#include<algorithm>

#include<iostream>

#include<cstring>

#include<vector>

#include<cmath>

#include<map>

#include<set>

#include<queue>

using namespace std;

typedef long long ll;

const int N=2e5+10;

int a[N],b[N];

vector<int>v[N];

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

queue<int>q;

int main()

{

    int n,k,l,i,j;

    cin>>n>>k>>l;

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

    {

        int x,y;

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

        v[x].push_back(y);

        v[y].push_back(x);

    }

    int cnt=0;

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

    if(a[i]==0)

    {

        a[i]=++cnt;

        q.push(i);

        while(!q.empty())

        {

            int x=q.front();

            for(j=0;j<v[x].size();j++)

            if(a[v[x][j]]==0)

            {

                a[v[x][j]]=cnt;

                q.push(v[x][j]);

            }

            q.pop();

        }

    }

    for(i=1;i<=n;i++)v[i].clear();

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

    {

        int x,y;

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

        v[x].push_back(y);

        v[y].push_back(x);

    }

    cnt=0;

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

    if(b[i]==0)

    {

        b[i]=++cnt;

        q.push(i);

        while(!q.empty())

        {

            int x=q.front();

            for(j=0;j<v[x].size();j++)

            if(b[v[x][j]]==0)

            {

                b[v[x][j]]=cnt;

                q.push(v[x][j]);

            }

            q.pop();

        }

    }

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

        mp[make_pair(a[i],b[i])]++;

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

        printf("%d ",mp[make_pair(a[i],b[i])]);

	return 0;

}


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

}