#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using pii = pair<int,int>;
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  bool same(int x, int y){
    return (find(x)==find(y));
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};


int N,K,L;
vector<int> P,Q,R,S;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N >> K >> L;
    for (int i = 0; i < K; i++)
    {
        int p,q; cin >> p >> q;
        p--,q--;
        P.push_back(p);
        Q.push_back(q);
    }
    for (int i = 0; i < L; i++)
    {
        int r,s; cin >> r >> s;
        r--,s--;
        R.push_back(r);
        S.push_back(s);
    }
    
    
}

int wrong_solve(){
    UnionFind uf_road(N);
    UnionFind uf_ans(N);
    for (int i = 0; i < K; i++) uf_road.unite(P[i],Q[i]);
    for (int i = 0; i < L; i++)
        if(uf_road.same(R[i],S[i])) uf_ans.unite(R[i],S[i]);
    DBG(uf_road.data)
    DBG(uf_ans.data)
    vector<int> ans;
    for (int i = 0; i < N; i++)
        ans.push_back(uf_ans.size(i));

    for(int a:ans) cout << a << " ";
    cout << "\n";
    return 0;
}   

int solve(){
    UnionFind uf_road(N);
    UnionFind uf_train(N);
    for (int i = 0; i < K; i++) uf_road.unite(P[i],Q[i]);
    for (int i = 0; i < L; i++) uf_train.unite(R[i],S[i]);
    DBG(uf_road.data)
    DBG(uf_train.data)

    vector<pii> ans;
    map<pii,int> cnt;
    for (int i = 0; i < N; i++)
    {
        int a=uf_road.find(i);
        int b=uf_train.find(i);
        ans.emplace_back(a,b);
        cnt[{a,b}]++;
    }
    
    for(pii a:ans) cout << cnt[a] << " ";
    cout << "\n";
    return 0;
}   


int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 16748