#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast", "inline")
using namespace std;
const long long INF(0x3f3f3f3f3f3f3f3fll);
const long long inf(0x3f3f3f3f);
template <typename T>
void read(T &res) {
  bool flag = false;
  char ch;
  while (!isdigit(ch = getchar())) (ch == '-') && (flag = true);
  for (res = ch - 48; isdigit(ch = getchar());
       res = (res << 1) + (res << 3) + ch - 48)
    ;
  flag && (res = -res);
}
template <typename T>
void Out(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) Out(x / 10);
  putchar(x % 10 + '0');
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long pow_mod(long long x, long long n, long long mod) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
long long fact_pow(long long n, long long p) {
  long long res = 0;
  while (n) {
    n /= p;
    res += n;
  }
  return res;
}
long long mult(long long a, long long b, long long p) {
  a %= p;
  b %= p;
  long long r = 0, v = a;
  while (b) {
    if (b & 1) {
      r += v;
      if (r > p) r -= p;
    }
    v <<= 1;
    if (v > p) v -= p;
    b >>= 1;
  }
  return r;
}
long long quick_pow(long long a, long long b, long long p) {
  long long r = 1, v = a % p;
  while (b) {
    if (b & 1) r = mult(r, v, p);
    v = mult(v, v, p);
    b >>= 1;
  }
  return r;
}
bool CH(long long a, long long n, long long x, long long t) {
  long long r = quick_pow(a, x, n);
  long long z = r;
  for (long long i = 1; i <= t; i++) {
    r = mult(r, r, n);
    if (r == 1 && z != 1 && z != n - 1) return true;
    z = r;
  }
  return r != 1;
}
bool Miller_Rabin(long long n) {
  if (n < 2) return false;
  if (n == 2) return true;
  if (!(n & 1)) return false;
  long long x = n - 1, t = 0;
  while (!(x & 1)) {
    x >>= 1;
    t++;
  }
  srand(time(NULL));
  long long o = 8;
  for (long long i = 0; i < o; i++) {
    long long a = rand() % (n - 1) + 1;
    if (CH(a, n, x, t)) return false;
  }
  return true;
}
long long exgcd1(long long a, long long b, long long &x, long long &y) {
  if (!b) {
    x = 1, y = 0;
    return a;
  }
  long long t = exgcd1(b, a % b, y, x);
  y -= a / b * x;
  return t;
}
long long get_inv(long long a, long long mod) {
  long long x, y;
  long long d = exgcd1(a, mod, x, y);
  return d == 1 ? (x % mod + mod) % mod : -1;
}
void exgcd(long long a, long long b, long long &x, long long &y) {
  if (!b) {
    x = 1, y = 0;
    return;
  }
  exgcd(b, a % b, x, y);
  long long t = x;
  x = y, y = t - (a / b) * y;
}
long long INV(long long a, long long b) {
  long long x, y;
  return exgcd(a, b, x, y), (x % b + b) % b;
}
long long crt(long long x, long long p, long long mod) {
  return INV(p / mod, mod) * (p / mod) * x;
}
long long FAC(long long x, long long a, long long b) {
  if (!x) return 1;
  long long ans = 1;
  for (long long i = 1; i <= b; i++)
    if (i % a) ans *= i, ans %= b;
  ans = pow_mod(ans, x / b, b);
  for (long long i = 1; i <= x % b; i++)
    if (i % a) ans *= i, ans %= b;
  return ans * FAC(x / a, a, b) % b;
}
long long C(long long n, long long m, long long a, long long b) {
  long long N = FAC(n, a, b), M = FAC(m, a, b), Z = FAC(n - m, a, b), sum = 0,
            i;
  for (i = n; i; i = i / a) sum += i / a;
  for (i = m; i; i = i / a) sum -= i / a;
  for (i = n - m; i; i = i / a) sum -= i / a;
  return N * pow_mod(a, sum, b) % b * INV(M, b) % b * INV(Z, b) % b;
}
long long exlucas(long long n, long long m, long long p) {
  long long t = p, ans = 0, i;
  for (i = 2; i * i <= p; i++) {
    long long k = 1;
    while (t % i == 0) {
      k *= i, t /= i;
    }
    ans += crt(C(n, m, i, k), p, k), ans %= p;
  }
  if (t > 1) ans += crt(C(n, m, t, t), p, t), ans %= p;
  return ans % p;
}
long long prime[100000], minprime[100000];
long long euler(long long n) {
  long long c = 0, i, j;
  for (i = 2; i <= n; i++) {
    if (!minprime[i]) prime[++c] = i, minprime[i] = i;
    for (j = 1; j <= c && i * prime[j] <= n; j++) {
      minprime[i * prime[j]] = prime[j];
      if (i % prime[j] == 0) break;
    }
  }
  return c;
}
struct Tree {
  long long l, r, sum, lazy, maxn, minn;
} tree[100000];
inline void push_up(long long rt) {
  tree[rt].sum = tree[rt << 1].sum + tree[rt << 1 | 1].sum;
  tree[rt].maxn = max(tree[rt << 1].maxn, tree[rt << 1 | 1].maxn);
  tree[rt].minn = min(tree[rt << 1].minn, tree[rt << 1 | 1].minn);
}
inline void push_down(long long rt, long long length) {
  if (tree[rt].lazy) {
    tree[rt << 1].lazy += tree[rt].lazy;
    tree[rt << 1 | 1].lazy += tree[rt].lazy;
    tree[rt << 1].sum += (length - (length >> 1)) * tree[rt].lazy;
    tree[rt << 1 | 1].sum += (length >> 1) * tree[rt].lazy;
    tree[rt << 1].minn += tree[rt].lazy;
    tree[rt << 1 | 1].minn += tree[rt].lazy;
    tree[rt << 1].maxn += tree[rt].lazy;
    tree[rt << 1 | 1].maxn += tree[rt].lazy;
    tree[rt].lazy = 0;
  }
}
inline void build(long long l, long long r, long long rt, long long *aa) {
  tree[rt].lazy = 0;
  tree[rt].l = l;
  tree[rt].r = r;
  if (l == r) {
    tree[rt].sum = aa[l];
    tree[rt].minn = tree[rt].sum;
    tree[rt].maxn = tree[rt].sum;
    return;
  }
  long long mid = (l + r) >> 1;
  build(l, mid, rt << 1, aa);
  build(mid + 1, r, rt << 1 | 1, aa);
  push_up(rt);
}
inline void update_range(long long L, long long R, long long key,
                         long long rt) {
  if (tree[rt].r < L || tree[rt].l > R) return;
  if (L <= tree[rt].l && R >= tree[rt].r) {
    tree[rt].sum += (tree[rt].r - tree[rt].l + 1) * key;
    tree[rt].minn += key;
    tree[rt].maxn += key;
    tree[rt].lazy += key;
    return;
  }
  push_down(rt, tree[rt].r - tree[rt].l + 1);
  long long mid = (tree[rt].r + tree[rt].l) >> 1;
  if (L <= mid) update_range(L, R, key, rt << 1);
  if (R > mid) update_range(L, R, key, rt << 1 | 1);
  push_up(rt);
}
inline long long query_range(long long L, long long R, long long rt) {
  if (L <= tree[rt].l && R >= tree[rt].r) {
    return tree[rt].sum;
  }
  push_down(rt, tree[rt].r - tree[rt].l + 1);
  long long mid = (tree[rt].r + tree[rt].l) >> 1;
  long long ans = 0;
  if (L <= mid) ans += query_range(L, R, rt << 1);
  if (R > mid) ans += query_range(L, R, rt << 1 | 1);
  return ans;
}
inline long long query_min(long long L, long long R, long long rt) {
  if (L <= tree[rt].l && R >= tree[rt].r) {
    return tree[rt].minn;
  }
  push_down(rt, tree[rt].r - tree[rt].l + 1);
  long long mid = (tree[rt].r + tree[rt].l) >> 1;
  long long ans = (0x3f3f3f3f3f3f3f3fll);
  if (L <= mid) ans = min(ans, query_min(L, R, rt << 1));
  if (R > mid) ans = min(ans, query_min(L, R, rt << 1 | 1));
  return ans;
}
inline long long query_max(long long L, long long R, long long rt) {
  if (L <= tree[rt].l && R >= tree[rt].r) {
    return tree[rt].maxn;
  }
  push_down(rt, tree[rt].r - tree[rt].l + 1);
  long long mid = (tree[rt].r + tree[rt].l) >> 1;
  long long ans = -(0x3f3f3f3f3f3f3f3fll);
  if (L <= mid) ans = max(ans, query_max(L, R, rt << 1));
  if (R > mid) ans = max(ans, query_max(L, R, rt << 1 | 1));
  return ans;
}
namespace linear_seq {
const long long N = 1e5 + 10, mod = 1e9 + 7;
long long Rx[N], Ba[N], _c[N], _md[N];
vector<long long> Md;
long long PMD(long long a, long long b) {
  long long Rx = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) Rx = Rx * a % mod;
    a = a * a % mod;
  }
  return Rx;
}
void MUL(long long *a, long long *b, long long k) {
  for (long long i = 0; i < k + k; i++) _c[i] = 0;
  for (long long i = 0; i < k; i++)
    if (a[i])
      for (long long j = 0; j < k; j++)
        _c[i + j] = (_c[i + j] + a[i] * b[j]) % mod;
  for (long long i = k + k - 1; i >= k; i--)
    if (_c[i])
      for (long long j = 0; j < ((long long)(Md).size()); j++)
        _c[i - k + Md[j]] = (_c[i - k + Md[j]] - _c[i] * _md[Md[j]]) % mod;
  for (long long i = 0; i < k; i++) a[i] = _c[i];
}
long long Solve(long long n, vector<long long> a, vector<long long> b) {
  long long ans = 0, pnt = 0, k = a.size();
  assert(((long long)(a).size()) == ((long long)(b).size()));
  for (long long i = 0; i < k; i++) _md[k - 1 - i] = -a[i];
  _md[k] = 1;
  Md.clear();
  for (long long i = 0; i < k; i++)
    if (_md[i] != 0) Md.push_back(i);
  for (long long i = 0; i < k; i++) Rx[i] = Ba[i] = 0;
  Rx[0] = 1;
  while ((1ll << pnt) <= n) pnt++;
  for (long long p = pnt; p >= 0; p--) {
    MUL(Rx, Rx, k);
    if ((n >> p) & 1) {
      for (long long i = k - 1; i >= 0; i--) Rx[i + 1] = Rx[i];
      Rx[0] = 0;
      for (long long j = 0; j < ((long long)(Md).size()); j++)
        Rx[Md[j]] = (Rx[Md[j]] - Rx[k] * _md[Md[j]]) % mod;
    }
  }
  for (long long i = 0; i < k; i++) ans = (ans + Rx[i] * b[i]) % mod;
  if (ans < 0) ans += mod;
  return ans;
}
vector<long long> BM(vector<long long> s) {
  vector<long long> C(1, 1), B(1, 1);
  long long L = 0, m = 1, b = 1;
  for (long long n = 0; n < ((long long)(s).size()); n++) {
    long long d = 0;
    for (long long i = 0; i < L + 1; i++)
      d = (d + (long long)C[i] * s[n - i]) % mod;
    if (d == 0)
      ++m;
    else if (2 * L <= n) {
      vector<long long> T = C;
      long long c = mod - d * PMD(b, mod - 2) % mod;
      while (((long long)(C).size()) < ((long long)(B).size()) + m)
        C.push_back(0);
      for (long long i = 0; i < ((long long)(B).size()); i++)
        C[i + m] = (C[i + m] + c * B[i]) % mod;
      L = n + 1 - L;
      B = T;
      b = d;
      m = 1;
    } else {
      long long c = mod - d * PMD(b, mod - 2) % mod;
      while (((long long)(C).size()) < ((long long)(B).size()) + m)
        C.push_back(0);
      for (long long i = 0; i < ((long long)(B).size()); i++)
        C[i + m] = (C[i + m] + c * B[i]) % mod;
      ++m;
    }
  }
  return C;
}
long long Gao(vector<long long> a, long long n) {
  vector<long long> c = BM(a);
  c.erase(c.begin());
  n--;
  for (long long i = 0; i < ((long long)(c).size()); i++)
    c[i] = (mod - c[i]) % mod;
  return Solve(
      n, c, vector<long long>(a.begin(), a.begin() + ((long long)(c).size())));
}
};  // namespace linear_seq
const long long N = 3e5 + 10;
struct Edge {
  long long nex, to;
} edge[N << 1];
long long head[N], TOT;
void add_edge(long long u, long long v) {
  edge[++TOT].nex = head[u];
  edge[TOT].to = v;
  head[u] = TOT;
}
long long a[N];
vector<pair<pair<long long, long long>, long long>> vec;
signed main() {
  std::ios::sync_with_stdio(false);
  long long T = 1;
  cin >> T;
  while (T--) {
    vec.clear();
    long long n, sum = 0;
    cin >> n;
    for (long long i = 1; i <= n; i++) cin >> a[i], sum += a[i];
    if (sum % n) {
      cout << -1 << '\n';
      continue;
    }
    long long x = sum / n;
    for (long long i = 2; i <= n; i++) {
      if (a[i] % i == 0) {
        vec.push_back(make_pair(make_pair(i, 1), a[i] / i));
        continue;
      }
      vec.push_back(make_pair(make_pair(1, i), i - a[i] % i));
      vec.push_back(make_pair(make_pair(i, 1), (a[i] + i - a[i] % i) / i));
    }
    for (long long i = 2; i <= n; i++) {
      vec.push_back(make_pair(make_pair(1, i), x));
    }
    cout << vec.size() << '\n';
    for (auto i : vec)
      cout << i.first.first << " " << i.first.second << " " << i.second << '\n';
  }
  return 0;
}

