input: from typing import List
  
  def count_distinct_colors(limit: int, queries: List[List[int]]) -> List[int]:
      """
      Given a number 'limit' and a two-dimensional list 'queries' with dimensions n x 2:
  
      There are balls labeled from 0 to limit, each originally without color. For each query [x, y] in the queries list, ball x is colored with color y. The task is to find the count of unique colors after processing each query.
  
      Return a list 'result' of size n, where result[i] represents the number of unique colors following the i-th query.
  
      Important:
      In a query response, colors not present on any ball are not counted.
  
      Examples:
      >>> limit = 4, queries = [[1,4],[2,5],[1,3],[3,4]]
      [1,2,2,3]
      >>> limit = 4, queries = [[0,1],[1,2],[2,2],[3,4],[4,5]]
      [1,2,2,3,4]
  
      Constraints:
      1 <= limit <= 10^9
      1 <= n == queries.length <= 10^5
      queries[i].length == 2
      0 <= queries[i][0] <= limit
      1 <= queries[i][1] <= 10^9
      """
output:     result = []
      color_map = {}
      unique_colors = set()
  
      for x, y in queries:
          if x in color_map:
              unique_colors.discard(color_map[x])
          color_map[x] = y
          unique_colors.add(y)
          result.append(len(unique_colors))
  
      return result