import java.util.*; public class program{ public static void main(String[] args) { Scanner scanner = new Scanner(System.in); List odd = new ArrayList<>(); List even = new ArrayList<>(); // Read input numbers while (scanner.hasNextInt()) { int num = scanner.nextInt(); if (num % 2 == 0) { even.add(num); } else { odd.add(num); } } scanner.close(); // Sort both lists Collections.sort(odd); Collections.sort(even); // Print odd numbers for (int i = 0; i < odd.size(); i++) { System.out.print(odd.get(i)); if (i < odd.size() - 1) System.out.print(" "); } System.out.println(); // Print even numbers for (int i = 0; i < even.size(); i++) { System.out.print(even.get(i)); if (i < even.size() - 1) System.out.print(" "); } System.out.println(); } }