def tower_of_hanoi(n, source, target, auxiliary, move_counter):
    """
    - Srini Raj
    Recursively solves the Tower of Hanoi puzzle for n rings.

    Parameters:
      n           : The number of rings.
      source      : The starting tower.
      target      : The destination tower.
      auxiliary   : The auxiliary tower.
      move_counter: A single-item list to keep track of move numbering.
    """
    if n == 1:
        move_counter[0] += 1
        print(f"{move_counter[0]}. Move Ring 1 from {source} to {target}.")
        return

    # Move n-1 rings from the source to the auxiliary tower.
    tower_of_hanoi(n - 1, source, auxiliary, target, move_counter)
    
    # Move the nth (largest) ring from the source to the target tower.
    move_counter[0] += 1
    print(f"{move_counter[0]}. Move Ring {n} from {source} to {target}.")
    
    # Move the n-1 rings from the auxiliary tower to the target tower.
    tower_of_hanoi(n - 1, auxiliary, target, source, move_counter)

def main():
    try:
        n = int(input("Enter the number of rings: "))
        if n < 1:
            raise ValueError("Number of rings must be at least 1.")
    except ValueError as e:
        print("Invalid input:", e)
        return

    print(f"\nTower of Hanoi solution for {n} rings:\n")
    move_counter = [0]  # Using a list for a mutable move counter
    tower_of_hanoi(n, "Tower 1", "Tower 3", "Tower 2", move_counter)

if __name__ == "__main__":
    main()