#include <bits/stdc++.h>
using namespace std;
long long int greatestSubarraySum(long long int array[], long long int n);
long long int modpowerrr(long long int x, long long int y, long long int p);
long long int power(long long int x, long long int y);
void swapp(long long int *a, long long int *b);
long long int gcd(long long int a, long long int b);
long long int lcm(long long int a, long long int b);
long long int min(long long int a, long long int b);
long long int max(long long int a, long long int b);
long long int search(long long int arr[], long long int n, long long int k);
string findSum(string str1, string str2);
string findSum(string str1, string str2) {
  if (str1.length() > str2.length()) {
    string s = str1;
    str1 = str2;
    str2 = s;
  }
  string str = "";
  int n1 = str1.length(), n2 = str2.length();
  reverse(str1.begin(), str1.end());
  reverse(str2.begin(), str2.end());
  int carry = 0;
  for (int i = 0; i < n1; i++) {
    int sum = ((str1[i] - '0') + (str2[i] - '0') + carry);
    str.push_back(sum % 10 + '0');
    carry = sum / 10;
  }
  for (int i = n1; i < n2; i++) {
    int sum = ((str2[i] - '0') + carry);
    str.push_back(sum % 10 + '0');
    carry = sum / 10;
  }
  if (carry) str.push_back(carry + '0');
  reverse(str.begin(), str.end());
  return str;
}
long long int binarySearch(vector<long long> arr, long long int l,
                           long long int r, long long int x) {
  if (r >= l) {
    long long int mid = l + (r - l) / 2;
    if (arr[mid] == x) return mid;
    if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x);
    return binarySearch(arr, mid + 1, r, x);
  }
  return -1;
}
long long int greatestSubarraySum(long long int array[], long long int n) {
  long long int best = 0, sum = 0;
  for (long long int k = 0; k < n; k++) {
    sum = max(array[k], sum + array[k]);
    best = max(best, sum);
  }
  return best;
}
long long int modpowerrr(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
void swapp(long long int *a, long long int *b) {
  long long int temp = *a;
  *a = *b;
  *b = temp;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
long long int min(long long int a, long long int b) {
  if (a < b) return a;
  return b;
}
long long int max(long long int a, long long int b) {
  if (a > b) return a;
  return b;
}
long long int power(long long int x, long long int y) {
  long long int temp;
  if (y == 0) return 1;
  temp = power(x, y / 2);
  if (y % 2 == 0)
    return temp * temp;
  else
    return x * temp * temp;
}
long long int countSetBits(long long int n) {
  if (n == 0)
    return 0;
  else
    return (n & 1) + countSetBits(n >> 1);
}
long long int modulo(long long int value, long long int m) {
  long long int mod = value % m;
  if (value < 0) {
    mod += m;
  }
  return mod;
}
vector<long long> pf;
void primeFactors(long long int n) {
  while (n % 2 == 0) {
    if (pf.size() == 0 || pf[pf.size() - 1] != 2) pf.push_back(2);
    n = n / 2;
  }
  for (long long int i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      if (pf.size() == 0 || pf[pf.size() - 1] != i) {
        pf.push_back(i);
        continue;
      }
      n = n / i;
    }
  }
  if (n > 2) {
    if (pf.size() == 0 || pf[pf.size() - 1] != n) {
      pf.push_back(n);
      return;
    }
  }
}
long long int approximate(long double a) {
  if (ceil(a) - a < 0.00001) return (long long int)ceil(a);
  return floor(a);
}
long long int close(long long int a, long long int b, long long int k) {
  if (abs(a - k) > abs(b - k)) return b;
  return a;
}
string convertTo4String(long long int x) {
  string s;
  while (x > 0) {
    char t = '0' + x % 10;
    s = t + s;
    x /= 10;
  }
  while (s.length() < 4) s = "0" + s;
  return s;
}
long long int find(long long int x, long long int par[], long long int size[]) {
  if (x == par[x])
    return x;
  else
    return par[x] = find(par[x], par, size);
}
void uni(long long int x, long long int y, long long int par[],
         long long int size[]) {
  x = find(x, par, size);
  y = find(y, par, size);
  if (size[x] > size[y]) swap(x, y);
  par[x] = y;
  size[y] += size[x];
}
void dfs(long long int i, set<long long int> arr[], long long int visited[]) {
  if (visited[i]) return;
  visited[i] = 1;
  for (auto u : arr[i]) dfs(u, arr, visited);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int q;
  cin >> q;
  while (q--) {
    long long int n, m;
    cin >> n >> m;
    long long int arr[n];
    long long int sum = 0;
    for (long long int i = 0; i < n; i++) {
      cin >> arr[i];
      sum += arr[i];
    }
    if (m < n) {
      cout << -1 << endl;
      continue;
    } else if (n == 2)
      cout << -1 << endl;
    else {
      long long int ans = 2 * sum;
      cout << ans << endl;
      for (long long int i = 0; i < n; i++) {
        if (i != n - 1)
          cout << i + 1 << " " << i + 2 << endl;
        else
          cout << n << " " << 1 << endl;
      }
    }
  }
}
