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 CPP):

Solution:
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#define endl '\n'
#define pb push_back
#define fir first
#define sec second
#define umap unordered_map
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
long long TESTCASE_NUM = 1;
long long TESTCASE_CUR = 0;
template <typename T>
inline void _read(T &x) { cin >> x; }
inline void _read(int &x) { scanf("%d", &x); }
inline void _read(long long &x) { scanf("%lld", &x); }
inline void _read(float &x) { scanf("%f", &x); }
inline void _read(double &x) { scanf("%lf", &x); }
inline void _read(char &x) { x = getchar(); }
inline void _read(char *x) { scanf("%s", x); }
inline void read() {}
template <typename T, typename... U>
inline void read(T &head, U &...tail)
{
    _read(head);
    read(tail...);
}
template <typename T>
inline void _write(const T &x) { cout << x; }
inline void _write(const int &x) { printf("%d", x); }
inline void _write(const long long &x) { printf("%lld", x); }
inline void _write(const float &x) { printf("%.6f", x); }
inline void _write(const double &x) { printf("%.8lf", x); }
inline void _write(const char &x) { putchar(x); }
inline void _write(const char *x) { printf("%s", x); }
inline void write() {}
template <typename T, typename... U>
inline void write(const T &head, const U &...tail)
{
    _write(head);
    write(tail...);
}
inline void debug() {}
#ifdef _USE_DEBUG
template <typename T, typename... U>
inline void debug(const T &head, const U &...tail)
{
    _write("\033[1m\033[33m\33[4m");
    write(head, tail...);
    _write("\033[0m");
    // system("sleep 1");
    fflush(stdout);
}
#else
template <typename T, typename... U>
inline void debug(const T &head, const U &...tail)
{
}
#endif
inline bool isprime(ll p)
{
    if (p == 2 || p == 3)
        return 1;
    if (p < 2 || (p % 6 != 1 && p % 6 != 5))
        return 0;
    for (ll i = 5; i * i <= p; i = i + 6)
        if (p % i == 0 || p % (i + 2) == 0)
            return 0;
    return 1;
}
inline ll qpow(ll a, ll b, ll m)
{
    ll ans = 1, base = a;
    while (b)
    {
        if (b & 1)
            ans = ans * base % m;
        base = base * base % m;
        b >>= 1;
    }
    return ans;
}
inline ll qpow(ll a, ll b)
{
    ll ans = 1, base = a;
    while (b)
    {
        if (b & 1)
            ans = ans * base;
        base = base * base;
        b >>= 1;
    }
    return ans;
}
inline ll exgcd(ll a, ll b, ll &x, ll &y)
{
    if (!b)
    {
        x = 1;
        y = 0;
        return a;
    }
    else
    {
        ll tx, ty;
        ll d = exgcd(b, a % b, tx, ty);
        x = ty;
        y = tx - (a / b) * ty;
        return d;
    }
}
inline ll geteuler(ll n)
{
    ll ans = n;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0)
        {
            ans = ans / i * (i - 1);
            while (n % i == 0)
                n /= i;
        }
    if (n > 1)
        ans = ans / n * (n - 1);
    return ans;
}
inline ll inv(ll a, ll n)
{
    ll x, y;
    ll d = exgcd(a, n, x, y);
    if (d == 1)
        return (x % n + n) % n;
    else
        return -1;
}
template <typename T1, typename T2>
inline T1 max(T1 a, T2 b)
{
    return a < b ? b : a;
}
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b)
{
    return a < b ? a : b;
}
ll C(ll n, ll m, ll p)
{
    if (m > n)
        return 0;
    ll up = 1, down = 1;
    for (int i = n - m + 1; i <= n; i++)
        up = up * i % p;
    for (int i = 1; i <= m; i++)
        down = down * i % p;
    return up * inv(down, p) % p;
}
ll Lucas(ll n, ll m, ll p)
{
    if (m == 0)
        return 1;
    return C(n % p, m % p, p) * Lucas(n / p, m / p, p) % p;
}

const int LCA_INFNUM = 0x3f3f3f3f;

template <typename T = int>
class Tree_LCA
{
    vector<vector<pair<int, T>>> edge;
    vector<int> fa;
    vector<int> son;
    vector<int> dep;
    vector<int> top;
    vector<int> sz;
    vector<T> dis;
    int n;
    void dfs1(int x, T sum = 0)
    {
        sz[x] = 1;
        dep[x] = dep[fa[x]] + 1;
        dis[x] = sum;
        for (auto &it : edge[x])
        {
            if (it.first == fa[x])
                continue;
            fa[it.first] = x;
            dfs1(it.first, sum + it.second);
            sz[x] += sz[it.first];
            if (!son[x] || sz[son[x]] < sz[it.first])
                son[x] = it.first;
        }
    }
    void dfs2(int x, int tp)
    {
        top[x] = tp;
        if (son[x])
            dfs2(son[x], tp);
        for (auto &it : edge[x])
        {
            if (it.first != fa[x] && it.first != son[x])
            {
                dfs2(it.first, it.first);
            }
        }
    }

