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

#include <cstdio>

#include <cstring>

#include <cmath>

#include <algorithm>

#include <vector>

#include <queue>

#include <string>

#include <stack>

#include <map>

#include <ctime>

#include <set>

#include <bitset>

#include <ctime>

#define X first

#define Y second

#define clr(u,v); memset(u,v,sizeof(u));

#define in() freopen("data","r",stdin);

#define out() freopen("data","w",stdout);

#define Clear(Q); while (!Q.empty()) Q.pop();

#define pb push_back

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<char, int> pci;

const int maxn = 2e5 + 10;

const int INF = 0x3f3f3f3f;

int f[maxn];

int f2[maxn];

int f3[maxn];



int sum[maxn];

void init(int n)

{

    for (int i = 0; i < maxn; i++)

        f[i] = i, f2[i] = i, f3[i] = i, sum[i] = 1;

}

int find(int x)

{

    return f[x] == x ? x : f[x] = find(f[x]);

}

int find2(int x)

{

    return f2[x] == x ? x : f2[x] = find2(f2[x]);

}



int find3(int x)

{

    return f3[x] == x ? x : f3[x] = find3(f3[x]);

}





void mix(int x, int y)

{

    int fx = find(x), fy = find(y);

    if (fx == fy) return ;

    f[fx] = fy;

}

void mix2(int x, int y)

{

    int fx = find2(x), fy = find2(y);

    if (fx == fy) return ;

    f2[fx] = fy;

}

void mix3(int x, int y)

{

    int fx = find3(x), fy = find3(y);

    if (fx == fy) return ;

    f3[fx] = fy;

    sum[fy] += sum[fx];

}

map <pii, int> M;



int main()

{

#ifdef LOCAL

//    in();

#endif

    int n, k, l, a, b;

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

    init(n);

    while (k--)

    {

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

        mix(a, b);

    }

    while (l--)

    {

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

        mix2(a, b);

//        else mix3(a,b);

    }

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

        M[make_pair(find(i), find2(i))]++;



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

        printf("%d ", M[make_pair(find(i), find2(i))]);

    puts("");

    return 0;

}


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

}