#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int,int> Pi;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) x.begin(), x.end()

int p[400040];

int Find(int x){
	return p[x] == x ? x : p[x] = Find(p[x]);
}

void solve(){
	int n, k, l; scanf("%d%d%d", &n, &k, &l);
	for(int i=1;i<=n+n;i++)p[i] = i;
	rep(i, k){
		int x, y; scanf("%d%d", &x, &y);
		p[Find(x)] = Find(y);
	}
	rep(i, l){
		int x, y; scanf("%d%d", &x, &y);
		p[Find(x+n)] = Find(y+n);
	}
	ll P[200020];
	map <ll, int> M;
	for(int i=1;i<=n;i++)M[P[i] = (ll)Find(i) << 20 | Find(i+n)]++;
	for(int i=1;i<=n;i++)printf("%d ", M[P[i]]);
	
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}