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

#include <string.h>

#include <stdio.h>

#include <queue>

#include <vector>

#include <map>

#include <algorithm>

using namespace std;

const int Max=3e5+100;

int get_root(int *f, int root){

    return f[root]==root?root:f[root]=get_root(f, f[root]);

}

void merge(int *f, int x,int y){

    int i=get_root(f, x);

    int j=get_root(f, y);

    f[i]=j;

}

int f[Max], g[Max];

void init(int n){

    for(int a=0; a<=n; a++)f[a]=a, g[a]=a;

}

int vis[Max], num[Max];

vector<int> vec[Max];

map<int, int>ma;

int main(){

    int n, m, k, u, v;

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

    init(n);

    for(int a=0; a<m; a++){

        scanf("%d%d", &u, &v);

        merge(f, u, v);

    }

    for(int a=0; a<k; a++){

        scanf("%d%d", &u, &v);

        merge(g, u, v);

    }

    for(int a=1; a<=n; a++)vec[get_root(f, a)].push_back(a);

    for(int a=0; a<=n; a++){

        ma.clear();

       // memset(num, 0, sizeof(num));

        for(int b=0; b<vec[a].size(); b++){

            ma[get_root(g, vec[a][b])]++;

            //num[get_root(g, vec[a][b])]++;

        }

        for(int b=0; b<vec[a].size(); b++){

            vis[vec[a][b]]+=ma[get_root(g, vec[a][b])];

        }

    }

    for(int a=1; a<=n; a++)printf("%d%c", vis[a], a==n?'\n':' ');

    return  0;

}

// Faster C++ solution for the same problem (measured speedup: 9.168563681450012x):
//### In The Name Of GOD ###



// %% Remember; (((He))) is The (((Accepter))) %%



#include <bits/stdc++.h>



using namespace std;



typedef long long ll ;

typedef long double ld ;



#define int ll

#define pb push_back

#define bp pop_back

#define pf push_front

#define fp pop_front

#define X first

#define Y second

#define IO ios_base::sync_with_stdio(false);

#define sz(a) (int)(a.size())

#define sg(a, b) (a + b - 1) / b



const int MOD = 1000 * 1000 * 1000 + 7;

const int INF = 2 * 1000 * 1000 + 200;

const int MAXN = 2 * 1000 * 100 + 20;

const int MLOG = 18;

const int NMAX = 1 * 1000;



int ps[MAXN][2], fath[MAXN][2], num[MAXN][2];



int fad(int x, int b){

  if(fath[x][b] == x) return x;

  else return fad(fath[x][b], b);

}



void mrg(int x, int y, int b){

  if(x == y) return ;

  if(ps[x][b] > ps[y][b]){

    fath[y][b] = x;

    num[x][b] += num[y][b];

  }else if(ps[x][b] == ps[y][b]){

    fath[y][b] = x;

    ps[x][b]++;

    num[x][b] += num[y][b];

  }else{

    fath[x][b] = y;

    num[y][b] += num[x][b];

  }

}



signed main(){

  IO;

  int n, rah, gat, a, b;

  cin >> n >> rah >> gat;

  // cout << "a";

  for(int i = 0; i < n + 20; i++){

    // cout << "b";

    fath[i][0] = i;

    num[i][0] = 1;

    fath[i][1] = i;

    num[i][1] = 1;

  }

  for(int i = 0; i < rah; i++){

    cin >> a >> b;a--;b--;

    // cout << "x" << endl;

    mrg(fad(a, 0), fad(b, 0), 0);

  }

  for(int i = 0; i < gat; i++){

    cin >> a >> b;a--;b--;

    // if(fad(a, 0) == fad(b, 0)){

      mrg(fad(a, 1), fad(b, 1), 1);

    // }

    // cout << "y";

  }

  map<pair<int, int>, int> h;

  for(int i = 0; i < n; i++){

    h[{fad(i, 1),fad(i, 0)}]++;

  }

  for(int i = 0; i < n; i++){

    cout << h[{fad(i, 1),fad(i, 0)}] << ' ';

  }

}