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

using namespace std;

#define INF 0x3f3f3f3f

#define maxn 212345

#define met(a, b) memset(a, b, sizeof(a))

class UMS

{

public:

    int f[maxn];

    UMS()

    {

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

        {

            f[i] = i;

        }

    }

    int getf(int u)

    {

        if(u == f[u])

            return f[u];

        else

        {

            f[u] = getf(f[u]);

            return f[u];

        }

    }

    void Merge(int u, int v)

    {

        int f1 = getf(u);

        int f2 = getf(v);

        if(f1 != f2)

        {

            f[f1] = f2;

        }

    }

};

vector<int> vec[maxn];

map<int, int> q;

int main()

{

    UMS u1, u2;

    int n, k, l, u, v;

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

    while(k--)

    {

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

        u1.Merge(u, v);

    }

    while(l--)

    {

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

        u2.Merge(u, v);

    }

    int vis[maxn];

    met(vis, 0);

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

    {

        int fa = u1.getf(i);

        vec[fa].push_back(i);

    }

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

    {

        q.clear();

        for(int j = 0; j < vec[i].size(); j++)

        {

            q[u2.getf(vec[i][j])] ++;

        }

        for(int j = 0; j < vec[i].size(); j++)

        {

            vis[vec[i][j]] += q[u2.getf(vec[i][j])];

        }



    }

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

    {

        printf("%d", vis[i]);

        if(i == n) printf("\n");

        else printf(" ");

    }

    return 0;

}


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

}