input: from typing import List
  
  def find_distinct_colors(limit: int, queries: List[List[int]]) -> List[int]:
      """
      Given an integer limit and a 2D list called queries with dimensions n x 2.
  
      There are limit + 1 balls, each with unique labels from 0 to limit. Initially, these balls have no colors. For each query represented as [x, y] in the queries, assign the color y to ball x. After processing each query, determine the total number of unique colors across the balls.
  
      Return a list named result of size n, where result[i] denotes the count of unique colors after processing the ith query.
  
      Note:
      A color that is absent should not be considered as a unique color when responding to a query.
  
      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 == len(queries) <= 10^5
      queries[i].length == 2
      0 <= queries[i][0] <= limit
      1 <= queries[i][1] <= 10^9
      """
output:     ball_colors = {}
      unique_colors = set()
      result = []
  
      for x, y in queries:
          if x in ball_colors:
              if ball_colors[x] != y:
                  unique_colors.discard(ball_colors[x])
          ball_colors[x] = y
          unique_colors.add(y)
          result.append(len(unique_colors))
  
      return result