    void dfs(int u, vector<int> &vis, vector<int> &dist)
    {
        vis[u] = true;
        for (auto &it : edge[u])
        {
            if (!vis[it.first])
            {
                dist[it.first] = dist[u] + it.second;
                if (dist[it.first] > length && dist[it.first] != LCA_INFNUM)
                {
                    length = dist[it.first];
                }
                dfs(it.first, vis, dist);
            }
        }
    }

public:
    T length;
    Tree_LCA(int _n)
        : edge(_n + 1, vector<pair<int, T>>()),
          fa(_n + 1),
          son(_n + 1),
          dep(_n + 1),
          top(_n + 1),
          sz(_n + 1),
          dis(_n + 1),
          n(_n + 1) {}
    void add_edge(int from, int to, T dis = 1)
    {
        edge[from].emplace_back(to, dis);
        edge[to].emplace_back(from, dis);
    }
    void pre(int root = 1)
    {
        dfs1(root);
        dfs2(root, root);
    }
    int lca(int x, int y)
    {
        while (top[x] != top[y])
        {
            if (dep[top[x]] <= dep[top[y]])
            {
                y = fa[top[y]];
            }
            else
            {
                x = fa[top[x]];
            }
        }
        if (dep[x] <= dep[y])
            return x;
        return y;
    }
    T distance(int x, int y) { return dis[x] + dis[y] - 2 * dis[lca(x, y)]; }
    T longestDistance()
    {
        length = -1;
        vector<int> vis(n + 1);
        vector<int> dist(n + 1, LCA_INFNUM);
        int start = max_element(dep.begin(), dep.end()) - dep.begin();
        dist[start] = 0;
        dfs(start, vis, dist);
        return length;
    }
};

void solve();
void init();
signed main()
{
#ifdef _USE_FILEIO
    freopen("in1.txt", "r", stdin);
    // freopen("ans1.txt", "w", stdout);
#endif
    init();
    scanf("%lld\n", &TESTCASE_NUM);
    while (TESTCASE_CUR++ < TESTCASE_NUM)
    {
        // printf("Case #%lld: ", TESTCASE_CUR);
        solve();
    }
    return 0;
}

//////////////////////////////////////////////////

const int MAXN = 3e5 + 10;
const int MOD = 1e9 + 7; // RE-CHECK THIS
const ll INF = 1e18;

void init()
{
}

pll a[MAXN];

ll pre[MAXN];

bool cmp(pll a, pll b)
{
    if (a.fir + a.sec != b.fir + b.sec)
    {
        return (a.fir + a.sec < b.fir + b.sec);
    }
    else
        return a.fir < b.fir;
}

bool cmp2(pll a, pll b)
{
    if (a.sec - a.fir != b.sec - b.fir)
    {
        return (a.sec - a.fir < b.sec - b.fir);
    }
    else
        return a.fir > b.fir;
}

void solve()
{
    ll n, k;
    read(n, k);
    for (int i = 0; i <= n + 5; i++)
    {
        pre[i] = INF;
    }

    for (int i = 0; i < k; i++)
    {
        read(a[i].fir);
    }
    for (int i = 0; i < k; i++)
    {
        read(a[i].sec);
    }
    sort(a, a + k, cmp);
    ll p = 0;
    for (ll i = 1; i <= n; i++)
    {
        if (p == k)
        {
            break;
        }
        while (a[p].fir < i)
        {
            p++;
            if (p == k)
            {
                break;
            }
        }
        if (p == k)
        {
            break;
        }
        pre[i] = min(pre[i], -i + a[p].fir + a[p].sec);
    }

    sort(a, a + k, cmp2);

    p = 0;
    for (ll i = n; i >= 0; i--)
    {
        if (p == k)
        {
            break;
        }
        while (a[p].fir > i)
        {
            p++;
            if (p == k)
            {
                break;
            }
        }
        if (p == k)
        {
            break;
        }
        pre[i] = min(pre[i], i - a[p].fir + a[p].sec);
    }
    for (int i = 1; i <= n; i++)
    {
        write(pre[i], ' ');
    }
    write(endl);
}