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.io.*;
import java.util.*;

public class Main {
	static InputReader in = new InputReader(System.in);
	static OutputWriter out = new OutputWriter(System.out);

	public static void main(String[] args) throws IOException {
		int t = 1;
		t = i();
		sb = new StringBuilder();
		while (t-- > 0) {
			solve();
		}
		out.println(sb.toString());
		out.close();

	}

	static int mod = 1000000007;
	static StringBuilder sb;

	private static void solve() {
		int n = i();
		int k = i();
		int[] a = readArray(k);
		int[] t = readArray(k);
		int[] res = new int[n + 2];

		Arrays.fill(res, Integer.MAX_VALUE - 5);
		for (int i = 0; i < k; i++) {
			res[a[i]] = t[i];
		}
		for (int i = n; i >= 1; i--) {
			res[i] = Math.min(res[i], res[i + 1] + 1);
		}
		for (int i = 1; i <= n; i++) {
			res[i] = Math.min(res[i], res[i - 1] + 1);
		}

		for (int i = 1; i <= n; i++) {
			sb.append(res[i] + " ");
		}
		sb.append("\n");
	}

	static class Edge implements Comparable<Edge> {
		int u;
		int v;
		int wt;

		Edge(int u, int v, int wt) {
			this.u = u;
			this.v = v;
			this.wt = wt;
		}

		public int compareTo(Edge o) {
			return this.wt - o.wt;
		}
	}

	// Fenwick Tree
	static class fenwickTree {
		int n;
		long[] farr;

		fenwickTree(int n, long[] a) {
			this.n = n;
			farr = new long[n + 1];
			for (int i = 0; i < n; i++) {
				update(i + 1, a[i]);
			}
		}

		void update(int i, long val) {
			while (i < farr.length) {
				farr[i] += val;
				i += (i & -i);
			}
		}

		long sum(int i) {
			long sum = 0L;
			while (i > 0) {
				sum += farr[i];
				i -= (i & -i);
			}
			return sum;
		}
	}

	// *************Disjoint set
	// union*********//
	static class dsu {
		int[] par;
		int[] rank;

		dsu(int n) {
			par = new int[n + 1];
			rank = new int[n + 1];
			for (int i = 0; i <= n; i++) {
				par[i] = i;
				rank[i] = 1;
			}
		}

		int find(int a) {
			if (par[a] == a) {
				return a;
			}
			int x = find(par[a]);
			par[a] = x;
			return x;
		}

		boolean union(int a, int b) {
			int pa = find(a);
			int pb = find(b);
			if (pa == pb) {
				return false;
			}
			if (rank[pa] > rank[pb]) {
				par[pb] = pa;
			} else if (rank[pb] > rank[pa]) {
				par[pa] = pb;
			} else {
				par[pa] = pb;
				rank[pb]++;
			}
			return true;
		}
	}

	// **************NCR%P******************
	static long ncr(int n, int r) {
		if (r > n)
			return (long) 0;
		long[] fact = new long[(int) 1e6 + 10];
		fact[0] = fact[1] = 1;
		for (int i = 2; i < fact.length; i++) {
			fact[i] = ((long) (i % mod) * (long) (fact[i - 1] % mod)) % mod;
		}
		long res = fact[n] % mod;
		res = ((long) (res % mod) * (long) (p(fact[r], mod - 2) % mod)) % mod;
		res = ((long) (res % mod) * (long) (p(fact[n - r], mod - 2) % mod)) % mod;
		return res;
	}

	static ArrayList<Integer> divisors(int n) {
		ArrayList<Integer> al = new ArrayList<>();
		for (int i = 1; i * i <= n; i++) {
			if (n % i == 0) {
				if (n == i * i) {
					al.add(i);
				} else {
					al.add(i);
					al.add(n / i);
				}
			}
		}
		Collections.sort(al);
		return al;
	}

	static long p(long x, long y)// POWER FXN //
	{
		if (y == 0)
			return 1;

		long res = 1;
		while (y > 0) {
			if (y % 2 == 1) {
				res = (res * x) % mod;
				y--;
			}

			x = (x * x) % mod;
			y = y / 2;

		}
		return res;
	}

	private static boolean pow2(int i) {
		return (i & (i - 1)) == 0;
	}

	private static void sort(int[] arr) {
		int n = arr.length;
		ArrayList<Integer> res = new ArrayList<>();
		for (int a : arr) {
			res.add(a);
		}
		Collections.sort(res);
		for (int i = 0; i < n; i++) {
			arr[i] = res.get(i);
		}
	}

	private static void sort(long[] arr) {
		int n = arr.length;
		ArrayList<Long> res = new ArrayList<>();
		for (long a : arr) {
			res.add(a);
		}
		Collections.sort(res);
		for (int i = 0; i < n; i++) {
			arr[i] = res.get(i);
		}
	}

	private static void revSort(int[] arr) {
		int n = arr.length;
		ArrayList<Integer> res = new ArrayList<>();
		for (int a : arr) {
			res.add(a);
		}
		Collections.sort(res, Collections.reverseOrder());
		for (int i = 0; i < n; i++) {
			arr[i] = res.get(i);
		}
	}

