Problem: On a strip of land of length n there are k air conditioners: the i-th air conditioner is placed in cell a_i (1 ≤ a_i ≤ n). Two or more air conditioners cannot be placed in the same cell (i.e. all a_i are distinct).

Each air conditioner is characterized by one parameter: temperature. The i-th air conditioner is set to the temperature t_i.

<image> Example of strip of length n=6, where k=2, a=[2,5] and t=[14,16].

For each cell i (1 ≤ i ≤ n) find it's temperature, that can be calculated by the formula $$$min_{1 ≤ j ≤ k}(t_j + |a_j - i|),$$$

where |a_j - i| denotes absolute value of the difference a_j - i.

In other words, the temperature in cell i is equal to the minimum among the temperatures of air conditioners, increased by the distance from it to the cell i.

Let's look at an example. Consider that n=6, k=2, the first air conditioner is placed in cell a_1=2 and is set to the temperature t_1=14 and the second air conditioner is placed in cell a_2=5 and is set to the temperature t_2=16. In that case temperatures in cells are:

  1. temperature in cell 1 is: min(14 + |2 - 1|, 16 + |5 - 1|)=min(14 + 1, 16 + 4)=min(15, 20)=15; 
  2. temperature in cell 2 is: min(14 + |2 - 2|, 16 + |5 - 2|)=min(14 + 0, 16 + 3)=min(14, 19)=14; 
  3. temperature in cell 3 is: min(14 + |2 - 3|, 16 + |5 - 3|)=min(14 + 1, 16 + 2)=min(15, 18)=15; 
  4. temperature in cell 4 is: min(14 + |2 - 4|, 16 + |5 - 4|)=min(14 + 2, 16 + 1)=min(16, 17)=16; 
  5. temperature in cell 5 is: min(14 + |2 - 5|, 16 + |5 - 5|)=min(14 + 3, 16 + 0)=min(17, 16)=16; 
  6. temperature in cell 6 is: min(14 + |2 - 6|, 16 + |5 - 6|)=min(14 + 4, 16 + 1)=min(18, 17)=17. 



For each cell from 1 to n find the temperature in it.

Input

The first line contains one integer q (1 ≤ q ≤ 10^4) — the number of test cases in the input. Then test cases follow. Before each test case, there is an empty line.

Each test case contains three lines. The first line contains two integers n (1 ≤ n ≤ 3 ⋅ 10^5) and k (1 ≤ k ≤ n) — the length of the strip of land and the number of air conditioners respectively.

The second line contains k integers a_1, a_2, …, a_k (1 ≤ a_i ≤ n) — positions of air conditioners on the strip of land.

The third line contains k integers t_1, t_2, …, t_k (1 ≤ t_i ≤ 10^9) — temperatures of air conditioners.

It is guaranteed that the sum of n over all test cases does not exceed 3 ⋅ 10^5.

Output

For each test case output n integers separated by space: temperatures of air in cells.

Example

Input


5

6 2
2 5
14 16

10 1
7
30

5 5
3 1 4 2 5
3 1 4 2 5

7 1
1
1000000000

6 3
6 1 3
5 5 5


Output


15 14 15 16 16 17 
36 35 34 33 32 31 30 31 32 33 
1 2 3 4 5 
1000000000 1000000001 1000000002 1000000003 1000000004 1000000005 1000000006 
5 6 5 6 6 5 

Solution (in JAVA):

Solution:
import java.lang.*;
import java.io.*;
import java.util.Comparator;
import java.util.TreeSet;

// Created by @thesupremeone on 10/07/21
public class E {
    static class AC implements Comparable<AC>{
        int index;
        long temp;
        public AC(int index, long temp) {
            this.index = index;
            this.temp = temp;
        }
        @Override
        public int compareTo(AC ac) {
            return Integer.compare(index, ac.index);
        }
        public long tempAt(int i) {
            return temp+Math.abs(i-index);
        }
    }



