input: from typing import Tuple
  import numpy as np
  
  def kmeans(k: int, data: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
      """
      Perform k-means clustering on given data.
      
      >>> kmeans(2, np.array([[1, 2], [1.5, 1.8], [5, 8], [8, 8]]))
      (array([0, 0, 1, 1]), array([[1.25, 1.9 ], [6.5 , 8.  ]]))
      >>> kmeans(3, np.array([[1, 2], [1.5, 1.8], [5, 8], [8, 8], [9, 9], [10, 12]]))
      (array([0, 0, 1, 1, 2, 2]), array([[1.25, 1.9 ], [6.5 , 8.  ], [9.5 , 10.5]]))
      """
output:     n_samples, n_features = data.shape
      centroids = data[np.random.choice(n_samples, k, replace=False)]
      labels = np.zeros(n_samples)
      
      while True:
          old_centroids = centroids.copy()
          distances = np.linalg.norm(data[:, np.newaxis] - centroids, axis=2)
          labels = np.argmin(distances, axis=1)
          
          for i in range(k):
              centroids[i] = np.mean(data[labels == i], axis=0)
          
          if np.all(old_centroids == centroids):
              break
      
      return labels, centroids