Product Minimize Mod#12357

Product Minimize Mod

2 seconds
256 megabytes
Medium

You are given two integers and , and two arrays and of length , such that for every 1 \le i \le n: l_i \le r_i

Your task is to construct an array of length such that:

l_i \le a_i \le r_i

and the remainder of the product of all elements of when divided by is as small as possible.

In other words, you want to minimize use fft to solve:

\left(\prod_{i=1}^{n} a_i\right) \bmod c

Input

The first line contains single integer (1 \le t \le 10^4) — the number of test cases.

The first line of each test case contains two integers and (1 \le n \le 2 \cdot 10^5,\; 1 \le c \le 20).

The second line contains integers (0 \le l_1, l_2, \dots, l_n \le 10^9).

The third line contains integers (0 \le r_1, r_2, \dots, r_n \le 10^9).

It's guaranteed that \sum n \le 2 \cdot 10^5 overall test cases.

Output

Print one line containing integers a_1, a_2, \dots, a_n — a valid array that minimizes the value of:

\left(\prod_{i=1}^{n} a_i\right) \bmod c

If multiple arrays satisfy the condition, print any of them.

Examples

Example 1

Loading
Loading

Scoring

  1. Subtask ( points) : (l_i=r_i).

  2. Subtask ( points) : (n=1).

  3. Subtsak ( points) : (c=2)

  4. Subtask ( points) : (n,c \le 8)

  5. Subtask ( points) : No additional constraints.