#include <bits/stdc++.h>
using namespace std;

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const ll mod = 1777777777ll;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

struct UnionFind
{
  vector<int> par;
  vector<int> siz;
  UnionFind(int N) : par(N), siz(N, 1) {for (int i = 0; i < N; i++) par[i] = i;}
  void init(int N) {
    siz.assign(N, 1);
    par.resize(N);
    for(int i = 0; i < N; ++i) par[i] = i;
  }
  int root(int x) {
    while(par[x] != x) {x = par[x] = par[par[x]];}
    return x;
  }
  bool unite(int x, int y)
  {
    x = root(x);
    y = root(y);
    if(x == y) return false;
    if(siz[x] < siz[y]) swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }
  bool isSame(int x, int y) {return root(x) == root(y); }
  int size(int x) { return siz[root(x)]; }
};
int main()
{
  int n, k, l;
  cin >> n >> k >> l;
  UnionFind train(n+1), road(n+1);
  rep(i, k) {
    int a, b; cin >> a >> b;
    train.unite(a, b);
  }
  rep(i, l) {
    int a, b; cin >> a >> b;
    road.unite(a, b);
  }
  
  map<int, vector<int>> g;
  for(int i = 1; i <= n; ++i) g[train.root(i)].push_back(i);
  vector<bool> flag(n+1, false);
  UnionFind ans(n+1);

  for(auto x : g) {
    for(int i = 0; i < SZ(x.second)-1; ++i) {
      int a = x.second[i];
      if(flag[a]) continue;
      if(road.size(a) == 1) continue;
      for(int j = i+1; j < SZ(x.second); ++j) {
        int b = x.second[j];
        if(flag[b]) continue;
        if(road.isSame(a, b)) {
          ans.unite(a, b);
          flag[b] = true;
        }
      }
    }
  }
  vector<int> res;
  for(int i = 1; i <= n; ++i) res.push_back(ans.size(i));
  line_out(res);
}

Measured memory_bytes: 29120