public class QueADT
{
	class Link
	{
		Object info;
		Link next;
		
		public String toString()
		{
			return "" + info;
		}
	}
	
	Link front, back;
	int n;
	
	public QueADT()
	{
		front = null;
		back = null;
		n = 0;
	}
	
	public boolean isEmpty()
	{
		return front == null;
	}
	
	public Object getNode()
	//pre: que not MT
	//post: front node removes and pointer moved one node
	{
		if(isEmpty() ) 
		{
			throw new MTQue("THe quewue is empty");
		}			
		Object ans = front.info;
		front = front.next;
		n--;
		return ans;
	}
	
	public void addNode(Object item)
	//pre:
	//post: new node placed at end of list and pointed to by back
	{
		Link temp = new Link();
		temp.info = item;
		temp.next = null;
		if(isEmpty() )
		{
			front = temp;//node just created is linked list
		}
		else
		{
			back.next = temp;
		}
		back = temp;
		n++;
	}
	
	public int size()
	{
		return n;
	}
	
	public void print()
	{
		Link q = front;
		while(q != null)
		{
			System.out.print(q);
			q = q.next;
		}
		System.out.println();
	}
}

class MTQue extends RuntimeException
{
	public MTQue()
	{
		super();
	}
	
	public MTQue(String s)
	{
		super(s);
	}
}
	
	
	
		