    void solve() throws IOException {
        int ts = getInt();
        for (int t = 1; t <= ts; t++){
            int n = getInt();
            int k = getInt();
            AC[] acs = new AC[n+1];
            TreeSet<Integer> indexes = new TreeSet<>();
            TreeSet<AC> set = new TreeSet<>((ac1, ac2)->{
                if(ac1.temp!=ac2.temp){
                    return Long.compare(ac1.temp, ac2.temp);
                }
                return Integer.compare(ac1.index, ac2.index);
            });
            int[] arr = new int[k];
            for (int i = 0; i < k; i++) {
                int index = getInt();
                indexes.add(index);
                arr[i] = index;
            }
            for(int i=0; i<k; i++){
                long temp = getLong();
                int index = arr[i];
                acs[index] = new AC(index, temp);
                set.add(acs[index]);
            }
            while (!set.isEmpty()){
                AC ac = set.first();
                Integer next;
                while ((next=indexes.lower(ac.index))!=null){
                    long temp = ac.tempAt(next);
                    if(temp<=acs[next].temp){
                        indexes.remove(next);
                        set.remove(acs[next]);
                    }else {
                        break;
                    }
                }
                while ((next=indexes.higher(ac.index))!=null){
                    long temp = ac.tempAt(next);
                    if(temp<=acs[next].temp){
                        indexes.remove(next);
                        set.remove(acs[next]);
                    }else {
                        break;
                    }
                }
                set.remove(ac);
            }
            for (int i = 1; i <= n ; i++) {
                if(indexes.contains(i)){
                    print(acs[i].tempAt(i));
                    print(' ');
                }else {
                    Integer lower = indexes.lower(i);
                    Integer higher = indexes.higher(i);
                    if(lower!=null && higher!=null){
                        print(Math.min(acs[lower].tempAt(i), acs[higher].tempAt(i)));
                        print(' ');
                    }else if(lower!=null){
                        print(acs[lower].tempAt(i));
                        print(' ');
                    }else if(higher!=null){
                        print(acs[higher].tempAt(i));
                        print(' ');
                    }
                }
            }
            println();
        }
    }

    public static void main(String[] args) throws Exception {
        new E().run();
    }
    private void run() throws Exception{
        if (isOnlineJudge()) {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
            out = System.out;
            solve();
        } else {
            localJudge = new Thread();
            din = new DataInputStream(new FileInputStream("input.txt"));
            out = new FileOutputStream("output.txt");
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
            localJudge.start();
            solve();
            localJudge.suspend();
        }
        flush();
        close();
    }
    boolean isOnlineJudge(){
        try {
            return System.getProperty("ONLINE_JUDGE")!=null
                    || System.getProperty("LOCAL")==null;
        }catch (Exception e){
            return true;
        }
    }

