public class Main {
public static class Node<String> {
private String Habitantes;
private Node next;
Node(){
this.Habitantes = null;
this.next = null;
}
Node (String Habitantes){
this.Habitantes = Habitantes;
this.next = null;
}
Node(String Habitantes, Node next){
this.Habitantes = Habitantes;
this.next = next;
}
public String getHabitantes (){
return Habitantes;
}
public Node getNext (){
return next;
}
public void setNext(Node next) {
this.next = next;
}
public void setHabitantes(String Habitantes) {
this.Habitantes = Habitantes;
}
}
public static class Lista {
private Node head;
private Node tail;
public Lista () {
this.head = null;
this.tail = null;
}
public Node getHead(){
return head;
}
public void insertar(String v) {
Node<String> n_node = new Node<String>(v, this.head);
this.head = n_node;
}
public void insertarCola(String val){
Node nNode = new Node(val);
if(this.head == this.tail && this.head == null){
this.head = this.tail = nNode;
return;
}
else{
this.tail.setNext(nNode);
this.tail = nNode;
}
}
public Node remove(){
Node ret = this.head;
if(this.head == null){return ret;}
this.head = this.head.getNext();
return ret;
}
}
public static void main(String[] args) {
/*Scanner sc = new Scanner(System.in);
Scanner sc2 = new Scanner(System.in);
int N = sc.nextInt();
String habitantes = sc2.nextLine();*/
int N = 6;
boolean palindromas = true;
int mitadN = N/2;
String habitantes = "6 3 9 9 3 6";
Lista listaHabitantes = new Lista ();
Lista listaHabitantes2 = new Lista ();
String[] parts = habitantes.split(" ");
for(int i = 0; i < N;i++){
listaHabitantes.insertar(parts[i]);
}
for(int i = 0; i < N;i++){
listaHabitantes2.insertarCola(parts[i]);
}
for(int i = 1 ; i < mitadN; i++){
System.out.println(listaHabitantes.getHead().getHabitantes());
System.out.println(listaHabitantes2.getHead().getHabitantes());
System.out.println(listaHabitantes.getHead().getHabitantes() == listaHabitantes2.getHead().getHabitantes());
if(listaHabitantes.getHead().getHabitantes() != listaHabitantes2.getHead().getHabitantes()){
System.out.println("!!!!");
palindromas = false;
break;
}
listaHabitantes.remove();
listaHabitantes2.remove();
}
System.out.println(palindromas);
}
}