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: # -*- coding: utf-8 -*-
  import bisect
  import heapq
  import math
  import random
  import sys
  from collections import Counter, defaultdict, deque
  from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
  from functools import lru_cache, reduce
  from itertools import combinations, combinations_with_replacement, product, permutations
  from operator import add, mul, sub
  
  sys.setrecursionlimit(10000)
  
  
  def read_int():
      return int(input())
  
  
  def read_int_n():
      return list(map(int, input().split()))
  
  
  def read_float():
      return float(input())
  
  
  def read_float_n():
      return list(map(float, input().split()))
  
  
  def read_str():
      return input()
  
  
  def read_str_n():
      return list(map(str, input().split()))
  
  
  def error_print(*args):
      print(*args, file=sys.stderr)
  
  
  def mt(f):
      import time
  
      def wrap(*args, **kwargs):
          s = time.time()
          ret = f(*args, **kwargs)
          e = time.time()
  
          error_print(e - s, "sec")
          return ret
  
      return wrap
  
  
  @mt
  def slv(N, K, L, PQ, RS):
      ans = 0
      gr = defaultdict(list)
      for p, q in PQ:
          gr[p].append(q)
          gr[q].append(p)
  
      gt = defaultdict(list)
      for r, s in RS:
          gt[r].append(s)
          gt[s].append(r)
  
      ccr = {}
      unused = set(gr.keys())
      while unused:
          q = [unused.pop()]
          con = set([])
          while q:
              v = q.pop()
              con.add(v)
              for u in gr[v]:
                  if u in unused:
                      q.append(u)
                      unused.remove(u)
          for v in con:
              ccr[v] = con
  
      cct = {}
      unused = set(gt.keys())
      while unused:
          q = [unused.pop()]
          con = set([])
          while q:
              v = q.pop()
              con.add(v)
              for u in gt[v]:
                  if u in unused:
                      q.append(u)
                      unused.remove(u)
          for v in con:
              cct[v] = con
  
      cache = {}
  
      def cc(t, r):
          k = (id(t), id(r))
          if k not in cache:
              cache[k] = len(t & r)
          return cache[k]
  
      ans = []
      for i in range(1, N + 1):
          if i in cct and i in ccr:
              a = cc(cct[i], ccr[i])
          else:
              a = 1
          ans.append(a)
      return " ".join(map(str, ans))
  
  
  def main():
      N, K, L = read_int_n()
      PQ = [read_int_n() for _ in range(K)]
      RS = [read_int_n() for _ in range(L)]
  
      print(slv(N, K, L, PQ, RS))
  
  
  if __name__ == "__main__":
      main()
  
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"}]