Problem: Sasha likes investigating different math objects, for example, magic squares. But Sasha understands that magic squares have already been studied by hundreds of people, so he sees no sense of studying them further. Instead, he invented his own type of square — a prime square. 

A square of size n × n is called prime if the following three conditions are held simultaneously: 

  * all numbers on the square are non-negative integers not exceeding 10^5; 
  * there are no prime numbers in the square; 
  * sums of integers in each row and each column are prime numbers. 



Sasha has an integer n. He asks you to find any prime square of size n × n. Sasha is absolutely sure such squares exist, so just help him!

Input

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

Each of the next t lines contains a single integer n (2 ≤ n ≤ 100) — the required size of a square.

Output

For each test case print n lines, each containing n integers — the prime square you built. If there are multiple answers, print any.

Example

Input


2
4
2


Output


4 6 8 1
4 9 9 9
4 10 10 65
1 4 4 4
1 1
1 1

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
void addwedge(vector<pair<long long int, long long int>> adj[], long long int u,
              long long int v, long long int wt) {
  adj[u].push_back(make_pair(v, wt));
  adj[v].push_back(make_pair(u, wt));
}
void addedge(vector<long long int> adj[], long long int u, long long int v) {
  adj[u].push_back(v);
  adj[v].push_back(u);
}
vector<long long int> shortestpath(
    vector<pair<long long int, long long int>> adj[], long long int V,
    long long int src) {
  priority_queue<pair<long long int, long long int>,
                 vector<pair<long long int, long long int>>,
                 greater<pair<long long int, long long int>>>
      pq;
  vector<long long int> dist(V, 9e+18);
  pq.push(make_pair(0, src));
  dist[src] = 0;
  while (!pq.empty()) {
    long long int u = pq.top().second;
    pq.pop();
    for (auto x : adj[u]) {
      long long int v = x.first;
      long long int weight = x.second;
      if (dist[v] > dist[u] + weight) {
        dist[v] = dist[u] + weight;
        pq.push(make_pair(dist[v], v));
      }
    }
  }
  return dist;
}
void buildsegment(long long int arr[], long long int tree[], long long int n) {
  for (long long int i = 0; i < n; i++) tree[n + i] = arr[i];
  for (long long int i = n - 1; i > 0; --i)
    tree[i] = tree[i << 1] + tree[i << 1 | 1];
}
void updatesegment(long long int p, long long int value, long long int tree[],
                   long long int n) {
  tree[p + n] = value;
  p = p + n;
  for (long long int i = p; i > 1; i >>= 1)
    tree[i >> 1] = tree[i] + tree[i ^ 1];
}
long long int querysegment(long long int l, long long int r,
                           long long int tree[], long long int n) {
  long long int res = 0;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) res += tree[l++];
    if (r & 1) res += tree[--r];
  }
  return res;
}
long long int findpar(long long int numb, long long int par[]) {
  if (par[numb] == numb)
    return numb;
  else
    return par[numb] = findpar(par[numb], par);
}
void setpar(long long int u1, long long int v1, long long int par[]) {
  long long int s1 = findpar(v1, par);
  long long int s2 = findpar(u1, par);
  if (s1 < s2) {
    par[s2] = s1;
  } else {
    par[s1] = s2;
  }
}
long long int extended_GCD(long long int a, long long int b, long long int& x,
                           long long int& y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long int x1, y1;
  long long int gcd = extended_GCD(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return gcd;
}
long long int modinv(long long int a, long long int mod = 1000000007) {
  long long int x, y;
  extended_GCD(a, mod, x, y);
  if (x < 0) x += mod;
  return x;
}
long long int power(long long int a, long long int b,
                    long long int m = 1000000007) {
  a %= m;
  long long int ans = 1;
  while (b > 0) {
    if (b & 1) ans = ans * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return ans;
}
vector<long long int> nge(long long int arr[], long long int n) {
  stack<long long int> s;
  vector<long long int> ans(n, -1);
  s.push(0);
  for (long long int i = 1; i < n; i++) {
    if (s.empty()) {
      s.push(i);
      continue;
    }
    while (s.empty() == false && arr[s.top()] < arr[i]) {
      ans[s.top()] = i;
      s.pop();
    }
    s.push(i);
  }
  return ans;
}
void swap(long long int& a, long long int& b) {
  long long int temp = a;
  a = b;
  b = temp;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1, n;
  cin >> t;
  while (t--) {
    cin >> n;
    long long int ans = -1;
    for (long long int i = 1; i <= n; i++) {
      long long int ctr = 0;
      for (int j = 2; j * j <= i; j++) {
        if (i % j == 0) {
          ctr++;
          break;
        }
      }
      if (ctr == 0) ans = i;
    }
    long long int z = n - ans;
    deque<long long int> dq;
    for (long long int i = 1; i <= z; i++) {
      dq.push_back(0);
    }
    for (long long int i = 1; i <= n - z; i++) {
      dq.push_back(1);
    }
    deque<long long int>::iterator it;
    for (long long int i = 1; i <= n; i++) {
      for (it = dq.begin(); it != dq.end(); ++it) cout << *it << " ";
      cout << '\n';
      long long int val = dq.back();
      dq.pop_back();
      dq.push_front(val);
    }
  }
  return 0;
}