Codeforces Round 186 (Div. 2)
E
Ilya and Two Numbers
Codeforces
2300
原题
← D→
翻译中…

Ilya has recently taken up archaeology. He's recently found two numbers, written in the $*m*$-based notation. Each of the found numbers consisted of exactly $*n*$ digits. Ilya immediately started looking for information about those numbers. He learned that the numbers are part of a cyphered code and the one who can decypher it can get the greatest treasure.

翻译中…

After considerable research Ilya understood that to decypher the code, he should do the following:

翻译中…
  • Rearrange digits in the first number in some manner. Similarly, rearrange digits in the second number in some manner. As a result of this operation, the numbers can get leading zeroes.
  • Add numbers, digit by digit, modulo $*m*$. In other words, we need to get the third number of length $*n*$, each digit of the number is the sum of the respective numbers of the found numbers. For example, suppose there are two numbers recorded in the ternary notation, 001210 and 012111, then if you add them to each other digit by digit modulo 3, you will get number 010021.
  • The key to the code is the maximum possible number that can be obtained in the previous step.
翻译中…

Help Ilya, find the key to the code.

翻译中…

Input

翻译中…

The first line contains two integers $*n*, *m*$ $(1 ≤ *n*, *m* ≤ 10^{5}, *m* > 1)$. The second line contains the first found number, the third line contains the second found number.

翻译中…

The numbers are recorded as a sequence of digits in the $*m*$-based notation. Each digit is an integer from 0 to $*m* - 1$. The digits in the line are written in the order from the most significant digits to the least significant ones.

翻译中…

The given numbers can contain leading zeroes.

翻译中…

Output

翻译中…

Print $*n*$ $*m*$-base digits. The resulting third number written in the $*m*$-based notation. Print the digits in the order from the most significant digits to the least significant ones.

翻译中…

样例

Input #1
4 7
5 4 3 2
5 6 5 4
Output #1
6 4 2 1
InputCopy OutputCopy
Input #2
5 5
2 4 4 1 3
1 0 1 2 4
Output #2
4 4 4 3 2
InputCopy OutputCopy
题目信息
题号
313E
时间限制
2 s
内存限制
256 MB
标签
构造
数据结构
并查集
贪心

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。