input: from typing import List, Tuple
  
  def find_connectable_server_pairs(edges: List[Tuple[int, int, int]], speed: int) -> List[int]:
      """
      Consider an unrooted tree with n servers labeled from 0 to n - 1, given by a list of edges where each edge[i] = [node1, node2, weight] defines a bidirectional connection between node1 and node2 with weight_i. An integer speed is also provided.
  
      Two servers a and b can be linked through a server c if:
  
      a < b, and a, b, c are distinct.
      Distance from c to a is a multiple of speed.
      Distance from c to b is a multiple of speed.
      The paths from c to a and from c to b are edge-independent.
      Output an integer list of length n such that each element at index i represents the count of server pairs connectable via server i.
  
      Examples:
      >>> edges = [[0,1,1],[1,2,5],[2,3,13],[3,4,9],[4,5,2]], speed = 1
      [0,4,6,6,4,0]
      >>> edges = [[0,6,3],[6,5,3],[0,3,1],[3,2,7],[3,1,6],[3,4,2]], speed = 3
      [2,0,0,0,0,0,2]
  
      Constraints:
      2 <= n <= 1000
      len(edges) == n - 1
      len(edges[i]) == 3
      0 <= node1, node2 < n
      edges[i] = [node1, node2, weight]
      1 <= weight <= 10^6
      1 <= speed <= 10^6
      The input edges form a valid tree.
      """
output:     from collections import defaultdict, deque
      def build_graph(edges):
          graph = defaultdict(list)
          for u, v, weight in edges:
              graph[u].append((v, weight))
              graph[v].append((u, weight))
          return graph
      
      def bfs_distances(start, graph, n):
          dist = [-1] * n
          queue = deque([(start, 0)])
          dist[start] = 0
          while queue:
              node, d = queue.popleft()
              for neighbor, weight in graph[node]:
                  if dist[neighbor] == -1:
                      dist[neighbor] = d + weight
                      queue.append((neighbor, d + weight))
          return dist
      
      def find_pairs(n, distances, speed):
          count = 0
          for i in range(n):
              for j in range(i + 1, n):
                  if distances[i] % speed == 0 and distances[j] % speed == 0:
                      count += 1
          return count
      
      graph = build_graph(edges)
      result = []
      for i in range(len(graph)):
          distances = bfs_distances(i, graph, len(graph))
          result.append(find_pairs(len(graph), distances, speed))
      return result