PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#CCBCHBAHAI0000079. Tách mảng thành mảng chẵn và mảng lẻ (Split an Array into Even and Odd Arrays)

    ID: 997 Loại: Thông thường 2000ms 256MiB Tried: 0 Đã chấp nhận: 0 Độ khó: 1 Đăng bởi: Nhãn>Programming language basicsStatic arraysIteration techniquesImplementation techniquesWorking with numbersInteger arithmetic
HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tách mảng thành mảng chẵn và mảng lẻ (Split an Array into Even and Odd Arrays)

Split an Array into Even and Odd Arrays

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem

Given a0,a1,…,an−1a_0,a_1,\ldots,a_{n-1}, create two arrays in original order: EE contains all even values (ai≡0(mod2)a_i\equiv0\pmod2), and OO contains all odd values. Their logical sizes are pp and qq with p+q=np+q=n.

Input

The first line contains nn. The second line contains nn integers aia_i.

Output

Line 1 prints pp followed by all elements of EE. Line 2 prints qq followed by all elements of OO. An empty group is printed as just 0.

Subtask

Subtask 1 (20 points): 1≤n≤101\le n\le 10, ∣ai∣≤103|a_i|\le 10^3.

Subtask 2 (30 points): 1≤n≤50001\le n\le 5000, ∣ai∣≤106|a_i|\le 10^6.

Subtask 3 (50 points): 1≤n≤2⋅1051\le n\le 2\cdot 10^5, ∣ai∣≤109|a_i|\le 10^9.

Example

Input

7
4 -3 0 9 8 -6 5

Output

4 4 0 8 -6
3 -3 9 5

Explanation

The output follows directly from the mathematical definition above.