    static Thread localJudge = null;
    // For input
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;
    // For output
    private static final int BUF_SIZE = 1<<13;
    private final byte[] buf = new byte[BUF_SIZE];
    private OutputStream out;
    private int ptr = 0;
    // Fast Input Methods
    public String getLine() throws IOException {
        byte[] buf = new byte[64]; // line length
        int cnt = 0, c;
        while ((c = read()) != -1) {
            if (c == '\n') {
                if (cnt != 0) break;
                else continue;
            }
            buf[cnt++] = (byte)c;
        }
        return new String(buf, 0, cnt);
    }
    public int getInt() throws IOException {
        int ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = (c == '-');
        if (neg) c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');
        if (neg) return -ret;
        return ret;
    }
    public long getLong() throws IOException {
        long ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = (c == '-');
        if (neg) c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');
        if (neg) return -ret;
        return ret;
    }
    public double getDouble() throws IOException {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = (c == '-');
        if (neg) c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');
        if (c == '.') {
            while ((c = read()) >= '0' && c <= '9')
                ret += (c - '0') / (div *= 10);
        }
        if (neg) return -ret;
        return ret;
    }
    private void fillBuffer() throws IOException {
        bytesRead = din.read(buffer, bufferPointer = 0,
                BUFFER_SIZE);
        if (bytesRead == -1) buffer[0] = -1;
    }
    private byte read() throws IOException {
        if (bufferPointer == bytesRead) fillBuffer();
        return buffer[bufferPointer++];
    }
    public void close() throws IOException {
        if (din == null) return;
        din.close();
    }
    // Fast Output Methods
    public void print(byte b) {
        buf[ptr++] = b;
        if(ptr == BUF_SIZE)innerflush();
    }
    public void print(char c) {
        print((byte)c);
    }
    public void print(char[] s) {
        for(char c : s){
            buf[ptr++] = (byte)c;
            if(ptr == BUF_SIZE)innerflush();
        }
    }
    public void print(String s) {
        s.chars().forEach(c -> {
            buf[ptr++] = (byte)c;
            if(ptr == BUF_SIZE)innerflush();
        });
    }
    private static int countDigits(int l) {
        if (l >= 1000000000) return 10;
        if (l >= 100000000) return 9;
        if (l >= 10000000) return 8;
        if (l >= 1000000) return 7;
        if (l >= 100000) return 6;
        if (l >= 10000) return 5;
        if (l >= 1000) return 4;
        if (l >= 100) return 3;
        if (l >= 10) return 2;
        return 1;
    }
    public void print(int x) {
        if(x == Integer.MIN_VALUE){
            print((long)x);
            return;
        }
        if(ptr + 12 >= BUF_SIZE)innerflush();
        if(x < 0){
            print((byte)'-');
            x = -x;
        }
        int d = countDigits(x);
        for(int i = ptr + d - 1;i >= ptr;i--){
            buf[i] = (byte)('0'+x%10);
            x /= 10;
        }
        ptr += d;
    }
    private static int countDigits(long l) {
        if (l >= 1000000000000000000L) return 19;
        if (l >= 100000000000000000L) return 18;
        if (l >= 10000000000000000L) return 17;
        if (l >= 1000000000000000L) return 16;
        if (l >= 100000000000000L) return 15;
        if (l >= 10000000000000L) return 14;
        if (l >= 1000000000000L) return 13;
        if (l >= 100000000000L) return 12;
        if (l >= 10000000000L) return 11;
        if (l >= 1000000000L) return 10;
        if (l >= 100000000L) return 9;
        if (l >= 10000000L) return 8;
        if (l >= 1000000L) return 7;
        if (l >= 100000L) return 6;
        if (l >= 10000L) return 5;
        if (l >= 1000L) return 4;
        if (l >= 100L) return 3;
        if (l >= 10L) return 2;
        return 1;
    }
    public void print(long x) {
        if(x == Long.MIN_VALUE){
            print("" + x);
            return;
        }
        if(ptr + 21 >= BUF_SIZE)innerflush();
        if(x < 0){
            print((byte)'-');
            x = -x;
        }
        int d = countDigits(x);
        for(int i = ptr + d - 1;i >= ptr;i--){
            buf[i] = (byte)('0'+x%10);
            x /= 10;
        }
        ptr += d;
    }
    public void print(double x, int precision) {
        if(x < 0){
            print('-');
            x = -x;
        }
        x += Math.pow(10, -precision)/2;
        //		if(x < 0){ x = 0; }
        print((long)x);
        print(".");
        x -= (long)x;
        for(int i = 0;i < precision;i++){
            x *= 10;
            print((char)('0'+(int)x));
            x -= (int)x;
        }
    }
    public void println(char c){
        print(c);
        println();
    }
    public void println(int x){
        print(x);
        println();
    }
    public void println(long x){
        print(x);
        println();
    }
    public void println(double x, int precision){
        print(x, precision);
        println();
    }
    public void print(int... xs) {
        boolean first = true;
        for(int x : xs) {
            if (!first) print(' ');
            first = false;
            print(x);
        }
    }
    public void print(long... xs) {
        boolean first = true;
        for(long x : xs) {
            if (!first) print(' ');
            first = false;
            print(x);
        }
    }
    public void println() {
        print((byte)'\n');
    }
    public void println(int... xs) {
        print(xs);
        println();
    }
    public void println(long... xs) {
        print(xs);
        println();
    }
    public void println(char[] line) {
        print(line);
        println();
    }
    public void println(char[]... map) {
        for(char[] line : map){
            print(line);
            println();
        }
    }
    public void println(String s) {
        print(s);
        println();
    }
    private void innerflush() {
        try {
            out.write(buf, 0, ptr);
            ptr = 0;
        } catch (IOException e) {
            throw new RuntimeException("innerflush");
        }
    }
    public void flush() {
        innerflush();
        try {
            out.flush();
        } catch (IOException e) {
            throw new RuntimeException("flush");
        }
    }
}