#include <iostream>
#include <cstdio>
#include <bitset>
#include <map>
using namespace std;
typedef long long LL;
const int maxn = 4e5 + 8;

//有时可能需要 并查集+离散化


int father[maxn], _rank[maxn];
inline void DisjointSet(int n)
{
    for(int i = 0; i <= n; i++){
        father[i] = i;
        _rank[i] = 0;
    }
}

inline int _find(int v)
{
    return father[v] = father[v] == v ? v : _find(father[v]);
    //同时压缩路径，有时不能压缩路径，有时必须压缩路径，看具体情况
}

inline void _merge(int x, int y)
{
    int a = _find(x), b = _find(y);                //
    if(_rank[a] < _rank[b]){
        father[a] = b;
    }
    else{
        father[b] = a;
        if(_rank[a] == _rank[b]){
            _rank[a]++;
        }
    }
}


int father1[maxn], _rank1[maxn];
inline void DisjointSet1(int n)
{
    for(int i = 0; i <= n; i++){
        father1[i] = i;
        _rank1[i] = 0;
    }
}

inline int _find1(int v)
{
    return father1[v] = father1[v] == v ? v : _find1(father1[v]);
    //同时压缩路径，有时不能压缩路径，有时必须压缩路径，看具体情况
}

inline void _merge1(int x, int y)
{
    int a = _find1(x), b = _find1(y);                //
    if(_rank1[a] < _rank1[b]){
        father1[a] = b;
    }
    else{
        father1[b] = a;
        if(_rank1[a] == _rank1[b]){
            _rank1[a]++;
        }
    }
}


map<int, bitset<200008>> mp1, mp2;

int main()
{
    #ifdef LOCAL
    freopen("a.txt", "r", stdin);
    //freopen("a.out", "w", stdout);
    int T = 4;
    while(T--){
    #endif // LOCAL
    ios::sync_with_stdio(false); cin.tie(0);


    int n, p, q, u, v;
    cin >> n >> p >> q;
    DisjointSet(n), DisjointSet1(n);
    while(p--){
        cin >> u >> v;
        if(_find(u) != _find(v)) _merge(_find(u), _find(v));
    }

    while(q--){
        cin >> u >> v;
        if(_find1(u) != _find1(v)) _merge1(_find1(u), _find1(v));
    }

    for(int i = 1; i <= n; i++){
        mp1[_find(i)][i-1] = 1;
    }
    for(int i = 1; i <= n; i++){
        mp2[_find1(i)][i-1] = 1;
    }

    bitset<200008> t;
    for(int i = 1; i <= n; i++){
        t = mp1[_find(i)] & mp2[_find1(i)];
        if(i == 1) cout << t.count();
        else cout << " " << t.count();
    }
    cout << endl;

    #ifdef LOCAL
    mp1.clear();
    mp2.clear();
    cout << endl;
    }
    #endif // LOCAL
    return 0;
}

