// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <algorithm>

#include <vector>

#include <stack>

#include <queue>

#include <map>

#include <set>

#include <string>

#include <cstring>

#include <bitset>

#define ll long long

#define rep(x,n) for(ll (x)=0;(x)<n;(x)++)

#define rep1(x,n) for(ll (x)=1;(x)<=n;(x)++)

using namespace std;



const ll N=200002;



struct node

{

    int id,pa1,pa2;

    node(int _id=0,int _pa1=0,int _pa2=0)

    {

        id=_id;pa1=_pa1;pa2=_pa2;

    }

    bool operator < (const node b) const

    {

        return pa1<b.pa1;

    }

};



int n,pa1[N],pa2[N],ans[N]={0};

vector<node> S[N];



int fpa1(int x)

{

    return pa1[x]==x?x:pa1[x]=fpa1(pa1[x]);

}



int fpa2(int x)

{

    return pa2[x]==x?x:pa2[x]=fpa2(pa2[x]);

}



int main()

{

    #ifdef LOCAL

        freopen("C_data","r",stdin);

    #endif

    int k,l,a,b;

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

    rep1(i,n) pa1[i]=i,pa2[i]=i;

    while(k--)

    {

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

        if(fpa1(b)!=fpa1(a))

            pa1[fpa1(b)]=fpa1(a);

    }

    while(l--)

    {

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

        if(fpa2(b)!=fpa2(a))

            pa2[fpa2(b)]=fpa2(a);

    }

    rep1(i,n)

    {

        S[fpa2(i)].push_back(node(i,fpa1(i),fpa2(i)));

    }

    rep1(i,n)

    {

        sort(S[i].begin(),S[i].end());

        int st=0;

        while(st<S[i].size())

        {

            int t=st,cnt=1;

            while(t+1<S[i].size() && S[i][t+1].pa1==S[i][t].pa1) t++,cnt++;

            for(int j=st;j<=t;j++)

            {

                ans[S[i][j].id]=cnt;

            }

            st=t+1;

        }

    }

    rep1(i,n) cout<<ans[i]<<' ';

    cout<<endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

struct abc {

	int aa, bb, cc;

	bool operator < (const abc&T) const {

		return(aa < T.aa || (aa == T.aa && bb < T.bb) || (aa == T.aa && bb == T.bb && cc < T.cc));

	}

	bool operator == (const abc&T) const {

		return(aa == T.aa && bb == T.bb);

	}

} ans[200005];

using namespace std;

int N, KK, LL, i, j, k, l, m, n, pt1[200005], pt2[200005], s1[200005], s2[200005], z;

int sz[200005], ans2[200005];

int find1(int aa) {

	if(pt1[aa] != aa) 

		pt1[aa] = find1(pt1[aa]);

	return(pt1[aa]);

}

int find2(int bb) {

	if(pt2[bb] != bb) 

		pt2[bb] = find2(pt2[bb]);

	return(pt2[bb]);

}

int main() {

	scanf("%d%d%d", &N, &KK, &LL);

	for(i = 1; i <= N; i++) {

		pt1[i] = i;

		pt2[i] = i;

		s1[i] = 1;

		s2[i] = 1;

	}

	for(i = 0; i < KK; i++) {

		scanf("%d%d", &j, &l);

		if(find1(j) == find1(l)) continue;

		s1[find1(l)] += s1[find1(j)];

		pt1[find1(j)] = find1(l);

	}

	

	for(i = 0; i < LL; i++) {

		scanf("%d%d", &j, &l);

		if(find2(j) == find2(l)) continue;

		s2[find2(l)] += s2[find2(j)];

		pt2[find2(j)] = find2(l);

	}

	for(i = 1; i <= N; i++) {

		pt1[i] = find1(i);

		pt2[i] = find2(i);

		ans[i].aa = pt1[i];

		ans[i].bb = pt2[i];

		ans[i].cc = i;

	}

//	for(i = 1; i <= N; i++) printf("%d %d\n", pt1[i], pt2[i]);

	

	sort(ans + 1, ans + N + 1);

	sz[1] = 1;

	for(i = 2; i <= N; i++) if(ans[i] == ans[i - 1]) {

		sz[i] = sz[i - 1] + 1;

	} else {

		sz[i] = 1;

	}

	for(i = N - 1; i >= 1; i--) 

	if(ans[i] == ans[i + 1]) sz[i] = sz[i + 1];

	

	//for(i = 1; i <= N; i++) printf("%d %d %d %d\n", ans[i].aa, ans[i].bb, ans[i].cc, sz[i]);

	

	for(i = 1; i <= N; i++) ans2[ans[i].cc] = sz[i];

	

	for(i = 1; i < N; i++) printf("%d ", ans2[i]);

	printf("%d\n", ans2[N]);

}

// Fastest known solution for this problem: