#include<bits/stdc++.h>

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007
void printbit(int u){if(u==0)cout<<0;else{int s=0,k=0;for(;0<u;u>>=1,k++)s=(s<<1)|(u&1);for(;0<k--;s>>=1)cout<<(s&1);}}

#define TIME chrono::system_clock::now()
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

template<typename T1,typename T2>
ostream& operator <<(ostream &o,const pair<T1,T2> p){o<<"("<<p.first<<":"<<p.second<<")";return o;}

struct unionfind {
    vector<int> data;
    unionfind(int size) : data(size, -1) { }
    bool union_set(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool find_set(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

struct qunionfind{
    vector<vector<int>> toItems; // MEMO:何故かdequeになってた
    vector<int> data;
    
    qunionfind(int size) : data(size, -1) { 
        toItems.resize(size);
        for (int i=0;i<size;i++){
            toItems[i].emplace_back(i);
        }
    }
    bool union_set(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            toItems[x].insert(toItems[x].end(),ALL(toItems[y]));
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    inline bool find_set(int x, int y) {
        return root(x) == root(y);
    }
    inline int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    inline int size(int x) {
        return -data[root(x)];
    }
};



int width,height;
int n,kei,el;

string str;

int roadstack[100010][2];
int trainstack[100010][2];

int main(){
    int i,j,k;
    int x,y,a,b;
    
    cin >> n >> kei >> el;
    
    //qunionfind uf(n+10);
    
    unionfind ufroad(n+10);
    unionfind uftrain(n+10);
    
    for (i=0;i<kei;i++){
        scanf("%d%d",&a,&b); // a<b
        //roadstack[i][0]=a;
        //roadstack[i][1]=b;
        ufroad.union_set(a,b);
    }
    for (i=0;i<el;i++){
        scanf("%d%d",&a,&b); // a<b
        //trainstack[i][0]=a;
        //trainstack[i][1]=b;
        uftrain.union_set(a,b);
    }
    
    map<pair<int,int>,int> tr;
    
    for (i=1;i<=n;i++){
        tr[make_pair(uftrain.root(i),ufroad.root(i))]++;
    }
    
    
    for (i=1;i<=n;i++){
        printf("%d ",tr[make_pair(uftrain.root(i),ufroad.root(i))]);
    }
    cout << endl;
    
    
    return 0;
}

Measured memory_bytes: 13568