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:
// Lam lai cuoc doi thoiiiiiiiiii :)))))
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<list>
#define inf 99999999999999999
#define MOD 1000000007
#define endl "\n"
#define ll long long
//#define ll unsigned long long
#define forl(i,a,b) for(ll i=a;i<=b;i++)
#define forx(i,a,b) for(ll i=a;i>=b;i--)
#define fi first
#define se second



#define maxn 205
using namespace std;
//---------------------------------------KHAI BAO BIEN----------------------------------------------
typedef pair<long long,long long> ii;
typedef pair<ii,long long> iii;
typedef pair<int,int> pii;
typedef pair<long long,ii> piii;
int tdong[5]={0,1,-1,0,0};
int tcot[5]={0,0,0,1,-1};
char direct[5]={'A','U','D','L','R'};
int tdm[9]={0,-2,-2,-1,-1,1,1,2,2};
int tcm[9]={0,-1,1,-2,2,-2,2,-1,1};
ll t,n,m;
string cong( string s1,string s2)
{
    if(s1=="0" && s2=="0")return "0";
    if(s1.length()>s2.length())swap(s1,s2);
    s2="0"+s2;
    while(s1.length()!=s2.length())
    {
        s1="0"+s1;
    }
    int nho=0,nho_1=0;
    forx(i,s1.length()-1,0)
    {
        nho=(bool)(((int)s1[i]-48+(int)s2[i]-48)+nho_1>=10);
        s1[i]=(char)((((int)s1[i]-48+(int)s2[i]-48)+nho_1)%10+48);
        nho_1=nho;
        //cout<<s1<<" "<<s2<<" "<<nho<<endl;
    }

    while(s1[0]=='0')s1.erase(0,1);
    return s1;
}
ll ucln(ll a,ll b)
{
    while(a!=b && a!=0 && b!=0)
    {
        //cout<<a<<" "<<b<<endl;
        if(a>b)a=a%b;
        else b=b%a;
    }
    return max(a,b);
}
struct fenwick_tree
{
    ll tree[100005];
    ll mang[100005];
    void khoi_tao(ll max_n)
    {
        forl(i,0,max_n)tree[i]=0;
    }
    void update(ll to,ll value)
    {
        for(to;to<100004;to+=to&(-to))tree[to]=(tree[to]+value);
    }
    ll tinh_tong(ll to)
    {
        ll kq=0;
        if(to!=0)for(to;to>0;to-=to&(-to))kq=(kq+tree[to])%MOD;
        return kq;
    }
    ll sum(ll from,ll to)
    {
        return (tinh_tong(to)-tinh_tong(from-1))%MOD;
    }
    void update_gcd(ll to,ll value)
    {
        for(to;to<100004;to+=to&(-to))tree[to]=ucln(tree[to],value);
    }
    ll gcd_range(int l,int r)
    {
        ll kq=0;
        l--;
        while(r>l)
        {
           // cout<<r<<" "<<(r-(r&(-r)))<<" "<<l<<" "<<tree[r]<<endl;
            if((r-r&(-r))>=l)
            {
                kq=ucln(kq,tree[r]);
                r-=r&(-r);
            }
            else
            {
                kq=ucln(kq,mang[r]);
                r--;
            }
        }
        return kq;
    }
};
//---------------------------------------CHUONG TRINH CON-----------------------------------------------------
struct segment_tree
{
    ll lazy[200005],s_tree[200005];
    void khoi_tao()
    {
        forl(i,1,200004){lazy[i]=0;s_tree[i]=0;}
    }
    void update_range(ll vt,ll r_left,ll r_right,ll t_left,ll t_right,ll value)
    {
        if(lazy[vt]!=0)
        {
            s_tree[vt]+=lazy[vt];
            lazy[vt*2]+=lazy[vt];
            lazy[vt*2+1]+=lazy[vt];
            lazy[vt]=0;
        }
        if(r_left>t_right || t_left>r_right)return;
        else if(r_left<=t_left && r_right>=t_right)
        {
            s_tree[vt]+=value;
            lazy[vt*2]+=value;
            lazy[vt*2+1]+=value;
            return;
        }
        else
        {
            ll mid=(t_left+t_right)/2;
            update_range(vt*2,r_left,r_right,t_left,mid,value);
            update_range(vt*2+1,r_left,r_right,mid+1,t_right,value);
            //max,min
            s_tree[vt]=max(s_tree[vt*2],s_tree[vt*2+1]);
        }
    }
    ll max_range(ll vt,ll r_left,ll r_right,ll t_left,ll t_right )
    {
        if(lazy[vt]!=0)
        {
            s_tree[vt]+=lazy[vt];
            lazy[vt*2]+=lazy[vt];
            lazy[vt*2+1]+=lazy[vt];
            lazy[vt]=0;
        }
        if(r_left>t_right || r_right<t_left)return -inf;
        else if(r_left<=t_left && r_right>=t_right)return s_tree[vt];
        else
        {
            ll mid=(t_left+t_right)/2;
            return max(max_range(vt*2,r_left,r_right,t_left,mid),max_range(vt*2+1,r_left,r_right,mid+1,t_right));
        }
    }
};