### Prompt

Please create a solution in CPP to the following problem:

You are given an array a consisting of n positive integers, numbered from 1 to n. You can perform the following operation no more than 3n times:

  1. choose three integers i, j and x (1 ≤ i, j ≤ n; 0 ≤ x ≤ 10^9); 
  2. assign a_i := a_i - x ⋅ i, a_j := a_j + x ⋅ i. 



After each operation, all elements of the array should be non-negative.

Can you find a sequence of no more than 3n operations after which all elements of the array are equal?

Input

The first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.

The first line of each test case contains one integer n (1 ≤ n ≤ 10^4) — the number of elements in the array. The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^5) — the elements of the array.

It is guaranteed that the sum of n over all test cases does not exceed 10^4.

Output

For each test case print the answer to it as follows:

  * if there is no suitable sequence of operations, print -1; 
  * otherwise, print one integer k (0 ≤ k ≤ 3n) — the number of operations in the sequence. Then print k lines, the m-th of which should contain three integers i, j and x (1 ≤ i, j ≤ n; 0 ≤ x ≤ 10^9) for the m-th operation. 



If there are multiple suitable sequences of operations, print any of them. Note that you don't have to minimize k.

Example

Input


3
4
2 16 4 18
6
1 2 3 4 5 6
5
11 19 1 1 3


