Problem:
Score : 400 points

Problem Statement

There are N cities. There are also K roads and L railways, extending between the cities.
The i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities.
No two roads connect the same pair of cities. Similarly, no two railways connect the same pair of cities.

We will say city A and B are connected by roads if city B is reachable from city A by traversing some number of roads. Here, any city is considered to be connected to itself by roads.
We will also define connectivity by railways similarly.

For each city, find the number of the cities connected to that city by both roads and railways.

Constraints

2 ≦ N ≦ 2*10^5

1 ≦ K, L≦ 10^5

1 ≦ p_i, q_i, r_i, s_i ≦ N

p_i < q_i

r_i < s_i

When i ≠ j, (p_i, q_i) ≠ (p_j, q_j)

When i ≠ j, (r_i, s_i) ≠ (r_j, s_j)

Input

The input is given from Standard Input in the following format:

N K L
p_1 q_1
:
p_K q_K
r_1 s_1
:
r_L s_L

Output

Print N integers. The i-th of them should represent the number of the cities connected to the i-th city by both roads and railways.

Sample Input 1

4 3 1
1 2
2 3
3 4
2 3

Sample Output 1

1 2 2 1

All the four cities are connected to each other by roads.

By railways, only the second and third cities are connected. Thus, the answers for the cities are 1, 2, 2 and 1, respectively.

Sample Input 2

4 2 2
1 2
2 3
1 4
2 3

Sample Output 2

1 2 2 1

Sample Input 3

7 4 4
1 2
2 3
2 5
6 7
3 5
4 5
3 4
6 7

Sample Output 3

1 1 2 1 2 2 2

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define dump(x)  cout << #x << " = " << (x) << endl;

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

vector<set<ll>> compK;
vector<set<ll>> compL;
ll cK[200005];
ll cL[200005];

void initDSU(ll n){
    rp(i,n) {
        set<ll> temp;
        temp.insert(i);
        compK.pb(temp);
        compL.pb(temp);
        cK[i] = i;
        cL[i] = i;
    }
}

ll getKomp(ll x){
    if(cK[x] == x) return x;
    else return cK[x] = getKomp(cK[x]);
}

ll getLomp(ll x){
    if(cL[x] == x) return x;
    else return cL[x] = getLomp(cL[x]);
}

void updateK(ll a, ll b){
    ll aP = getKomp(a);
    ll bP = getKomp(b);
    if(aP == bP) return;
    if(compK[aP].size() < compK[bP].size())
        swap(a,b);
    compK[aP].insert(compK[bP].begin(),compK[bP].end());
    cK[bP] = cK[aP];
}

void updateL(ll a, ll b){
    ll aP = getLomp(a);
    ll bP = getLomp(b);
    if(aP == bP) return;
    if(compL[aP].size() < compL[bP].size())
        swap(a,b);
    compL[aP].insert(compL[bP].begin(),compL[bP].end());
    cL[bP] = cL[aP];
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(0);
    cout << std::fixed;

    ll n,k,l;
    cin >> n >> k >> l;
    initDSU(n);
    vpl ks(k,mp(0,0));
    vpl ls(l,mp(0,0));
    ll x,y;
    rp(i,k) {
        cin >>x>>y;
        x--;y--;
        updateK(x,y);
    }
    rp(i,l) {
        cin >>x>>y;
        x--;y--;
        updateL(x,y);
    }

    map<pl,ll> mapik;
    cout <<"fuck you"<<endl;
    return 0;
    rp(i,n){
        ll kP = getKomp(i);
        ll lP = getLomp(i);
        auto it = mapik.find(mp(kP,lP));
        if(it != mapik.end()){
            cout << it->second << " ";
        } else {
            vl res;
            set_intersection(compK[getKomp(i)].begin(),compK[getKomp(i)].end(),compL[getLomp(i)].begin(),compL[getLomp(i)].end(), back_inserter(res));
            cout << res.size() << " ";
            mapik[mp(kP,lP)] = res.size();
        }
    }
    cout << "\n";

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343