ll toi_uu_nhan(ll a,ll b,ll mod)
{
    if(mod==0)return 999999999;
    if(a==0 || b==0 || mod==1)return 0;
    if(a<(mod/b+1))return a*b;
    a=a%mod;b=b%mod;

    if(a<b)swap(a,b);//a=5, b=2, mod=4
    ll tam=mod/a+(bool)(mod%a!=0);//tam=1
    ll mod_a=(a*tam)%mod;//mod_a=1
    ll need=b/tam;//need=2
    ll du=b-tam*need;//du=0
    ll con_lai=du*a;//con_lai=0
    //cout<<tam<<" "<<mod_a<<" "<<need<<" "<<du<<" "<<con_lai<<endl;
    return (toi_uu_nhan(mod_a,need,mod)+con_lai)%mod;// ((0*1)%10 + 5) %10 =5
}
ll pow_f(ll a,ll b,ll k)
{
    if(k==0)return 99999999999999;
    if(k==1)return 0;
    ll kq=1;
    a%=k;
    while(b>0)
    {
        if(b%2!=0){kq=toi_uu_nhan(kq,a,k);}
        a=toi_uu_nhan(a,a,k);
        b/=2;//cout<<a<<" "<<b<<" "<<kq<<endl;
    }
    return kq;
}
/*    int parent[100005];
    bool visit[100005];
    long long d[100005],table[2005][2005];
int getmin()
{
    ll dd=inf,u=0;
    forl(i,1,n)if(!visit[i] && d[i]<dd){dd=d[i];u=i;}
    return u;
}
void prim(int s)
{
    forl(i,1,n){visit[i]=false;d[i]=inf;}
    d[s]=0;
    while(true)
    {
        int u=getmin();
        //cout<<u<<endl;
        if(u==0)break;
        visit[u]=true;
        forl(i,1,n)
        {
            if(!visit[i])d[i]=min(d[i],table[u][i]);
        }
    }
}
ll distra(int s,int t)
{
    forl(i,1,n){visit[i]=false;d[i]=inf;}
    d[s]=0;
    while(true)
    {
        int u=getmin();
        //cout<<u<<endl;
        if(u==0 || u==t)return d[t];
        visit[u]=true;
        forl(i,1,n)
        {
            if(!visit[i])d[i]=min(d[i],max(table[u][i],d[u]));
        }
    }
}
struct DSU
{
    int r[100005];int sl[100005];
    int find_parent(int a)
    {
        if(parent[a]==a)return parent[a];
        else return parent[a]=find_parent(parent[a]);
    }
    void join(int a,int b)
    {
        a=find_parent(a);
        b=find_parent(b);
        if(r[b]>r[a]){parent[a]=b;sl[b]+=sl[a];}
        else {parent[b]=a;sl[a]+=sl[b];r[a]++;}
    }

};
bool check(int i,int j,int n,int m)
{
    return(i>=1 && j>=1 && i<=n && j<=m);
}
struct edge
{
    ll ii,jj,ww;
    edge(int ii,int jj, int ww)
    {
        this->ii=ii;
        this->jj=jj;
        this->ww=ww;
    }
};
void distra_heap(int s,int t,vector<ii> canh[])
{
    forl(i,1,n){d[i]=inf;visit[i]=false;}
    d[s]=0;
    priority_queue<ii, vector<ii>, greater<ii> > pq;
    pq.push(ii(0,s));
    while(!pq.empty())
    {
        int u=pq.top().second;
        pq.pop();
        if(visit[u])continue;
        visit[u]=true;
        forl(i,0,canh[u].size()-1)
        {
            d[canh[u][i].first]=min(d[canh[u][i].first],d[u]+canh[u][i].second);
            pq.push(ii( d[canh[u][i].first],canh[u][i].first));
        }
    }
}
bool kt[1000005];

vector<ll> snt;
void sang()
{
    forl(i,1,50001)kt[i]=false;
    kt[2]=1;
    snt.push_back(2);
    ll vt=3;
    while(vt<=50000)
    {
        while(kt[vt] && vt<=50000)vt+=2;
        kt[vt]=true;snt.push_back(vt);//cout<<vt<<endl;
        for(ll k=vt*vt;k<=50000;k+=vt){if(k<50000)kt[k]=true;}
    }
}*/
//---------------------------------------CHUONG TRINH CHINH--------------------------------------------------
int bb[19];
/*void bin(int x,int sl)
{
    stack<int> s;
    int dem=0;
    while(x>0)
    {
        if(x%2!=0)s.push(1);
        else s.push(0);
        x/=2;
        dem++;
    }
    while(dem<sl){s.push(0);dem++;}
    while(!s.empty()){cout<<s.top();s.pop();}
    cout<<endl;
}

string intostring(ll a)
{
    stack<int> st;
    while(a>0)
    {
        st.push(a%10);
        a/=10;
    }
    string s;
    while(!st.empty())
    {
        s+=(char)(st.top()+'0');st.pop();
    }
    return s;
}*/

