public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> list = new ArrayList<Integer>();
ArrayList<Integer> three = new ArrayList<Integer>();
ArrayList<Integer> two = new ArrayList<Integer>();
ArrayList<Integer> both = new ArrayList<Integer>();
for (int i = 0; i < 20; i++)
{
list.add(Integer.parseInt(bf.readLine()));
}
for(int i:list)
{
if(i % 3 == 0)
three.add(i);
if(i % 2 == 0)
two.add(i);
if(i % 3 ==0 && i % 2==0)
both.add(i);
}
printList(three);
printList(two);
printList(both);
}
}
public static void printList(List<Integer> list) {
for (int x : list)
{
System.out.println(x);
}
}
}
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 {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> list = new ArrayList<Integer>();
ArrayList<Integer> three = new ArrayList<Integer>();
ArrayList<Integer> two = new ArrayList<Integer>();
ArrayList<Integer> both = new ArrayList<Integer>();
for (int i = 0; i < 20; i++)
{
list.add(Integer.parseInt(bf.readLine()));
}
for(int i:list)
{
if(i % 3 == 0)
three.add(i);
if(i % 2 == 0)
two.add(i);
if(i % 3 ==0 && i % 2==0)
both.add(i);
}
printList(three);
printList(two);
printList(both);
}
}
public static void printList(List<Integer> list) {
for (int x : list)
{
System.out.println(x);
}
}
}