input: Write a python function to perform KMeans clustering and plot the data and centroids using matplotlib.
  assert np.allclose(kmeans_and_plot([[120, 250], [110, 200], [140, 300]], 2)[0], np.array([[115., 225.], [140., 300.]]), atol=0.1)
  assert np.allclose(kmeans_and_plot([[1, 2], [1, 4], [1, 0], [10, 2], [10, 4], [10, 0]], 2)[0], np.array([[10., 2.], [1., 2.]]), atol=0.1)
  assert np.allclose(kmeans_and_plot([[2, 3], [2, 2], [8, 3], [8, 2]], 2)[0], np.array([[2., 2.5], [8., 2.5]]), atol=0.1)
output: def kmeans_and_plot(data, n_clusters):
      import numpy as np
      from sklearn.cluster import KMeans
      import matplotlib.pyplot as plt
  
      # Convert data to numpy array
      data = np.array(data)
      
      # Perform KMeans clustering
      kmeans = KMeans(n_clusters=n_clusters, random_state=0).fit(data)
      centroids = kmeans.cluster_centers_
      
      # Plot the data points and centroids
      plt.scatter(data[:, 0], data[:, 1], c=kmeans.labels_, cmap='viridis')
      plt.scatter(centroids[:, 0], centroids[:, 1], c='red', marker='x')
      plt.title('KMeans Clustering')
      plt.xlabel('Feature 1')
      plt.ylabel('Feature 2')
      plt.show()
      
      return centroids, kmeans.labels_