import java.awt. * ; import java.net. * ; import java.io. * ; import java.lang. * ; import java.util. * ; class node ... {private Object data;private node next;private node prev;public node(Object o)...{data = o;prev = next = null;}public String toString()...{if(next!=null)return data.toString() + " "+ next.toString();return data.toString();}public node getNext()...{return next;}public void setNext(node n)...{next = n;}public node getPrev()...{return prev;}public void setPrev(node n)...{prev = n;}public Object getData()...{return data;}} class linkedlist ... {node head;node tail;public linkedlist()...{tail = head = null;}public String toString()...{if(head==null)return "Empty list";return head.toString();}public void insert(Object o)...{if(tail==null)...{head = tail = new node(o);}else...{node nn = new node(o);tail.setNext(nn);tail=nn;}}public boolean contains(Object o)...{for(node n = head;n!=null;n=n.getNext())...{if(o.equals(n.getData()))return true;}return false;}public Object pop()...{if(head==null)return null;Object ret = head.getData();head = head.getNext();if(head==null)tail = null;return ret;}public boolean isEmpty()...{return head==null;}} class list ... {protected node tail;protected node ptr;private boolean stop;public list()...{ptr=tail=null;stop=false;}public boolean isEmpty()...{return tail==null;}public void reset()...{stop=false;ptr=tail;}public String toString()...{if(tail==null)return "Empty list";String ret="";for(node n = tail.getNext();n!=tail;n=n.getNext())ret+=n.getData().toString()+" ";ret+=tail.getData().toString();return ret;}public Object get()...{if(ptr==null)return null;ptr = ptr.getNext();if(ptr==tail.getNext())...{if(stop)return null;stop=true;return tail.getNext().getData();}return ptr.getData();}public void insert(Object o, boolean attail)...{node nn = new node(o);if(tail==null)...{nn.setNext(nn);nn.setPrev(nn);ptr=tail=nn;return;}if(attail)...{tail.getNext().setPrev(nn);nn.setNext(tail.getNext());tail.setNext(nn);nn.setPrev(tail);tail=nn;}else...{nn.setNext(tail.getNext());nn.setPrev(tail);tail.setNext(nn);nn.getNext().setPrev(nn);}}public void insert(Object o)...{}} class stack extends list ... {public stack()...{super();}public void insert(Object o)...{insert(o, false);}} class queue extends list ... {