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

#TP0000015. Lập trình theo cặp (Pair Programming)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Lập trình theo cặp (Pair Programming)

Pair Programming

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Monocarp and Polycarp are editing the same program file. Initially, the file has kk lines. During each minute, exactly one of them performs an operation: appending a new line or editing an existing line.

Monocarp performs the ordered sequence a1,a2,…,ana_1,a_2,\ldots,a_n, whereas Polycarp performs b1,b2,…,bmb_1,b_2,\ldots,b_m. An operation equal to 00 appends a line. A positive value xx edits line xx, which is permitted only when the file currently contains at least xx lines.

They may take turns arbitrarily, but each person's operations must retain their original relative order. Construct a valid merged sequence containing all n+mn+m operations, or report that no such merge exists.

Input

The first line contains three integers k,n,mk,n,m: the initial number of lines and the respective numbers of operations performed by Monocarp and Polycarp.

The second line contains nn integers a1,a2,…,ana_1,a_2,\ldots,a_n in Monocarp's operation order.

The third line contains mm integers b1,b2,…,bmb_1,b_2,\ldots,b_m in Polycarp's operation order.

Output

If a valid merge exists, print n+mn+m integers on one line, describing the operations in execution order. Any valid merge is accepted. Otherwise, print -1.

Subtasks

  • Subtask 1 (20 points): 0≤k≤1000\le k\le100; 1≤n,m≤51\le n,m\le 5; 0≤ai,bj≤3000\le a_i,b_j\le300 for every element of both arrays.
  • Subtask 2 (30 points): 0≤k≤1000\le k\le100; 1≤n,m≤301\le n,m\le 30; 0≤ai,bj≤3000\le a_i,b_j\le300 for every element of both arrays.
  • Subtask 3 (50 points): 0≤k≤1000\le k\le100; 1≤n,m≤1001\le n,m\le 100; 0≤ai,bj≤3000\le a_i,b_j\le300 for every element of both arrays.

Examples

Input

3 2 2
2 0
0 5

Output

2 0 0 5

Explanation

The file initially has 33 lines. Monocarp must edit line 22 and then append a line; Polycarp must append a line and then edit line 55. The first action 22 is valid because 2≤32\le3. The two zeros increase the line count from 33 to 44 and then to 55. Finally, editing line 55 becomes possible. The output preserves each programmer's action order. 0 2 0 5 is another valid answer.