#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
using namespace std;
//
const int inf=1e9+7;//0x3f
//
struct UnionFind{
	//
	vector<int> par,ran;
	//
	UnionFind(int n){
		init(n);
	}
	//
	void init(int n){
		par.resize(n);
		ran.resize(n,0);
		for(int i=0;i<n;i++){
			par[i]=i;
		}
	}
	//
	int find(int x){
		return (x==par[x]?x:par[x]=find(par[x]));
	}
	//
	bool same(int x,int y){
		return find(x)==find(y);
	}
	//
	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y){
			return;
		}else{
			if(ran[x]<ran[y]){
				par[x]=y;
			}else{
				par[y]=x;
				if(ran[x]==ran[y]){
					ran[x]++;
				}
			}
		}
	}
	//
};
//
int main(){
	int N,K,L;
	cin>>N>>K>>L;
	UnionFind road(N),train(N);
	for(int i=0;i<K;i++){
		int p,q;
		cin>>p>>q;
		p--;q--;
		road.unite(p,q);
	}
	for(int i=0;i<L;i++){
		int r,s;
		cin>>r>>s;
		r--;s--;
		train.unite(r,s);
	}
	int r[200000],t[200000];
	for(int i=0;i<N;i++){
		r[i]=road.find(i);
		t[i]=train.find(i);
	}
	map<pair<int,int>,int> M;
	for(int i=0;i<N;i++){
		M[make_pair(r[i],t[i])]++;
	}
	for(int i=0;i<N;i++){
		if(i){
			cout<<" ";
		}
		cout<<M[make_pair(r[i],t[i])];
	}
	cout<<endl;
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 2e5 + 3;

int pai[3][T];
int peso[3][T];
vii g[T];
int n,k,l;

void init() {
    for(int i = 0; i < 3; i++)
        for(int j = 0; j <= n; j++) {
            pai[i][j] = j;
            peso[i][j] = 1;
        }
}

int find(int op, int x) {
    return (pai[op][x] == x? x : pai[op][x] = find(op,pai[op][x]));
}

void join(int op, int x, int y) {
    x = find(op,x);
    y = find(op,y);
    if(x == y) return;
    if(peso[op][x] < peso[op][y]) swap(x,y);
    pai[op][y] = x;
    peso[op][x] += peso[op][y];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> k >> l;
    init();

    while(k--) {
        int a,b; cin >> a >> b;
        if(find(0,a) != find(0,b)) join(0,a,b);
    }

    while(l--) {
        int a,b; cin >> a >> b;
        if(find(1,a) != find(1,b)) join(1,a,b);
    }

    for(int i = 1; i <= n; i++)
        g[find(0,i)].eb(find(1,i),i);

    for(int i = 1; i <= n; i++) {
        sort(g[i].begin(), g[i].end());
        for(int j = 1; j < g[i].size(); j++)
            if(g[i][j].fi == g[i][j-1].fi)
                join(2,g[i][j].se,g[i][j-1].se);
    }

    for(int i = 1; i <= n; i++) cout << peso[2][find(2,i)] << " ";
    cout << endl;

    return 0;
}
