class List
{
   int value;
   List next;
}

public class insert
{
   /* =========================================
      insert(h, e): insert e at start of list h
                    return new list
      ========================================= */
   public static List insert (List h, List e)
   {
      e.next = h;
      return e;		// Return new list that starts at e
   }

   public static void main(String[] args)
   {
      List head = null;
      List p;

      /* -------------------------------------------------
         Create a list element and insert in List at head
         ------------------------------------------------- */
      p = new List( );
      p.value = 1;
      head = insert(head, p);       // Insert p in head
      print(head);  

      /* -------------------------------------------------
         Create a list element and insert in List at head
         ------------------------------------------------- */
      p = new List( );
      p.value = 2;
      head = insert(head, p);       // Insert p in head
      print(head);   
   }






   // Print the list
   public static void print(List h)
   {
      while (h != null)
      {
         System.out.printf("%d ", h.value);
         h = h.next;
      }
      System.out.printf("\n\n");
   }
}