// 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.384628538291112x):
#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;

       

    }

}