/**/
struct combinatoric
{
    ll gt[100005],nghich_dao[100004];
    void gt_va_nghichdao()
    {
        gt[0]=nghich_dao[0]=1;
        forl(i,1,100001)
        {
            gt[i]=(gt[i-1]*i)%MOD;
        }
        nghich_dao[100001]=pow_f(gt[100001],MOD-2,MOD);
        forx(i,100000,0)nghich_dao[i]=(nghich_dao[i+1]*(i+1))%MOD;
    }
    ll nck(ll n,ll k)
    {
        if(n<k || n<0 || k<0)return 0;
        else return  1LL* gt[n] * nghich_dao[n-k] % MOD *nghich_dao[k] % MOD;
    }
    ll nak(ll n,ll k)
    {
        if(n<k || n<0 || k<0)return 0;
        else return 1LL* gt[n] * nghich_dao[n-k] % MOD;
    }
};
/*int fn(ll s1,ll s2,ll m)
{
    if(s1<=s2){return (s2-s1);}
    ll tam=s1-s2;
    ll kq=tam/m+(tam%m!=0);
    return kq*m+s2-s1;
}
bool ch(ll n,ll adj[],ll m)
{
    ll tam=fn(adj[1],adj[2],m);
    forl(i,3,n)if((adj[i]+m-tam)%m!=adj[i-1])return false;
    return true;
}

struct matran
{
    ll m[4][4];
};
matran nhanmatran(matran a,matran b,ll sz)
{
    matran kq;
    forl(i,1,sz)
        forl(j,1,sz)kq.m[i][j]=0;
    forl(i,1,sz)
        forl(j,1,sz)
            forl(k,1,sz)kq.m[i][j]=(kq.m[i][j]+a.m[i][k]*b.m[k][j])%MOD;
    return kq;
}
matran luythuamatran(matran a,ll b,ll sz)
{
    matran kq=a;
    while(b>0)
    {
        if(b%2!=0){kq=nhanmatran(a,kq,sz);}
        a=nhanmatran(a,a,sz);
        b/=2;//cout<<a<<" "<<b<<" "<<kq<<endl;
        //cout<<kq.m[1][1]<<" "<<kq.m[1][2]<<endl;
        //cout<<kq.m[2][1]<<" "<<kq.m[2][2]<<endl;
        //cout<<b<<" "<<endl;
    }
    return kq;
}
ll fibo(ll k)
{
    if(k<1)return 1;
    matran a;
    a.m[1][1]=0;a.m[1][2]=1;a.m[2][1]=1;a.m[2][2]=1;
    matran tam=luythuamatran(a,k,2);
    return tam.m[2][2];
}*/
stack<int> st;
void dfs(int s,bool visit[],vector<int>v[])
{
    //cout<<s<<endl;
    visit[s]=true;
    if(v[s].size()>0)
    forl(i,0,v[s].size()-1)
    {
        int j=v[s][i];
        if(!visit[j]){dfs(j,visit,v);}
    }
    st.push(s);
}
void bfs(int from,int to,int step,bool visit[],int d[],int parent[])
{
    forl(i,0,n){d[i]=99999999;visit[i]=false;parent[i]=i;}
    d[from]=0;
    queue<int> q;
    q.push(from);
    while(!q.empty())
    {
        int u=q.front();q.pop();if(visit[u] || u>to)continue;
       // cout<<u<<" "<<d[u]<<" "<<parent[u]<<endl;
        visit[u]=true;
        if(u==to)break;
        if(u==from){d[u+step]=d[u]+1;parent[u+step]=from;q.push(u+step);}
        else
        {
            int n0=step+1,n1=-1;
            for(int i=-step;i<=step;i+=2)
            {
                n0--;n1++;
                int v=to-u;//u:bit 1;v:bit 0
                if(n0>u || n1>v){continue;}
                if(u+i<=to && u+i>=0)if(!visit[u+i] && d[u+i]>d[u]+1){d[u+i]=d[u]+1;parent[u+i]=u;q.push(u+i);}
                if(u==-1)
                {
                    cout<<"* "<<i<<endl;
                    cout<<n0<<" "<<n1<<endl;
                    cout<<u<<" "<<v<<endl;
                }
            }
        }
    }
}
bool comp (const pii &g1, const pii &g2)
{
    if(g1.fi!=g2.fi)return g1.first<g2.first;
    return g1.second>g2.second;
}

