input: Write a python function to implement the k-nearest neighbors algorithm.
  assert k_nearest_neighbors({1: [[1, 2], [2, 3], [3, 1]], 2: [[6, 5], [7, 7], [8, 6]]}, [5, 5], k=3) == (2, 1.0)
  assert k_nearest_neighbors({1: [[1, 2], [2, 3], [3, 1]], 2: [[6, 5], [7, 7], [8, 6]]}, [2, 2], k=3) == (1, 1.0)
  assert k_nearest_neighbors({1: [[1, 2], [2, 3], [3, 1]], 2: [[6, 5], [7, 7], [8, 6]]}, [7, 5], k=2) == (2, 1.0)
output: def k_nearest_neighbors(data, point, k):
      import heapq
      from collections import Counter
  
      def euclidean_distance(p1, p2):
          return sum((x - y) ** 2 for x, y in zip(p1, p2)) ** 0.5
  
      distances = []
      for label, points in data.items():
          for pt in points:
              distance = euclidean_distance(point, pt)
              distances.append((distance, label))
  
      k_nearest = heapq.nsmallest(k, distances)
      labels = [label for _, label in k_nearest]
      most_common = Counter(labels).most_common(1)[0]
      return most_common[0], most_common[1] / k