/***************************************** START OF TEMPLATE *********************************************/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define  SPEED           ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT      mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)      for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)      for(ll i = (a); i >= n; i--)
#define  fo(i,n)         for(ll i = 0; i < n; i++)
#define  newl            cout<<"\n";
#define  f               first
#define  s               second
#define  pb              push_back
#define  mp              make_pair
#define  sym(s)          s="#"+s+"#";
#define  sqr(v)          v*v;
#define  all(x)          (x).begin(),(x).end()
#define  alll(x,n)       x+1, x+n+1
#define  uniq(a)         a.resize(unique(a.begin(), a.end()) - a.begin());
#define  mset(x,val)     memset(x,val,sizeof(x))
#define  mset1d(a,n,v)   foo(i,0,n+5)a[i]=v;
#define  mset2d(a,n,m,v) foo(i,0,n+5)foo(j,0,m+5)a[i][j]=v;
#define  deb1(a)         cout<<a<<"\n";
#define  deb2(a,b)       cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)     cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)   cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  debp(a)         cout<<a.f<<" "<<a.s<<"\n";
#define  debv(a)         for(auto it: a)cout<<it<<" ";newl;
#define  debm(a)         for(auto it: a)cout<<"{"<<it.f<<","<<it.s<<"}, ";newl;
#define  deb1d(a,n)      foo(i,1,n)cout<<a[i]<<" ";newl;
#define  deb2d(a,n,m)    foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}    

template <typename T> 
using  ordered_set =  tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;
using  ll          =  long long;
using  ull         =  unsigned long long;
using  ld          =  long double;
using  pll         =  pair<ll,ll>;
using  vll         =  vector<ll>;
using  vpll        =  vector<pll>;

const ld   PI    =  3.14159265358979323846; 
const ll   MOD   =  1e+9+7;
const ll   INF   =  LLONG_MAX;
const int  INFi  =  INT_MAX;
const ll   N     =  2e+5+8;

vll adj[N]; ll vis[N];
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

ll test_cases = 1; randomINIT;

/*********************************************************************************************************/
ll n, m1, m2, u, v, res[N];
vll component;
ll par[N], sz[N]; 
/***************************************** VARIABLE DECLARATIONS *****************************************/


/***************************************** FUNCTION IMPLEMENTATIONS **************************************/
void make() {
    foo(v,1,N-1)
        par[v]=v, sz[v]=1;
} 
 
ll find(ll v) {
    return  (v == par[v])? v: par[v] = find(par[v]);
}
 
void merge(ll x, ll y) {
    ll a = find(x); 
    ll b = find(y);
    if (a != b) {
        if (sz[a] < sz[b]) 
            swap(a, b);
        par[b] = a;
        sz[a] += sz[b];
    }
}

void dfs(ll v){
    vis[v]=1;
    component.pb(v);
    for(auto to : adj[v]){
        if(!vis[to]) dfs(to);
    }
}
/***************************************** START OF MAIN FUNCTION ****************************************/
void MAIN(ll tc){
    cin>>n>>m1>>m2;
    for(int i = 1; i <= m1; i++){
        cin>>u>>v;
        merge(u,v);
    }
    for(int i = 1; i <= m2; i++){
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }


    for(int i = 1; i <= n; i++){
        if(!vis[i]){
            component.clear();
            dfs(i);
            map<ll,ll> cnt;
            for(auto it: component){
                ll p = find(it);
                cnt[p]++;
            }
            for(auto it: component){
                ll p = find(it);
                res[it] = cnt[p];
            }
        }
    }

    for(int i = 1; i <= n; i++){
        cout<<res[i]<<" ";
    }

}

int main(){
    SPEED;
    make();

    //cin>>test_cases;
    foo(i,1,test_cases){
        MAIN(i);
    }
}

Measured memory_bytes: 21144