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: class Node:
      def __init__(self, value):
          self.value = value
          self.connect = []
          self.visited = False
  
      def getConnect(self):
          return self.connect
  
      def setConnect(self, connects):
          self.connect = connects
  
      def getConnectValues(self):
          res = []
          for node in self.connect:
              res.append(node.getValue())
          return res
  
      def getValue(self):
          return self.value
  
      def addConnect(self, connectNode):
          self.connect.append(connectNode)
  
      def addConnects(self, connectNodes):
          self.connect += connectNodes
  
      def visitAll(self):
          self.visited = True
          for i in range(len(self.connect)):
              if self.connect[i].visited:
                  continue
              else:
                  self.connect[i].visitAll()
  
  
  def computeAllConnects(node, list1):
      node.visitAll()
      res = []
      for i in range(1, len(list1)):
          if list1[i].visited:
              res.append(list1[i])
      node.setConnect(res)
      refreshVisited(list1)
  
  
  def refreshVisited(list1):
      for i in range(1, len(list1)):
          list1[i].visited = False
  
  
  def computeDuplicate(list1, list2):
      res = []
      for i in list1:
          if i in list2:
              res.append(i)
      return res
  
  
  line1 = input()
  line1 = line1.split(" ")
  numCities = int(line1[0])
  numRoads = int(line1[1])
  numRails = int(line1[2])
  
  road = [0]
  rail = [0]
  res = [0]
  
  for i in range(1, numCities + 1):
      road.append(Node(i))
      rail.append(Node(i))
  
  for i in range(numRoads):
      lineI = input().split(" ")
      city1 = road[int(lineI[0])]
      city2 = road[int(lineI[1])]
      city1.addConnect(city2)
      city2.addConnect(city1)
  
  for i in range(numRails):
      lineI = input().split(" ")
      city1 = rail[int(lineI[0])]
      city2 = rail[int(lineI[1])]
      city1.addConnect(city2)
      city2.addConnect(city1)
  
  for i in range(1, numCities + 1):
      computeAllConnects(road[i], road)
      computeAllConnects(rail[i], rail)
  
  for i in range(1, numCities + 1):
      roadConnects = road[i].getConnectValues()
      railConnects = rail[i].getConnectValues()
      res.append(len(computeDuplicate(roadConnects, railConnects)))
  
  res = res[1:]
  
  for i in range(0, len(res) - 1):
      print(res[i], end=" ")
  print(res[len(res) - 1])
  
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"}]