Output


2
4 1 2
2 3 3
-1
4
1 2 4
2 4 5
2 3 3
4 5 1

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast", "inline")
using namespace std;
const long long INF(0x3f3f3f3f3f3f3f3fll);
const long long inf(0x3f3f3f3f);
template <typename T>
void read(T &res) {
  bool flag = false;
  char ch;
  while (!isdigit(ch = getchar())) (ch == '-') && (flag = true);
  for (res = ch - 48; isdigit(ch = getchar());
       res = (res << 1) + (res << 3) + ch - 48)
    ;
  flag && (res = -res);
}
template <typename T>
void Out(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) Out(x / 10);
  putchar(x % 10 + '0');
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long pow_mod(long long x, long long n, long long mod) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
long long fact_pow(long long n, long long p) {
  long long res = 0;
  while (n) {
    n /= p;
    res += n;
  }
  return res;
}
long long mult(long long a, long long b, long long p) {
  a %= p;
  b %= p;
  long long r = 0, v = a;
  while (b) {
    if (b & 1) {
      r += v;
      if (r > p) r -= p;
    }
    v <<= 1;
    if (v > p) v -= p;
    b >>= 1;
  }
  return r;
}
long long quick_pow(long long a, long long b, long long p) {
  long long r = 1, v = a % p;
  while (b) {
    if (b & 1) r = mult(r, v, p);
    v = mult(v, v, p);
    b >>= 1;
  }
  return r;
}
bool CH(long long a, long long n, long long x, long long t) {
  long long r = quick_pow(a, x, n);
  long long z = r;
  for (long long i = 1; i <= t; i++) {
    r = mult(r, r, n);
    if (r == 1 && z != 1 && z != n - 1) return true;
    z = r;
  }
  return r != 1;
}
bool Miller_Rabin(long long n) {
  if (n < 2) return false;
  if (n == 2) return true;
  if (!(n & 1)) return false;
  long long x = n - 1, t = 0;
  while (!(x & 1)) {
    x >>= 1;
    t++;
  }
  srand(time(NULL));
  long long o = 8;
  for (long long i = 0; i < o; i++) {
    long long a = rand() % (n - 1) + 1;
    if (CH(a, n, x, t)) return false;
  }
  return true;
}
long long exgcd1(long long a, long long b, long long &x, long long &y) {
  if (!b) {
    x = 1, y = 0;
    return a;
  }
  long long t = exgcd1(b, a % b, y, x);
  y -= a / b * x;
  return t;
}
long long get_inv(long long a, long long mod) {
  long long x, y;
  long long d = exgcd1(a, mod, x, y);
  return d == 1 ? (x % mod + mod) % mod : -1;
}
void exgcd(long long a, long long b, long long &x, long long &y) {
  if (!b) {
    x = 1, y = 0;
    return;
  }
  exgcd(b, a % b, x, y);
  long long t = x;
  x = y, y = t - (a / b) * y;
}
long long INV(long long a, long long b) {
  long long x, y;
  return exgcd(a, b, x, y), (x % b + b) % b;
}
long long crt(long long x, long long p, long long mod) {
  return INV(p / mod, mod) * (p / mod) * x;
}
long long FAC(long long x, long long a, long long b) {
  if (!x) return 1;
  long long ans = 1;
  for (long long i = 1; i <= b; i++)
    if (i % a) ans *= i, ans %= b;
  ans = pow_mod(ans, x / b, b);
  for (long long i = 1; i <= x % b; i++)
    if (i % a) ans *= i, ans %= b;
  return ans * FAC(x / a, a, b) % b;
}
long long C(long long n, long long m, long long a, long long b) {
  long long N = FAC(n, a, b), M = FAC(m, a, b), Z = FAC(n - m, a, b), sum = 0,
            i;
  for (i = n; i; i = i / a) sum += i / a;
  for (i = m; i; i = i / a) sum -= i / a;
  for (i = n - m; i; i = i / a) sum -= i / a;
  return N * pow_mod(a, sum, b) % b * INV(M, b) % b * INV(Z, b) % b;
}
long long exlucas(long long n, long long m, long long p) {
  long long t = p, ans = 0, i;
  for (i = 2; i * i <= p; i++) {
    long long k = 1;
    while (t % i == 0) {
      k *= i, t /= i;
    }
    ans += crt(C(n, m, i, k), p, k), ans %= p;
  }
  if (t > 1) ans += crt(C(n, m, t, t), p, t), ans %= p;
  return ans % p;
}
long long prime[100000], minprime[100000];
long long euler(long long n) {
  long long c = 0, i, j;
  for (i = 2; i <= n; i++) {
    if (!minprime[i]) prime[++c] = i, minprime[i] = i;
    for (j = 1; j <= c && i * prime[j] <= n; j++) {
      minprime[i * prime[j]] = prime[j];
      if (i % prime[j] == 0) break;
    }
  }
  return c;
}
struct Tree {
  long long l, r, sum, lazy, maxn, minn;
} tree[100000];
inline void push_up(long long rt) {
  tree[rt].sum = tree[rt << 1].sum + tree[rt << 1 | 1].sum;
  tree[rt].maxn = max(tree[rt << 1].maxn, tree[rt << 1 | 1].maxn);
  tree[rt].minn = min(tree[rt << 1].minn, tree[rt << 1 | 1].minn);
}
inline void push_down(long long rt, long long length) {
  if (tree[rt].lazy) {
    tree[rt << 1].lazy += tree[rt].lazy;
    tree[rt << 1 | 1].lazy += tree[rt].lazy;
    tree[rt << 1].sum += (length - (length >> 1)) * tree[rt].lazy;
    tree[rt << 1 | 1].sum += (length >> 1) * tree[rt].lazy;
    tree[rt << 1].minn += tree[rt].lazy;
    tree[rt << 1 | 1].minn += tree[rt].lazy;
    tree[rt << 1].maxn += tree[rt].lazy;
    tree[rt << 1 | 1].maxn += tree[rt].lazy;
    tree[rt].lazy = 0;
  }
}
inline void build(long long l, long long r, long long rt, long long *aa) {
  tree[rt].lazy = 0;
  tree[rt].l = l;
  tree[rt].r = r;
  if (l == r) {
    tree[rt].sum = aa[l];
    tree[rt].minn = tree[rt].sum;
    tree[rt].maxn = tree[rt].sum;
    return;
  }
  long long mid = (l + r) >> 1;
  build(l, mid, rt << 1, aa);
  build(mid + 1, r, rt << 1 | 1, aa);
  push_up(rt);
}
inline void update_range(long long L, long long R, long long key,
                         long long rt) {
  if (tree[rt].r < L || tree[rt].l > R) return;
  if (L <= tree[rt].l && R >= tree[rt].r) {
    tree[rt].sum += (tree[rt].r - tree[rt].l + 1) * key;
    tree[rt].minn += key;
    tree[rt].maxn += key;
    tree[rt].lazy += key;
    return;
  }
  push_down(rt, tree[rt].r - tree[rt].l + 1);
  long long mid = (tree[rt].r + tree[rt].l) >> 1;
  if (L <= mid) update_range(L, R, key, rt << 1);
  if (R > mid) update_range(L, R, key, rt << 1 | 1);
  push_up(rt);
}
inline long long query_range(long long L, long long R, long long rt) {
  if (L <= tree[rt].l && R >= tree[rt].r) {
    return tree[rt].sum;
  }
  push_down(rt, tree[rt].r - tree[rt].l + 1);
  long long mid = (tree[rt].r + tree[rt].l) >> 1;
  long long ans = 0;
  if (L <= mid) ans += query_range(L, R, rt << 1);
  if (R > mid) ans += query_range(L, R, rt << 1 | 1);
  return ans;
}
inline long long query_min(long long L, long long R, long long rt) {
  if (L <= tree[rt].l && R >= tree[rt].r) {
    return tree[rt].minn;
  }
  push_down(rt, tree[rt].r - tree[rt].l + 1);
  long long mid = (tree[rt].r + tree[rt].l) >> 1;
  long long ans = (0x3f3f3f3f3f3f3f3fll);
  if (L <= mid) ans = min(ans, query_min(L, R, rt << 1));
  if (R > mid) ans = min(ans, query_min(L, R, rt << 1 | 1));
  return ans;
}
inline long long query_max(long long L, long long R, long long rt) {
  if (L <= tree[rt].l && R >= tree[rt].r) {
    return tree[rt].maxn;
  }
  push_down(rt, tree[rt].r - tree[rt].l + 1);
  long long mid = (tree[rt].r + tree[rt].l) >> 1;
  long long ans = -(0x3f3f3f3f3f3f3f3fll);
  if (L <= mid) ans = max(ans, query_max(L, R, rt << 1));
  if (R > mid) ans = max(ans, query_max(L, R, rt << 1 | 1));
  return ans;
}
namespace linear_seq {
const long long N = 1e5 + 10, mod = 1e9 + 7;
long long Rx[N], Ba[N], _c[N], _md[N];
vector<long long> Md;
long long PMD(long long a, long long b) {
  long long Rx = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) Rx = Rx * a % mod;
    a = a * a % mod;
  }
  return Rx;
}
void MUL(long long *a, long long *b, long long k) {
  for (long long i = 0; i < k + k; i++) _c[i] = 0;
  for (long long i = 0; i < k; i++)
    if (a[i])
      for (long long j = 0; j < k; j++)
        _c[i + j] = (_c[i + j] + a[i] * b[j]) % mod;
  for (long long i = k + k - 1; i >= k; i--)
    if (_c[i])
      for (long long j = 0; j < ((long long)(Md).size()); j++)
        _c[i - k + Md[j]] = (_c[i - k + Md[j]] - _c[i] * _md[Md[j]]) % mod;
  for (long long i = 0; i < k; i++) a[i] = _c[i];
}
long long Solve(long long n, vector<long long> a, vector<long long> b) {
  long long ans = 0, pnt = 0, k = a.size();
  assert(((long long)(a).size()) == ((long long)(b).size()));
  for (long long i = 0; i < k; i++) _md[k - 1 - i] = -a[i];
  _md[k] = 1;
  Md.clear();
  for (long long i = 0; i < k; i++)
    if (_md[i] != 0) Md.push_back(i);
  for (long long i = 0; i < k; i++) Rx[i] = Ba[i] = 0;
  Rx[0] = 1;
  while ((1ll << pnt) <= n) pnt++;
  for (long long p = pnt; p >= 0; p--) {
    MUL(Rx, Rx, k);
    if ((n >> p) & 1) {
      for (long long i = k - 1; i >= 0; i--) Rx[i + 1] = Rx[i];
      Rx[0] = 0;
      for (long long j = 0; j < ((long long)(Md).size()); j++)
        Rx[Md[j]] = (Rx[Md[j]] - Rx[k] * _md[Md[j]]) % mod;
    }
  }
  for (long long i = 0; i < k; i++) ans = (ans + Rx[i] * b[i]) % mod;
  if (ans < 0) ans += mod;
  return ans;
}
vector<long long> BM(vector<long long> s) {
  vector<long long> C(1, 1), B(1, 1);
  long long L = 0, m = 1, b = 1;
  for (long long n = 0; n < ((long long)(s).size()); n++) {
    long long d = 0;
    for (long long i = 0; i < L + 1; i++)
      d = (d + (long long)C[i] * s[n - i]) % mod;
    if (d == 0)
      ++m;
    else if (2 * L <= n) {
      vector<long long> T = C;
      long long c = mod - d * PMD(b, mod - 2) % mod;
      while (((long long)(C).size()) < ((long long)(B).size()) + m)
        C.push_back(0);
      for (long long i = 0; i < ((long long)(B).size()); i++)
        C[i + m] = (C[i + m] + c * B[i]) % mod;
      L = n + 1 - L;
      B = T;
      b = d;
      m = 1;
    } else {
      long long c = mod - d * PMD(b, mod - 2) % mod;
      while (((long long)(C).size()) < ((long long)(B).size()) + m)
        C.push_back(0);
      for (long long i = 0; i < ((long long)(B).size()); i++)
        C[i + m] = (C[i + m] + c * B[i]) % mod;
      ++m;
    }
  }
  return C;
}
long long Gao(vector<long long> a, long long n) {
  vector<long long> c = BM(a);
  c.erase(c.begin());
  n--;
  for (long long i = 0; i < ((long long)(c).size()); i++)
    c[i] = (mod - c[i]) % mod;
  return Solve(
      n, c, vector<long long>(a.begin(), a.begin() + ((long long)(c).size())));
}
};  // namespace linear_seq
const long long N = 3e5 + 10;
struct Edge {
  long long nex, to;
} edge[N << 1];
long long head[N], TOT;
void add_edge(long long u, long long v) {
  edge[++TOT].nex = head[u];
  edge[TOT].to = v;
  head[u] = TOT;
}
long long a[N];
vector<pair<pair<long long, long long>, long long>> vec;
signed main() {
  std::ios::sync_with_stdio(false);
  long long T = 1;
  cin >> T;
  while (T--) {
    vec.clear();
    long long n, sum = 0;
    cin >> n;
    for (long long i = 1; i <= n; i++) cin >> a[i], sum += a[i];
    if (sum % n) {
      cout << -1 << '\n';
      continue;
    }
    long long x = sum / n;
    for (long long i = 2; i <= n; i++) {
      if (a[i] % i == 0) {
        vec.push_back(make_pair(make_pair(i, 1), a[i] / i));
        continue;
      }
      vec.push_back(make_pair(make_pair(1, i), i - a[i] % i));
      vec.push_back(make_pair(make_pair(i, 1), (a[i] + i - a[i] % i) / i));
    }
    for (long long i = 2; i <= n; i++) {
      vec.push_back(make_pair(make_pair(1, i), x));
    }
    cout << vec.size() << '\n';
    for (auto i : vec)
      cout << i.first.first << " " << i.first.second << " " << i.second << '\n';
  }
  return 0;
}

```