class HeadTail {
	Node head;
	Node tail;

	HeadTail(Node x, Node y)
	  {
		head = x;
		tail = y;	
	}
}

public class GeneratingList {
	public static void main (String[] args)
	{
		String [] arr1 = {"Winnipeg","Vancouver","Bejing","Athen","London","Berlin","Toronto","Seattle","Rome","Baltimore"}; 
		HeadTail a = linkedList(arr1);
		
		Node x = a.head;
		while (x != null) {
			System.out.println(x.getElement());
			x = x.getNext();
		}

	}

	public static HeadTail linkedList(String[] b) {
		Node head = null;
		Node tail = null;
		Node x = null;
		for (int i = 0; i < b.length; i++)
	     {x = new Node(); x.setElement(b[i]);
	        if (i == 0 ) {x.setNext(null); tail = x;}
	        else x.setNext(head);
	        head = x;
		}	
     	return new HeadTail(head, tail);
	}
}

