#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

// Manages Union-Find Forest.
class UnionFindForest {
  std::vector<int> parent_;
  std::vector<int> rank_;
  std::vector<int> size_;

 public:
  // Initialize forest.
  // parent_[i]=i, rank_[i]=0, size_[i]=1.
  UnionFindForest(const int &n);
  // Get the number of the root of the node q.
  int Root(const int &q);
  // Return true if the roots of x and y is same.
  bool IsSame(const int &x, const int &y);
  // Unite the tree x and tree y.
  void Unite(int x, int y);
  // Get the number of nodes which are the same group as node q.
  int Size(const int &q);
};
UnionFindForest::UnionFindForest(const int &n) {
  parent_.resize(n);
  rank_.resize(n);
  size_.resize(n);
  for (int i = 0; i < n; i++) {
    parent_[i] = i;
    rank_[i]   = 0;
    size_[i]   = 1;
  }
}
int UnionFindForest::Size(const int &q) {
  return size_[Root(q)];
}

int UnionFindForest::Root(const int &q) {
  if (parent_[q] == q) {
    return q;
  } else {
    return parent_[q] = Root(parent_[q]);
  }
}

bool UnionFindForest::IsSame(const int &x, const int &y) {
  return Root(x) == Root(y);
}

void UnionFindForest::Unite(int x, int y) {
  x = Root(x);
  y = Root(y);
  if (x == y) return;
  if (rank_[x] < rank_[y]) {
    parent_[x] = y;
    size_[y] += size_[x];
    size_[x] = 0;

  } else {
    parent_[y] = x;
    size_[x] += size_[y];
    size_[y] = 0;
    if (rank_[x] == rank_[y]) rank_[x]++;
  }
}

struct Node {
  int root_road;
  int root_rail;
  int number;
  const bool operator==(const Node &a) {
    if (root_rail == a.root_rail && root_road == a.root_road) {
      return true;
    } else {
      return false;
    }
  }
  const bool operator<(const Node &a) {
    if (root_road == a.root_road) {
      return root_rail < a.root_rail;
    } else {
      return root_road < a.root_road;
    }
  }
  const bool operator>(const Node &a) {
    if (root_road == a.root_road) {
      return root_rail > a.root_rail;
    } else {
      return root_road > a.root_road;
    }
  }
};

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n, k, l;
  cin >> n >> k >> l;
  std::unordered_set<int> road_connection[200001], rail_connection[200001];
  for (int i = 0; i < k; i++) {
    int p, q;
    cin >> p >> q;
    road_connection[p].insert(q);
    road_connection[q].insert(p);
  }
  for (int i = 0; i < l; i++) {
    int p, q;
    cin >> p >> q;
    rail_connection[p].insert(q);
    rail_connection[q].insert(p);
  }

  UnionFindForest uf_road(n + 1);
  for (int i = 1; i <= n; i++) {
    for (auto x : road_connection[i]) {
      uf_road.Unite(i, x);
    }
  }
  UnionFindForest uf_rail(n + 1);

  for (int i = 1; i <= n; i++) {
    for (auto x : rail_connection[i]) {
      uf_rail.Unite(i, x);
    }
  }
  std::vector<Node> set;
  for (int i = 1; i <= n; i++) {
    Node node;
    node.number    = i;
    node.root_rail = uf_rail.Root(i);
    node.root_road = uf_road.Root(i);
    set.push_back(node);
  }
  std::sort(set.begin(), set.end());
  UnionFindForest uf_twin(n + 1);
  for (int i = 0; i < n - 1; i++) {
    if (set[i] == set[i + 1]) {
      uf_twin.Unite(set[i].number, set[i + 1].number);
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << uf_twin.Size(i) << " ";
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 51696