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

#include <stdio.h>

#include <iostream>

#include <string.h>

#include <math.h>

#include <stdlib.h>

#include <limits.h>

#include <algorithm>

#include <queue>

#include <vector>

#include <set>

#include <map>

#include <stack>

#include <bitset>

#include <string>

#include <time.h>

using namespace std;

long double esp=1e-11;

//#pragma comment(linker, "/STACK:1024000000,1024000000")

#define fi first

#define se second

#define all(a) (a).begin(),(a).end()

#define cle(a) while(!a.empty())a.pop()

#define mem(p,c) memset(p,c,sizeof(p))

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

#define pb push_back

#define lson l , m , rt << 1

#define rson m + 1 , r , rt << 1 | 1

typedef long long int LL;

const long double PI = acos((long double)-1);

const LL INF=0x3f3f3f3f3f3f3f3fll;

const int MOD =1000000007ll;

const int maxn=210100;

int ro1[maxn];

int up1(int u){return(ro1[u]==u)?u:ro1[u]=up1(ro1[u]);}

int ro2[maxn];

int up2(int u){return(ro2[u]==u)?u:ro2[u]=up2(ro2[u]);}

vector<pair<int,int> >node[maxn];

int c[maxn][2];

int ans[maxn];

int main()

{

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

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

    //freopen("out9.txt", "w", stdout);

    //::iterator iter;                  %I64d

    //for(int x=1;x<=n;x++)

    //for(int y=1;y<=n;y++)

    //scanf("%d",&a);

    //printf("%d\n",ans);

    int n,k,l;

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

    for(int x=1;x<=n;x++)ro1[x]=ro2[x]=x,node[x].clear();

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

    {

        int u,v;

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

        ro1[up1(u)]=up1(v);

    }

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

        node[up1(x)].pb(mp(x,0));

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

    {

        int u,v;

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

        ro2[up2(u)]=up2(v);

    }

    mem(ans,0);

    mem(c,0);

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

    {

    	for(int y=0;y<node[x].size();y++)

		{

			node[x][y].se=up2(node[x][y].fi);

			if(c[node[x][y].se][1]!=x)

			{

				c[node[x][y].se][1]=x;

				c[node[x][y].se][0]=0;

			}

			c[node[x][y].se][0]++;

		}

		for(int y=0;y<node[x].size();y++)

			ans[node[x][y].fi]=c[node[x][y].se][0];

    }

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

        printf("%d%c",ans[x]," \n"[x==n]);

    return 0;

}


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

#include<iostream>

#include<algorithm>

#include<cstdio>

#include<cstdlib>

#include<cmath> 

#include<cstring> 

#include<cassert>

#include<string>

#include<sstream>

#include<fstream>

#include<deque>

#include<queue>

#include<vector>

#include<map>

#include<list>

#include<stack>

#include<set>

#include<bitset>

#include<iomanip>

#include<utility>

#include<functional>

#include<cctype>

#include<cerrno>

#include<cfloat>

#include<ciso646>

#include<climits>

#include<clocale>

#include<complex>

#include<csetjmp>

#include<csignal>

#include<cstdarg>

#include<cstddef>

#include<cwchar>

#include<cwctype>

#include<exception>

#include<locale>

#include<numeric>

#include<new>

#include<stdexcept>

#include<limits>

using namespace std;



#define ll long long

#define INF 1e9

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

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

#define mk(a,b) make_pair(a,b)

#define fi first

#define se second

#define pii pair<int,int>

#define sz(s) s.size()

#define all(s) (s.begin(),s.end())



const int maxn=200005;

int n,k,l;

int f1[maxn],f2[maxn],ans[maxn];

map<pii,vector<int> >mp;





int Find(int f[],int x){

	return f[x]==x?x:f[x]=Find(f,f[x]);

}



void Union(int f[],int x,int y){

	x=Find(f,x);y=Find(f,y);

	if(x!=y)f[x]=y;

}



int main(){

	ios::sync_with_stdio(false);

	cin>>n>>k>>l;

	REP(i,n)f1[i]=f2[i]=i;

	while(k--){

		int u,v;

		cin>>u>>v;

		Union(f1,u,v);

	}

	while(l--){

		int u,v;

		cin>>u>>v;

		Union(f2,u,v);

	}

	REP(i,n)mp[mk(Find(f1,i),Find(f2,i))].push_back(i);

	for(map<pii,vector<int> >::iterator it=mp.begin();it!=mp.end();it++){

		rep(j,it->se.size())ans[it->se[j]]=it->se.size();

	}

	REP(i,n)cout<<ans[i]<<" ";

	return 0;

}