// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



const int inf = 0x3f3f3f3f;

const int maxv = 200010;

const int maxe = 100010;

int vertex, RailEdge, RoadEdge, cnt;

int RailHead[maxv], RoadHead[maxv], number[maxv], ans[maxv];

bool vis[maxv];

vector <int> v[maxv];

struct Edge

{

    int to, next;

}e[maxe * 4];



void addEdge(int *head, int from, int to)

{

    e[cnt].next = head[from];

    e[cnt].to = to;

    head[from] = cnt++;

}



void getNumberDFS(int cur)

{

    vis[cur] = true;

    number[cur] = cnt;

    for (int i = RoadHead[cur]; ~i; i = e[i].next)

    {

        int to = e[i].to;

        if (!vis[to])

            getNumberDFS(to);

    }

}



vector <int> valid;



void DFS(int cur)

{

    vis[cur] = true;

    int curNumber = number[cur];

    if (v[curNumber].size() == 0)

        valid.push_back(curNumber);

    v[curNumber].push_back(cur);

    for (int i = RailHead[cur]; ~i; i = e[i].next)

    {

        if (!vis[e[i].to])

            DFS(e[i].to);

    }

}



int main()

{

    memset(RailHead, -1, sizeof(RailHead));

    memset(RoadHead, -1, sizeof(RoadHead));

    for (int i = 0; i < maxv; i++)

        ans[i] = 1;





    int from, to;

    scanf("%d %d %d", &vertex, &RoadEdge, &RailEdge);

    for (int i = 0; i < RoadEdge; i++)

    {

        scanf("%d %d", &from, &to);

        addEdge(RoadHead, from, to);

        addEdge(RoadHead, to, from);

    }

    for (int i = 0; i < RailEdge; i++)

    {

        scanf("%d %d", &from, &to);

        addEdge(RailHead, from, to);

        addEdge(RailHead, to, from);

    }

    cnt = 0;

    for (int i = 1; i <= vertex; i++)

    {

        if (!vis[i])

        {

            getNumberDFS(i);

            cnt++;

        }

    }

//    printf("number:\n");

//    for (int i = 1; i <= vertex; i++)

//        printf("%d%c", number[i], i == vertex ? '\n' : ' ');

    memset(vis, false, sizeof(vis));

    for (int i = 1; i <= vertex; i++)

    {

        if (!vis[i])

        {

            DFS(i);

            for (int i = 0; i < valid.size(); i++)

            {

                int id = valid[i];

                for (int j = 0; j < v[id].size(); j++)

                    ans[v[id][j]] += v[id].size() - 1;

                v[id].clear();

            }

            valid.clear();

        }

    }

//    printf("answer:\n");

    for (int i = 1; i <= vertex; i++)

        printf("%d%c", ans[i], i == vertex ? '\n' : ' ');

    return 0;

}

/*

7 5 5

1 2

2 3

2 5

6 7

5 6

3 5

4 5

3 4

6 7

5 6

 

 1 1 4 1 4 4 4

 */






// Faster C++ solution for the same problem (measured speedup: 9.210493315522696x):
//### 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)}] << ' ';

  }

}