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:
#ifdef LOCAL
#pragma warning(disable:4996)
#pragma warning(disable:4244)
#pragma warning(disable:4554)
#define gets gets_s

#endif
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<stack>
#include<queue>
#include<cmath>
#include<vector>
#include<string>
#include<cctype>
#include<cstdio>
#include<bitset>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<assert.h>
#define ll long long
#define cl(a,x) memset((a),(x),sizeof(a))
#define lson 2*i
#define rson 2*i+1
#define sf scanf
#define ull unsigned long long
#define lowbit(x) (x)&(-x)
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pdd pair<double,double>
#define ti tree[i]
#define endl "\n"
#define debug(num) #num << "=" << num << " "
ll q_pow(ll x, ll n, ll mod) { ll ret = 1; while (n) { if (n & 1) ret = x * ret%mod; x = x * x%mod; n >>= 1; }return ret; }
ll __gcd(ll x, ll y) { if (!y) return x; return __gcd(y, x%y); }
ll getbit(ll now) { int cnt = 0; while (now) { cnt++; now -= lowbit(now); }return cnt; }
int dx[] = { -1,1,0,0 };//上下左右
int dy[] = { 0,0,-1,1 };//
using namespace std;
const ll maxn = 1e5 + 10;
const ll INF = 0x3f3f3f3f;
const ll IINF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
int mod = 1e9 + 7;
void add(ll &a, ll num) { a += num; if (a >= mod) a -= mod; }

vector<vector<int> > ans;
ll m, k;
ll a[maxn];

void solve() {
	cin >> m >> k;
	for (int i = 1; i <= k; i++)
		cin >> a[i];
	
	ll maxnum = 0;
	for (int i = 1; i <= k; i++) {
		maxnum = max(maxnum, a[i]);
	}

	int le = 0, ri = INF;
	while (le + 1 < ri) {
		ll mid = le + ri >> 1;
		ll nownum = mid * ((mid + 1) / 2);
		ll delta = mid * ((mid + 1) / 2) + ((mid) / 2) * ((mid + 1) / 2);
		if (nownum >= maxnum and delta >= m) ri = mid;
		else le = mid;
	}

	//cerr << debug(le) << debug(ri) << endl;
	
	ans.clear();
	int len = ri;
	ans.resize(len + 1);
	for (int i = 1; i <= len; i++)
		ans[i].resize(len + 1);

	vector<pii> vec[3];
	for(int i = 1;i <= len;i++)
		for (int j = 1; j <= len; j++) {
			if (i % 2 == 1 and j % 2 == 1) vec[0].emplace_back(make_pair(i, j));
			else if (i % 2 == 1 and j % 2 == 0) vec[1].emplace_back(make_pair(i, j));
			else if (i % 2 == 0 and j % 2 == 1) vec[2].emplace_back(make_pair(i, j));
		}

	vector<pii> pos;
	for (int i = 1; i <= k; i++) {
		pos.emplace_back(make_pair(a[i], i));
	}

	sort(pos.begin(), pos.end());

	for (int i = pos.size() - 1; i >= 0; i--) {
		int now = 0;
		if (vec[1].size() > vec[2].size()) now = 1;
		else now = 2;
		for (int j = 1; j <= pos[i].first; j++) {
			if (vec[now].size() != 0) {
				pii tmp = *vec[now].rbegin();
				vec[now].pop_back();
				ans[tmp.first][tmp.second] = pos[i].second;
			}
			else {
				pii tmp = *vec[0].rbegin();
				vec[0].pop_back();
				ans[tmp.first][tmp.second] = pos[i].second;
			}
			//cerr << debug(vec[0].size()) << endl;
		}
	}

	cout << len << endl;
	for (int i = 1; i <= len; i++) {
		for (int j = 1; j <= len; j++) {
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}

}

signed main(int argc, char *argv[]) {
	if (argc == 2 && strcmp("-debug", argv[1]) == 0) {
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}

	cout << fixed << setprecision(20); ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t = 1;
	cin >> t;

	while (t--) {
		solve();
	}

	return 0;
}