using System.Collections;
Stack source=new Stack();
public void MoveRing(Stack s1,Stack s2,int start,int end){
v1=Convert.ToInt32(s1.Peek());
v2=Convert.ToInt32(s2.Peek());
if((v1>v2 || v1==0) && v2!=0)
int s=Convert.ToInt32(s2.Pop());
Console.WriteLine(" Moved "+s.ToString().Trim()+" from "+end+" to "+start);
else if((v2>v1 || v2==0) && v1!=0)
int s=Convert.ToInt32(s1.Pop());
Console.WriteLine(" Moved "+s.ToString().Trim()+" from "+start+" to "+end);
Console.WriteLine("Error");
public void View(Stack s){
ArrayList list=new ArrayList();
list.Add(s.Pop().ToString());
for(int i=list.Count-1;i>=0;i--)
Console.WriteLine(list[i]);
var p=((int)Math.Pow(2,N))-1;
MoveRing(source,aux,1,2);
MoveRing(source,dest,1,3);
MoveRing(source,dest,1,3);
MoveRing(source,aux,1,2);
public static void Main()
var input=Convert.ToInt32(Console.ReadLine());
Towers tower=new Towers();