Problem: You like numbers, don't you? Nastia has a lot of numbers and she wants to share them with you! Isn't it amazing?

Let a_i be how many numbers i (1 ≤ i ≤ k) you have.

An n × n matrix is called beautiful if it contains all the numbers you have, and for each 2 × 2 submatrix of the original matrix is satisfied: 

  1. The number of occupied cells doesn't exceed 3; 
  2. The numbers on each diagonal are distinct. 



Make a beautiful matrix of minimum size.

Input

The first line contains a single integer t (1 ≤ t ≤ 10 000) — the number of test cases.

The first line of each test case contains 2 integers m and k (1 ≤ m, k ≤ 10^5) — how many numbers Nastia gave you and the length of the array a, respectively.

The second line of each test case contains k integers a_1, a_2, …, a_{k} (0 ≤ a_i ≤ m, a_1 + a_2 + … + a_{k} = m), where a_i is how many numbers i you have.

It's guaranteed that the sum of m and k in one test doesn't exceed 2 ⋅ 10^5.

Output

For each t test case print a single integer n — the size of the beautiful matrix.

In the next n lines print n integers b_{i, j} (0 ≤ b_{i, j} ≤ k; if position is empty, print b_{i, j} = 0) — the beautiful matrix b you made up. 

Example

Input


2
3 4
2 0 0 1
15 4
2 4 8 1


Output


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

Note

Note that 0 in this problem represents a blank, not a number.

Examples of possible answers for the first test case:

\begin{array}{cc} 1 & 1 \\\ 4 & 0 \\\ \end{array} \hspace{0,5cm} \begin{array}{cc} 1 & 4 \\\ 1 & 0 \\\ \end{array} \hspace{0,5cm} \begin{array}{cc} 4 & 0 \\\ 1 & 1 \\\ \end{array}

Examples of not beautiful matrices for the first test case:

\begin{array}{cc} 1 & 0 \\\ 4 & 1 \\\ \end{array} \hspace{0,5cm} \begin{array}{cc} 4 & 1 \\\ 7 & 1 \\\ \end{array} \hspace{0,5cm} \begin{array}{cc} 1 & 0 \\\ 4 & 0 \\\ \end{array}

The example of the not beautiful matrix for the second test case:

\begin{array}{cc} 3 & 4 & 0 & 2 & 2 \\\ 3 & 2 & 3 & 3 & 0 \\\ 0 & 1 & 0 & 0 & 0 \\\ 3 & 0 & 0 & 0 & 0 \\\ 2 & 1 & 3 & 3 & 3 \\\ \end{array}

Everything is okay, except the left-top submatrix contains 4 numbers.

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#include "debug.h"
#endif

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vch;
typedef vector<vch> vvch;

#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define repi(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define pb push_back
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())

template<typename T> void umin(T &a, T b) { a = min(a, b); }
template<typename T> void umax(T &a, T b) { a = max(a, b); }

ll nxt() {
	ll x; cin >> x; return x;
}

void setIO(string s) {
	#ifndef LOCAL
	ios_base::sync_with_stdio(0); cin.tie(0); 
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
	#endif
}

void yes() {
	cout << "yes\n";
}

void no() {
	cout << "no\n";
}

void flush() {
	debug("#################");
}

const ll mod = 1e9 + 7;
const ll INF = 1e9;

void solve() {
  int m, k; cin >> m >> k;
  vi cnt(k + 1);

  rep(i, 1, k + 1) {
    cnt[i] = nxt();
  }

  int mx = *max_element(all(cnt));
  int mxid = -1;
  rep(i, 1, k + 1) if (cnt[i] == mx) mxid = i;

  int lo = 1, hi = 200005;
  while (lo < hi) {
    int mid = (lo + hi) / 2;
    ll one = 1LL * mid * mid - 1LL * (mid / 2) * (mid / 2);
    ll two = 1LL * mid * ((mid + 1) / 2);
    if (one >= m && two >= mx) {
      hi = mid;
    } else {
      lo = mid + 1;
    }
  }

  int n = lo;
  vvi a(n + 1, vi(n + 1));

  vpi filling_order;
  rep(i, 1, k + 1) filling_order.pb({cnt[i], i});
  sort(all(filling_order)); reverse(all(filling_order));

  vi order;
  for (auto it : filling_order) {
    rep(i, 0, it.fi) order.pb(it.se);
  }

  assert(sz(order) == m);
  int ptr = 0;
  int done = 0;
  for (int row = 2; row <= n; row += 2) {
    for (int col = 1; col <= n; col += 2) {
      if (done >= mx) break;
      a[row][col] = order[ptr++];
      done++;
    }
  }

  if (done < mx) {
    for (int row = 1; row <= n; row += 2) {
      for (int col = 1; col <= n; col += 2) {
        if (done >= mx) break;
        a[row][col] = order[ptr++];
        done++;
      }
    }
  } else {
    for (int row = 2; row <= n; row += 2) for (int col = 1; col <= n; col += 2) {
      if (ptr >= m) break;
      if (a[row][col] == 0) a[row][col] = order[ptr++];
    }
  }
  //all reds are filled

  //fill all non-filled
  for (int row = 1; row <= n; row++) {
    int add = 2;
    if (row % 2 == 1) {
      add = 1;
    }
    for (int col = 1; col <= n; col += add) {
      if (a[row][col] == 0 && ptr < m) {
        a[row][col] = order[ptr++];
      }
    }
  }

  cout << n << endl;
  for (int row = 1; row <= n; row++) {
    for (int col = 1; col <= n; col++) {
      cout << a[row][col] << " ";
    }
    cout << endl;
  }

  flush();
  for (int row = 1; row <= n; row++) for (int col = 1; col <= n; col++) {
    debug(row, col);
    if (row + 1 <= n && col + 1 <= n && a[row][col] != 0 && a[row + 1][col + 1] != 0) assert(a[row][col] != a[row + 1][col + 1]);
    if (row + 1 <= n && col - 1 >= 1 && a[row][col] != 0 && a[row + 1][col - 1] != 0) assert(a[row][col] != a[row + 1][col - 1]);

    if (row + 1 <= n && col + 1 <= n) assert(a[row][col] == 0 or a[row][col + 1] == 0 or a[row + 1][col] == 0 or a[row + 1][col + 1] == 0);
  }
}	

	
int32_t main(){
	// setIO("trapped");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cout << fixed << setprecision(10);

	int T = 1;
	cin >> T;

	for (int tc = 1; tc <= T; tc++) {
		// cout << "Case #" << tc << ": ";
		solve();
	}
}