Bags and Coins

When you were a child you must have been told a puzzle of bags and coins. Anyway, here’s one of its versions:

A horse has three bags. The first bag has one coin, the second bag has one coin and the third bag has three coins. In total, the horse has three coins in the bags. How is that possible?

The answer is quite simple. The third bag contains a coin and two other bags.

This problem is a generalization of the childhood puzzle. You have n bags. You know that the first bag contains a 1 coins, the second bag contains a 2 coins, …, the n-th bag contains a n coins. In total, there are s coins. Find the way to arrange the bags and coins so that they match the described scenario or else state that it is impossible to do.

Input

The first line contains two integers n and s (1 ≤ n, s ≤ 70000) — the number of bags and the total number of coins. The next line contains n integers a 1, a 2, …, a n (1 ≤ a i ≤ 70000), where a i shows the number of coins in the i-th bag.

Output

If the answer doesn’t exist, print -1.

Otherwise, print n lines, on the i-th line print the contents of the i-th bag. The first number in the line, c i (0 ≤ c i ≤ a i), must represent the number of coins lying directly in the i-th bag (the coins in the bags that are in the i-th bag are not taken into consideration). The second number in the line, k i (0 ≤ k i < n) must represent the number of bags that lie directly in the i-th bag (the bags that are inside the bags lying in the i-th bag are not taken into consideration). Next, the line must contain k i integers — the numbers of the bags that are lying directly in the i-th bag.

The total number of coins in the solution must equal s. If we count the total number of coins the i-th bag in the solution has, we should get a i.

No bag can directly lie in more than one bag. The bags can be nested in more than one level (see the second test case). If there are multiple correct answers, you can print any of them.

Examples

input

3 3
1 3 1

output

1 0
1 2 3 1
1 0

input

3 3
1 3 1

output

1 0
2 1 3
0 1 1

input

1 2
1

output

-1

input

8 10
2 7 3 4 1 3 1 2

output

2 0
1 2 1 4
0 2 7 8
0 2 5 6
1 0
3 0
1 0
2 0

Note

The pictures below show two possible ways to solve one test case from the statement. The left picture corresponds to the first test case, the right picture corresponds to the second one.

Solution:

#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

const int N = 4 * 77777;

unsigned int one = 1;
unsigned int f[N], nf[N];
pair <int, int> a[N];
int last[N], inside[N], A[N];
bool used[N];

int main() {
int n, s;
scanf("%d %d", &n, &s);
for (int i = 0; i < n; i++) {
    scanf("%d", &a[i].first);
    A[i] = a[i].first;
    a[i].second = i;
  }
  sort(a, a + n);
  reverse(a, a + n);
  if (a[0].first > s) {
printf("%d\n", -1);
return 0;
}
s -= a[0].first;
int nn = (s >> 5) + 1;
for (int i = 0; i < nn; i++) f[i] = 0;
  for (int i = 0; i <= s; i++) last[i] = -1;
  last[0] = 0;
  f[0] |= (one << 0);
  for (int q = 1; q < n; q++) {
    int w = a[q].first;
    for (int i = 0; i < nn; i++) nf[i] = 0;
    int els = (w >> 5);
int shift = (w & 31);
for (int i = 0; i < nn; i++) {
      int j = i + els;
      if (j < nn) {
        nf[j] |= (f[i] << shift);
        if (j + 1 < nn && shift != 0) {
          nf[j + 1] |= (f[i] >> (32 - shift));
}
}
else break;
}
for (int i = 0; i < nn; i++)
      if ((f[i] | nf[i]) != f[i]) {
        for (int j = 0; j < 32; j++)
          if (nf[i] & (one << j)) {
            if (!(f[i] & (one << j))) {
              int id = (i << 5) + j;
              last[id] = q;
            }
          }
        f[i] |= nf[i];
      }
  }
  if (last[s] == -1) {
    printf("%d\n", -1);
    return 0;
  }
  for (int i = 1; i < n; i++) used[i] = false;
  while (s > 0) {
used[last[s]] = true;
s -= a[last[s]].first;
}
for (int i = 0; i < n; i++) inside[i] = -1;
  int prev = 0;
  for (int i = 1; i < n; i++) {
    if (!used[i]) {
      inside[a[prev].second] = a[i].second;
      prev = i;
    }
  }
  for (int i = 0; i < n; i++) {
    if (inside[i] == -1) {
      printf("%d 0\n", A[i]);
    } else {
      printf("%d 1 %d\n", A[i] - A[inside[i]], inside[i] + 1);
    }
  }
  return 0;
}