using System;
using System.Collections.Generic;
using System.Text;

class LinkedListTest
{
    static void Main(string[] args)
    {
    }
}

public abstract class Node
{
    public Node ptr;

    public Node()
    {
        ptr = null;
    }

    public abstract void printNode();

}

public class myNode:Node
{
	public String val;

	public myNode(String s):base()
	{
        val = s;
	}

	public override void printNode()
	{
        System.Console.WriteLine(val);
	}
}


/*public class Node
{
    public Node ptr=null;
    private int val;

    public Node(int v)
    {
        val = v;
        ptr = null;
    }

    public void printNode()
    {
        System.Console.WriteLine("Node val " + val);
    }

}*/

public class LinkedList
{
    private Node head = null;
    private Node tail = null;

    public void addNode(Node n)
    {
        if (head == null)		// Empty list
        {
            head = n;
            tail = n;
        }
        else
        {
            tail.ptr = n;
            tail = n;
        }
    }

    public void printList()
    {
        Node curr = head;
        while (curr != null)
        {
            curr.printNode();
            curr = curr.ptr;
        }
    }
}




