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

using namespace std;



const int N = 2e5+10;

int fa1[N],fa2[N];

int findroot1(int u)

{

    return fa1[u]==u?u:fa1[u]=findroot1(fa1[u]);

}

int findroot2(int u)

{

    return fa2[u]==u?u:fa2[u]=findroot2(fa2[u]);

}

set<int>s2[N];

int ans[N];

int main()

{

    int n,k,l;

    int u,v;

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

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

    for(int i=1;i<=n;i++) fa1[i]=fa2[i]=i;

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

    {

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

        int uu=findroot1(u);

        int vv=findroot1(v);

        if(uu==vv) continue;

        else fa1[vv]=uu;

    }

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

    {

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

        int uu=findroot2(u);

        int vv=findroot2(v);

        if(uu==vv) continue;

        else fa2[vv]=uu;

    }

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

    {

        v=findroot2(i);

        s2[v].insert(i);

    }

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

    {

        if(!s2[i].empty())

        {

            map<int,int>mp;

            for(auto it:s2[i])

            {

                int uu=findroot1(it);

                mp[uu]++;

            }

            for(auto it:s2[i])

            {

                int uu=findroot1(it);

                ans[it]=mp[uu];

            }

        }

    }

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

    {

        printf("%d",ans[i]);

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

        else printf("\n");

    }

    return 0;

}


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

}