#include<bits/stdc++.h>
#define LL long long
#define MAXN 200005
using namespace std;

int N,M0,M1;
vector<int> adj[2][MAXN];
vector<int> s[2][MAXN];

int p[2][MAXN];
void dfs(int u, int x, int f){
	p[f][u] = x;
	s[f][x].push_back(u);
	
	int v;
	for(int k=0;k<adj[f][u].size();k++){
		v = adj[f][u][k];
		if(!p[f][v]) dfs(v, x, f);
	}
}

int ans[MAXN], vis[MAXN];
void work(int id){
	int x = p[0][id];
	int v;
	for(int k=0;k<s[0][x].size();k++){
		v = s[0][x][k];
		vis[p[1][v]]++;
	}

	for(int k=0;k<s[0][x].size();k++){
		v = s[0][x][k];
		ans[v] = vis[p[1][v]];
	}
	
	for(int k=0;k<s[0][x].size();k++){
		v = s[0][x][k];
		vis[p[1][v]]--;
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin>>N>>M0>>M1;
	
	int u,v;
	for(int i=1;i<=M0;i++){
		cin>>u>>v;
		adj[0][u].push_back(v);
		adj[0][v].push_back(u);
	}
	for(int i=1;i<=M1;i++){
		cin>>u>>v;
		adj[1][u].push_back(v);
		adj[1][v].push_back(u);
	}
	
	for(int i=1;i<=N;i++){
		if(!p[0][i]){
			dfs(i,i,0);
		}
		if(!p[1][i]){
			dfs(i,i,1);
		}
	}
	
	for(int i=1;i<=N;i++){
		if(ans[i] == 0){
			work(i);
		}
	}
	
	//for(int i=1;i<=N;i++) cout<<p1[i]<<" "<<p2[i]<<endl;
	for(int i=1;i<=N;i++) cout<<ans[i]<<" ";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct _IO{_IO(){ios::sync_with_stdio(0);cin.tie(0);}}_io;

typedef long long ll;
typedef long double db;
typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vii;
typedef pair<int, int> pi;
typedef tuple<int, int, int> t3;
typedef map<int, int> mi;
#define fi first
#define se second
#define vt vector
#define be begin()
#define ed end()
#define sz size()
#define cl clear()
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define lb(v, x) lower_bound(v.begin(), v.end(), x)
#define lbi(v, x) (lb(v, x) - v.begin())
#define tp(t, x, y) t x, y; tie(x, y)
#define tp3(t, x, y, z) t x, y, z; tie(x, y, z)
#define mp make_pair
#define mt make_tuple
#define co const
#define fc(x) for(int x = 1, _end = ri(); x <= _end; x++)
void uni(vi &v) { sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); }

db rd() { db x; cin >> x; return x; }
ll ri() { ll x; cin >> x; return x; }
string rs() { string s; cin >> s; return s; }
pi rpi() { pi x; cin >> x.fi >> x.se; return x; }
vi rvi(int n, int f = 0) { vi v(n + f); for (int i = f; i < v.size(); i++) cin >> v[i]; return v; }
vii rvii(int n, int m, int f = 0) { vii v(n + f, vi(n + f)); for (int i = f; i < v.size(); i++) for (int j = f; j < v[0].size(); j++) cin >> v[i][j]; return v; }
void pr() {}; template <class T, class ...U> void pr(T x, U ...y) { cout << x << ' ', pr(y...); }
void prl() { cout << '\n'; }; template <class T, class ...U> void prl(T x, U ...y) { cout << x << ' ', prl(y...); }
void pr(const vi &v, int f = 0) { for (int i = f; i < v.size(); i++) cout << v[i] << ' '; }
void prl(const vi &v, int f = 0) { pr(v, f); cout << '\n'; }
void pr(const pi &x) { cout << x.fi << ' ' << x.se; };
void prl(const pi &x) { pr(x); cout << '\n'; }

#define rep(i, l, r) for (int i = l; i < r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)

const int N = 2e5 + 5, M = 1e9 + 7;

int fa[N];
int fi(int x) {
  return !fa[x] || fa[x] == x ? x : fa[x] = fi(fa[x]);
}

vi g[N];
map<int, vi> cnt;
bool vis[N];
void dfs(int u) {
  vis[u] = 1;
  cnt[fi(u)].pb(u);
  for (auto &v : g[u]) {
    if (!vis[v]) dfs(v);
  }
}

int main() {
  int n = ri(), a = ri(), b = ri();
  rep(i, 0, a) {
    int x = ri(), y = ri();
    fa[fi(x)] = fi(y);
  }
  rep(i, 0, b) {
    int u = ri(), v = ri();
    g[u].pb(v);
    g[v].pb(u);
  }
  vi ans(n + 1);
  rep(i, 1, n + 1) {
    if (!vis[i]) {
      cnt.clear();
      dfs(i);
      for (auto &p : cnt) {
        for (auto &v : p.se) {
          ans[v] = p.se.sz;
        }
      }
    }
  }
  pr(ans, 1);
}
