#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   using uint = unsigned int;   using ull = unsigned long long;   template <class T>   bool set_max(T &a, const T &b) {     if (a < b) {       a = b;       return true;     }     return false;   }   template <class T>   bool set_min(T &a, const T &b) {     if (a > b) {       a = b;       return true;     }     return false;   }   template <typename A, typename B>   string to_string(pair<A, B> p);   template <typename A, typename B, typename C>   string to_string(tuple<A, B, C> p);   template <typename A, typename B, typename C, typename D>   string to_string(tuple<A, B, C, D> p);   string to_string(const string &s) { return     + s +    ; }   string to_string(const char *s) { return to_string((string)s); }   string to_string(bool b) { return (b ?  true  :  false ); }   string to_string(vector<bool> v) {     bool first = true;     string res =  { ;     for (int i = 0; i < static_cast<int>(v.size()); i++) {       if (!first) {         res +=  ,  ;       }       first = false;       res += to_string(v[i]);     }     res +=  } ;     return res;   }   template <size_t N>   string to_string(bitset<N> v) {     string res =   ;     for (size_t i = 0; i < N; i++) {       res += static_cast<char>( 0  + v[i]);     }     return res;   }   template <typename A>   string to_string(A v) {     bool first = true;     string res =  { ;     for (const auto &x : v) {       if (!first) {         res +=  ,  ;       }       first = false;       res += to_string(x);     }     res +=  } ;     return res;   }   template <typename A, typename B>   string to_string(pair<A, B> p) {     return  (  + to_string(p.first) +  ,   + to_string(p.second) +  ) ;   }   template <typename A, typename B, typename C>   string to_string(tuple<A, B, C> p) {     return  (  + to_string(get<0>(p)) +  ,   + to_string(get<1>(p)) +  ,   +            to_string(get<2>(p)) +  ) ;   }   template <typename A, typename B, typename C, typename D>   string to_string(tuple<A, B, C, D> p) {     return  (  + to_string(get<0>(p)) +  ,   + to_string(get<1>(p)) +  ,   +            to_string(get<2>(p)) +  ,   + to_string(get<3>(p)) +  ) ;   }   void debug_out() { cerr << endl; }   template <typename Head, typename... Tail>   void debug_out(Head H, Tail... T) {     cerr <<     << to_string(H);     debug_out(T...);   }   const int N = 3e5 + 10;   const int MOD = 1e9 + 7;   const double eps = 1e-6;   const ll INF = 1e18;   const int inf = 1e9;   int a[N];   void solve() {     int n;     cin >> n;     int sum = 0;     for (int i = 1; i <= n; i++) {       cin >> a[i];       sum += a[i];     }     if (sum % n) {       cout <<  -1 n ;       return;     }     int avg = sum / n;     vector<tuple<int, int, int>> ops;     auto move = [&](int i, int j, int x) {       assert(a[i] >= x * i);       ops.emplace_back(i, j, x);       a[j] += x * i;       a[i] -= x * i;     };     for (int i = 2; i <= n; i++) {       int x = (i - a[i] % i) % i;       if (x > 0) {         move(1, i, x);       }       assert(a[i] % i == 0);       move(i, 1, a[i] / i);     }     for (int i = 2; i <= n; i++) {       move(1, i, avg);     }     cout << ops.size() <<   n ;     for (auto x : ops) {       cout << get<0>(x) <<     << get<1>(x) <<     << get<2>(x) <<   n ;     }   }   int main() {     ios::sync_with_stdio(false), cin.tie(nullptr);     int t = 1;     cin >> t;     while (t--) solve();   }