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: mport sys
  sys.setrecursionlimit(10**5)
  def 解():
      iN,iK,iL = [int(_) for _ in input().split()]
      aD = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
      a道 = aD[0:iK]
      a鉄道 = aD[iK:]
  
      d道 = {}
      d鉄道 = {}
  #   for i in range(1,iN+1):
  #       d道[i] = {i}
  #       d鉄道[i] ={i}
      def fMakeSet(d,x,y):
          if x in d:
              d[x].add(y)
          else:
              d[x] = {y}
  
      for p,q in a道:
          #d道[p].add(q)
          #d道[q].add(p)
          fMakeSet(d道,q,p)
          fMakeSet(d道,p,q)
      for r,s in a鉄道:
          fMakeSet(d鉄道,r,s)
          fMakeSet(d鉄道,s,r)
  
      def fdfs(d,iS):
          dsVisited=set()
          def digRoute(iT):
              dsVisited.add(iT)
              if iT in d:
                  for i in d[iT] - dsVisited:
                      #dsVisited.add(i)
                      digRoute(i)
          digRoute(iS)
          return dsVisited
      def buildGroup(d):
          gl = {}
          gidx = {}
          v = set()
          iC = 0
          for i in range(1,iN+1):
              if i in v:
                  continue
              else:
                  dsList = fdfs(d,i)
                  for i in dsList:
                      gidx[i] = iC
                  gl[iC]=dsList
                  iC += 1
                  v = v | dsList
          return (gl,gidx)
      dg鉄道,idxdg鉄道 = (buildGroup(d鉄道))
      dg道,idxdg道 = (buildGroup(d道))
      ak鉄道 = dg鉄道.keys()
      ak道 = dg道.keys()
      aM = [[ None for _ in range(len(ak道))] for _ in range(len(ak鉄道))]
      for i in ak鉄道:
          for j in ak道:
              aM[i][j]=len(dg鉄道[i] & dg道[j])
      aRet = []
      for i in range(1,iN+1):
          aRet.append(str(aM[idxdg鉄道[i]][idxdg道[i]]))
      print( " ".join(aRet))
  解()
  
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"}]