int main()
{
/**/#ifndef ONLINE_JUDGE
   freopen("test.inp","r",stdin);
   freopen("test.out","w",stdout);
#endif // ONLINE_JUDGE          //『 』
   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

   //cin.ignore();
   //cout<<fixed;
   //cout<<setprecision(6);
   /**/
    t=1;cin>>t;
    int cas=0,cc=0;
    ll ans,k;
    //--------------
    while(t--)
    {
        int n,k;cin>>n>>k;int a[k+5], tp[k+5];
        int h[n+5];
        forl(i,1,n)h[i]=0;
        forl(i,1,k){cin>>a[i];}
        forl(i,1,k){cin>>tp[i];h[a[i]]=tp[i]+a[i];}
        set<ii> s;
        forl(i,1,k)s.insert(ii(tp[i]+a[i],a[i]));
        s.insert(ii(1e10,1e10));
        ll l=1e15,cur=1e15,nl=0,nr=0;
        forl(i,1,n)
        {
            nr--;l++;
            if(h[i])
            {
                //cout<<"---"<<h[i]<<" "<<i<<endl;
                auto it=s.lower_bound(ii(h[i],i));
                cur=it->first-it->second;
               // cur+=nr;
               //cout<<it->first<<" "<<it->second<<endl;
                s.erase(it);
                //cout<<"cur="<<cur<<endl;
                if(cur<l)l=cur;
            }
            //cout<<s.begin()->fi<<" "<<nr<<" l="<<l<<endl;
            cout<<min(s.begin()->fi+nr,l)<<" ";
        }cout<<endl;
    }
}