points = {
    "R1": (1, 1), "R2": (2, 1),
    "R3": (8, 9), "R4": (9, 8),
}
centers = [(1, 1), (9, 8)]
previous = None
while True:
    groups = [[] for _ in centers]
    assignment = []
    for row_id, point in points.items():
        distances = [sum((a - b) ** 2 for a, b in zip(point, c)) for c in centers]
        group_id = distances.index(min(distances))
        groups[group_id].append(row_id)
        assignment.append(group_id)
    updated = [
        tuple(sum(points[r][i] for r in group) / len(group) for i in range(2))
        for group in groups
    ]
    print(assignment, updated)
    if assignment == previous:
        break
    previous = assignment
    centers = updated
