output_description: 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.
  
  * * *
input_description: 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
attempt: import sys
  
  sys.setrecursionlimit(4100000)
  
  import math
  
  import logging
  
  logging.basicConfig(level=logging.DEBUG)
  
  logger = logging.getLogger(__name__)
  
  from unionfind import UnionFind, UnionFindCounter
  
  
  def resolve():
      # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
      # N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
      N, K, L = [int(x) for x in sys.stdin.readline().split()]  # 複数int
      # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
      grid = [
          [int(x) - 1 for x in sys.stdin.readline().split()] for _ in range(K + L)
      ]  # int grid
  
      logger.debug("{}".format([]))
  
      p_uf = UnionFind(N)
      r_uf = UnionFind(N)
      both_uf = UnionFindCounter(N)
  
      for k in range(K):
          p, q = grid[k]
          p_uf.unite(p, q)
  
      for l in range(K, K + L):
          r, s = grid[l]
          r_uf.unite(r, s)
          if p_uf.isSame(r, s):
              both_uf.unite(r, s)
  
      print(" ".join([str(x) for x in both_uf.getCount()]))
  
  
  if __name__ == "__main__":
      resolve()
  
  # AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
  # python -m unittest template/template.py で実行できる
  # pypy3 -m unittest template/template.py で実行できる
  
  import sys
  from io import StringIO
  import unittest
  
  
  class TestClass(unittest.TestCase):
      def assertIO(self, input, output):
          stdout, stdin = sys.stdout, sys.stdin
          sys.stdout, sys.stdin = StringIO(), StringIO(input)
          resolve()
          sys.stdout.seek(0)
          out = sys.stdout.read()[:-1]
          sys.stdout, sys.stdin = stdout, stdin
          self.assertEqual(out, output)
  
      def test_入力例_1(self):
          input = """4 3 1
  1 2
  2 3
  3 4
  2 3"""
          output = """1 2 2 1"""
          self.assertIO(input, output)
  
      def test_入力例_2(self):
          input = """4 2 2
  1 2
  2 3
  1 4
  2 3"""
          output = """1 2 2 1"""
          self.assertIO(input, output)
  
      def test_入力例_3(self):
          input = """7 4 4
  1 2
  2 3
  2 5
  6 7
  3 5
  4 5
  3 4
  6 7"""
          output = """1 1 2 1 2 2 2"""
          self.assertIO(input, output)
  
      def test_入力例_4(self):
          input = """2 1 1
  1 2
  1 2"""
          output = """2 2"""
          self.assertIO(input, output)
  
problem_description: 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.
samples: [{"input": "4 3 1\n    1 2\n    2 3\n    3 4\n    2 3", "output": "1 2 2 1\n    \n\nAll the four cities are connected to each other by roads.\n\nBy railways, only the second and third cities are connected. Thus, the answers\nfor the cities are 1, 2, 2 and 1, respectively.\n\n* * *"}, {"input": "4 2 2\n    1 2\n    2 3\n    1 4\n    2 3", "output": "1 2 2 1\n    \n\n* * *"}, {"input": "7 4 4\n    1 2\n    2 3\n    2 5\n    6 7\n    3 5\n    4 5\n    3 4\n    6 7", "output": "1 1 2 1 2 2 2"}]