package com.codegym.task.task07.task0713;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/*
Playing Javarella
*/
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in) );
ArrayList<Integer> list = new ArrayList<Integer>();
for (int i = 0; i<20; i++) {
list.add(Integer.parseInt(reader.readLine()));
}
ArrayList<Integer> list1 = new ArrayList<Integer>();
ArrayList<Integer> list3 = new ArrayList<Integer>();
ArrayList<Integer> list2 = new ArrayList<Integer>();
for (int i = 0; i<20; i++) {
Integer x = list.get(i);
if (x % 3 == 0){
list1.add(x); // Check that the remainder is zero when we divide by two
} //add to the list which are divided by 3
if (x % 2 == 0){
list2.add(x); //add to the list which are divided by 2
}
if(x%2!=0 && x%3!=0){
list3.add(x);
}
}
printList(list1);
printList(list2);
printList(list3);
}
public static void printList(List<Integer> list) {
//write your code here
for (Integer temp: list) {
System.out.println(temp);
}
}
}