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

#include <iostream>

#include <iomanip>

#include <cstring>

#include <string>

#include <vector>

#include <queue>

#include <cmath>

using namespace std;



const int MAXN = 200000 + 10;

const int MAXL = 100000 + 10;



struct DSU

{

    int fa[MAXN];



    int find(int x)

    {

        if(x == fa[x])

            return x;

        return fa[x] = find(fa[x]);

    }



    void merge(int x, int y)

    {

        fa[find(x)] = find(y);

    }

}d1, d2;



int tmp[MAXN], ans[MAXN], cnt[MAXN];



void init(DSU & d)

{

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

        d.fa[i] = i;

}



int N, K, L;

int main()

{

    init(d1);

    init(d2);

    int u, v;

    cin >> N >> K >> L ;



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

        cin >> u >> v, d1.merge(u, v);

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

        cin >> u >> v, d2.merge(u, v);



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

        d1.fa[i] = d1.find(i),

        d2.fa[i] = d2.find(i);

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

        tmp[i] = i;

    sort(tmp+1, tmp+N+1, [](int x, int y)-> bool {return d1.fa[x] < d1.fa[y];});





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

    {

        int j = i;

        while(j < N && d1.fa[tmp[j]] == d1.fa[tmp[j+1]])

            j++;



        for(int t = i; t <= j; t++)

            cnt[d2.fa[tmp[t]]]++;

        for(int t = i; t <= j; t++)

            ans[tmp[t]] = cnt[d2.fa[tmp[t]]];

        for(int t = i; t <= j; t++)

            cnt[d2.fa[tmp[t]]]--;

        i = j ;

    }



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

        cout << ans[i] << " " ;



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 2.606259320481218x):
#include<bits/stdc++.h>

using namespace std;

int Arr[ 200005 ] , Brr[ 200005 ];

int A[ 200005 ] , B[ 200005 ];



void _init( int a )

{

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

    {

        Arr[ i ] = Brr[ i ] = i;

    }

}



int _roadfp( int a )

{

    if( Arr[ a ] == a )

        return a;

    return Arr[ a ] = _roadfp( Arr[ a ] );

}



int _railfp( int a )

{

    if( Brr[ a ] == a )

        return a;

    return Brr[ a ] = _railfp( Brr[ a ] );

}



void _roaduni( int x , int y )

{

    int u = _roadfp( x );

    int v = _roadfp( y );



    if( u != v )

    {

        Arr[ v ] = u;

    }

}



void _railuni( int x , int y )

{

    int u = _railfp( x );

    int v = _railfp( y );



    if( u != v )

    {

        Brr[ v ] = u;

    }

}



int main()

{

    int n , k , l;

    cin >> n >> k >> l;

    _init( n );



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

    {

        int a , b;

        cin >> a >> b;

        _roaduni( a , b );

    }



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

    {

        int a , b;

        cin >> a >> b;

        _railuni( a , b );

    }



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

    {

        _roadfp( i );

        _railfp( i );

    }



    map < pair<int,int> , int > M;



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

    {

        // cout << Arr[ i ] << "  " << Brr[ i ] << endl;

        M[ { Arr[ i ] , Brr[ i ] }  ] ++;

    }

//

//    for( auto it : M )

//    {

//        cout << it.first.first << " " << it.first.second << endl;

//        cout << it.second << endl;

//    }



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

    {

        printf("%d " , M[ { Arr[ i ] , Brr[ i ] } ] );

    }

    printf("%d\n" , M[ { Arr[ n ] , Brr[ n ] } ] );

    return 0;

}