/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1;
const double eps = 1e-6, ldeps = 1e-9;
struct Dbg {
static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto dud(C *x)->decltype(os << *x, 0);
template<class C> static char dud(...);
template<class C> typename enable_if<sizeof dud<C>(0)!=1, Dbg&>::type operator<<(const C &x) { os << x; return *this; }
template<class C> Dbg &dump(C b, C e) {
    *this << "\n[";
    int cur = 0;
    for (C i = b; i!=e and cur<26; i++, cur++) *this << ", "+2*(i==b) << *i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof dud<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator <<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator <<(const pair<B, C> &x) {
    return *this << '{' << x.first << ", " << x.second << '}';
}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = 200005;

class DSU//{
{
    vector<int> dsupar;
public:
    int cntDSU;
    vector<int> siz;

    void reset(int nd) {
        for (int i = 0; i <= nd; i++) dsupar[i] = i, siz[i] = 1;
        cntDSU = nd;
    }

    DSU(int N, int noOfSets = -1) {
        dsupar.resize(N+5), siz.resize(N+5);
        reset(N+4);
        cntDSU = noOfSets==-1 ? N : noOfSets;
    }

    int find(int x) {
        return dsupar[x]==x ? x : dsupar[x] = find(dsupar[x]);
    }

    void union_(int u, int v) {
        if ((u = find(u))==(v = find(v))) return;
        if (siz[u]<siz[v]) swap(u, v);
        dsupar[v] = u, siz[u] += siz[v], siz[v] = 0;
        cntDSU--;
    }
};//}

int n, K, L;
DSU dsuRoad(mxn), dsuRail(mxn);
pair<pair<int, int>, int> a[mxn];
int ans[mxn];

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11);
    cin >> n >> K >> L;
    for (int i = 0; i < K; i++) {
        int u, v;
        cin >> u >> v;
        dsuRoad.union_(u, v);
    }
    for (int i = 0; i < L; i++) {
        int u, v;
        cin >> u >> v;
        dsuRail.union_(u, v);
    }

    for (int i = 1; i <= n; i++) {
        a[i] = {{dsuRoad.find(i), dsuRail.find(i)}, i};
    }

    sort(a+1, a+1+n);
    for (int i = 1, strt = 1; i <= n; i++) {
        if (i != n and a[i].first == a[i+1].first) continue;
        for (int j = strt; j <= i; j++) {
            ans[a[j].second] = i-strt+1;
        }
        strt = i+1;
    }

    for (int i = 1; i <= n; i++) {
        cout << ans[i] << " \n"[i == n];
    }
}

Measured memory_bytes: 7040