/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 200005;
const ll mm = 1e+18;
vector<int>gr[2][N];
set<int>s[2][N];
int vis[2][N];
int wh[2][N];
void dfs(int x,int he,int w){
    wh[x][he]=w;
    s[x][w].insert(he);
    vis[x][he]=1;
    for(auto y:gr[x][he]){
        if(!vis[x][y]) dfs(x,y,w);
    }
}
int f(int x,int y){
    vector<int>v;
    if((int)(s[0][x].si)<(int)(s[1][y].si)){
        for(auto z:s[0][x]){
            if(s[1][y].find(z)!=s[1][y].en){
                v.pb(z);
            }
        }
    }
    else{
        for(auto z:s[1][y]){
            if(s[0][x].find(z)!=s[0][x].en){
                v.pb(z);
            }
        }
    }
    for(auto z:v){
        s[0][x].erase(z);
        s[1][y].erase(z);
    }
    return (int)(v.si);
}
void solve()
{
    int n,k,l;
    cin>>n>>k>>l;
    rep0(i,k){
        int x,y;
        cin>>x>>y;
        gr[0][x].pb(y);
        gr[0][y].pb(x);
    }
    rep0(i,l){
        int x,y;
        cin>>x>>y;
        gr[1][x].pb(y);
        gr[1][y].pb(x);
    }
    rep0(i,2){
        int cu=0;
        rep1(j,n){
            if(!vis[i][j]){
                dfs(i,j,cu);
                cu++;
            }
        }
    }
    map<pair<int,int>,int>mp;
    rep1(i,n){
        auto it=mp.find({wh[0][i],wh[1][i]});
        if(it!=mp.end()){
            cout<<it->s<<" ";
            continue;
        }
        else{
            int x=f(wh[0][i],wh[1][i]);
            cout<<x<<" ";
            mp.in({{wh[0][i],wh[1][i]},x});
        }
    }
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 63240