	private static ArrayList<Integer> sieveOfEratosthenes(int n) {
		boolean[] arr = new boolean[n + 1];

		arr[0] = arr[1] = true;
		for (int i = 2; i * i <= n; i++) {
			if (!arr[i]) {
				for (int j = i * i; j <= n; j += i) {
					arr[j] = true;
				}
			}
		}
		ArrayList<Integer> primes = new ArrayList<>();
		for (int i = 2; i <= n; i++) {
			if (!arr[i]) {
				primes.add(i);
			}
		}
		return primes;
	}

	private static ArrayList<Integer> segmentedSieve(int s, int e) {
		int len = (int) (Math.sqrt(e) + 1);
		ArrayList<Integer> primes = sieveOfEratosthenes(len);
		boolean[] arr2 = new boolean[e - s + 1];
		if (s == 1) {
			arr2[0] = true;
		}
		ArrayList<Integer> res = new ArrayList<>();
		for (int p : primes) {

			int st = (int) (p * (Math.ceil((double) s / p)));
			if (st < s) {
				st += p;
			}
			if (st == p) {
				st += p;
			}
			for (int i = st; i <= e; i += p) {
				arr2[i - s] = true;
			}
		}
		for (int i = 0; i < arr2.length; i++) {
			if (!arr2[i]) {
				res.add(i + s);
			}
		}
		return res;
	}

	private static long pow(int n, int k) {
		long res = 1;
		long num = (long) n;
		while (k > 0) {
			if ((k & 1) == 1) {
				res = (res * num) % mod;
			}
			k /= 2;
			num = num * num % mod;
		}
		return res;
	}

	private static int countDigits(int n) {
		int c = 0;
		while (n != 0) {
			c++;
			n /= 10;
		}
		return c;
	}

	private static int[] getRange(int a) {
		int min = 1;
		int t = a;
		while (--t > 0) {
			min = min * 10;
		}
		int max = 9;
		t = a;
		while (--t > 0) {
			max = max * 10 + 9;
		}
		return new int[] { min, max };
	}

	private static boolean palindrome(String str) {
		int s = 0;
		int e = str.length() - 1;
		while (s < e) {
			if (str.charAt(s) != str.charAt(e)) {
				return false;
			}
			s++;
			e--;
		}
		return true;
	}

	private static void reverse(int[] arr, int s, int e) {
		while (s < e) {
			int temp = arr[s];
			arr[s++] = arr[e];
			arr[e--] = temp;
		}
	}

	private static int getMax(int[] arr, int s, int e) {
		int maxi = s;
		for (int i = s + 1; i <= e; i++) {
			if (arr[i] > arr[maxi]) {
				maxi = i;
			}
		}
		return maxi;
	}

	private static int getMin(int[] arr, int s, int e) {
		int mini = s;
		for (int i = s + 1; i <= e; i++) {
			if (arr[i] < arr[mini]) {
				mini = i;
			}
		}
		return mini;
	}

	// ******LOWEST COMMON MULTIPLE************************
	private static long lcm(long n1, long n2) {
		return (n1 * n2) / gcd(n1, n2);
	}

	private static int lcm(int n1, int n2) {
		return (n1 * n2) / gcd(n1, n2);
	}

	// ***********GCD*****************
	private static long gcd(long num1, long num2) {
		if (num2 == 0) {
			return num1;
		}
		return gcd(num2, num1 % num2);
	}

	private static int gcd(int num1, int num2) {
		if (num2 == 0) {
			return num1;
		}
		return gcd(num2, num1 % num2);
	}

	// **************PRIME FACTORIZE **********************************//
	static TreeMap<Integer, Integer> prime(long n) {
		TreeMap<Integer, Integer> h = new TreeMap<>();
		long num = n;
		for (int i = 2; i <= Math.sqrt(num); i++) {
			if (n % i == 0) {
				int nt = 0;
				while (n % i == 0) {
					n = n / i;
					nt++;
				}
				h.put(i, nt);
			}
		}
		if (n != 1)
			h.put((int) n, 1);
		return h;

	}

	// ****CLASS PAIR ************************************************
	static class Pair implements Comparable<Pair> {
		int vtx;
		int wt;

		Pair(int x, int y) {
			this.vtx = x;
			this.wt = y;
		}

		public int compareTo(Pair o) {
			return this.wt - o.wt;

		}

	}

	static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int Int() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public String String() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next() {
			return String();
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}

	static class OutputWriter {
		private final PrintWriter writer;

		public OutputWriter(OutputStream outputStream) {
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
		}

		public OutputWriter(Writer writer) {
			this.writer = new PrintWriter(writer);
		}

		public void print(Object... objects) {
			for (int i = 0; i < objects.length; i++) {
				if (i != 0)
					writer.print(' ');
				writer.print(objects[i]);
			}
		}

		public void println(Object... objects) {
			print(objects);
			writer.println();
		}

		public void close() {
			writer.close();
		}

		public void flush() {
			writer.flush();
		}
	}

//*****************INPUT PATTERN******************************************
	public static int i() {
		return in.Int();
	}

	public static long l() {
		String s = in.String();
		return Long.parseLong(s);
	}

	public static String s() {
		return in.String();
	}

	public static int[] readArray(int n) {
		int A[] = new int[n];
		for (int i = 0; i < n; i++) {
			A[i] = i();
		}
		return A;
	}

	public static long[] readArray(long n) {
		long A[] = new long[(int) n];
		for (int i = 0; i < n; i++) {
			A[i] = l();
		}
		return A;
	}

}