import java.util.*;

public class TD3EX1Q3 {
  public static void main(String []args) {
    Stack<Integer> p1 = new Stack<Integer>();
    Stack<Integer> p2 = new Stack<Integer>();
    Stack<Integer> p3 = new Stack<Integer>();
    Scanner in = new Scanner(System.in);
    while (in.hasNext()) {
      p1.push(in.nextInt());
    }
    System.out.println("p1="+p1+" p2="+p2+" p3="+p3);

    /* Solution ├ęclater p1 dans deux piles celles contenant les pairs et celle
       contenant les impairs, puis fusionner les imparis par-dessus les pairs */
    while (!p1.empty()) {
      int element = p1.pop();
      if (element%2==0) // pair
        p2.push(element);
      else
        p3.push(element);
    }
    System.out.println("p1="+p1+" p2="+p2+" p3="+p3);
    while (!p3.empty()) {
      p2.push(p3.pop());
    }
    System.out.println("p1="+p1+" p2="+p2+" p3="+p3);
  }
}