#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 70100;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

pii a[maxn];
int n , s;
bitset < maxn > dp , dummy , nw;
int par[maxn];
int coin[maxn] , pr[maxn];
bool mark[maxn];

int main(){
    migmig
    cin >> n >> s;
    for(int i = 0 ; i < n ; i ++){
		cin >> a[i].first;
		a[i].second = i;
	}
	ms(par , -1);
	sort(a , a + n);
	reverse(a , a + n);
	if(a[0].first > s)
		dokme(-1);
	int sum = 0;
	for(int i = 0 ; i < n ; i ++)
		sum+=a[i].first;
	if(sum < s)	dokme(-1);
	dp[a[0].first] = 1;
	par[a[0].first] = a[0].second;
	for(int i = 1; i < n ; i ++){
		dummy = dp;
		dummy[a[i].first] = 1;
		nw = dp^(dummy|(dp << a[i].first));
		dp=dummy|(dp << a[i].first);
		int cur = nw._Find_first();
		while(cur!=maxn){
			par[cur] = a[i].second;
			cur = nw._Find_next(cur);
		}
	}
    if(!dp[s])
		dokme(-1);
    s-=a[0].first;
    while(s){
		mark[par[s]] = 1;
		s -= a[par[s]].first;
	}
	reverse(a , a + n);
	int cur = 0;
	int prev = -1;
	for(int i = 0; i < n ; i ++){
		if(mark[a[i].second]){
			coin[a[i].second] = a[i].first;
			continue;
		}
		if(cur!=a[i].first){
			coin[a[i].second] = a[i].first - cur;
		}
		cur = a[i].first;
		if(prev!=-1)
			pr[a[i].second]=prev+1;
		prev = a[i].second;
	}
	for(int i = 0 ; i < n ; i ++){
		cout << coin[i] << ' ';
		if(pr[i])
			cout << 1 << ' ' << pr[i];
		else
			cout << 0;
		cout << endl;
	}

    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 70100;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

pii a[maxn];
int n , s;
bitset < maxn > dp , dummy , nw;
int par[maxn];
int coin[maxn] , pr[maxn];
bool mark[maxn];
int val[maxn];
vector < int > num[maxn];

int main(){
    migmig
    cin >> n >> s;
    for(int i = 0 ; i < n ; i ++){
		cin >> a[i].first;
		val[i] = a[i].first;
		a[i].second = i;
		num[val[i]].pb(i);
	}
	ms(par , -1);
	sort(a , a + n);
	reverse(a , a + n);
	if(a[0].first > s)
		dokme(-1);
	int sum = 0;
	for(int i = 0 ; i < n ; i ++)
		sum+=a[i].first;
	if(sum < s)	dokme(-1);
	dp[0] = 1;
	par[0] = -1;
	for(int i = 0; i < n ; i ++){
		dummy = dp;
		dummy[a[i].first] = 1;
		nw = dp^(dummy|(dp << a[i].first));
		dp=dummy|(dp << a[i].first);
		int cur = nw._Find_first();
		while(cur!=maxn){
			par[cur] = a[i].second;
			cur = nw._Find_next(cur);
		}
	}
    if(!dp[s])
		dokme(-1);
    s-=a[0].first;
    num[a[0].first].pop_back();
    while(s){
		if(par[s] == -1)dokme(-1);
		mark[num[val[par[s]]].back()] = 1;
		num[val[par[s]]].pop_back();
		s -= val[par[s]];
	}
	reverse(a , a + n);
	int cur = 0;
	int prev = -1;
	for(int i = 0; i < n ; i ++){
		if(mark[a[i].second]){
			coin[a[i].second] = a[i].first;
			continue;
		}
		if(cur!=a[i].first){
			coin[a[i].second] = a[i].first - cur;
		}
		cur+=coin[a[i].second];
		if(prev!=-1)
			pr[a[i].second]=prev+1;
		prev = a[i].second;
	}
	for(int i = 0 ; i < n ; i ++){
		cout << coin[i] << ' ';
		if(pr[i])
			cout << 1 << ' ' << pr[i];
		else
			cout << 0;
		cout << endl;
	}
    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 70100;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

pii a[maxn];
int n , s;
bitset < maxn > dp , dummy , nw;
int par[maxn];
int coin[maxn] , pr[maxn];
bool mark[maxn];
int val[maxn];
vector < int > num[maxn];

int main(){
    migmig
    cin >> n >> s;
    for(int i = 0 ; i < n ; i ++){
		cin >> a[i].first;
		val[i] = a[i].first;
		a[i].second = i;
		num[val[i]].pb(i);
	}
	ms(par , -1);
	sort(a , a + n);
	reverse(a , a + n);
	if(a[0].first > s)
		dokme(-1);
	int sum = 0;
	for(int i = 0 ; i < n ; i ++)
		sum+=a[i].first;
	if(sum < s)	dokme(-1);
	dp[0] = 1;
	par[0] = -1;
	for(int i = 0; i < n ; i ++){
		dummy = dp;
		dummy[a[i].first] = 1;
		nw = dp^(dummy|(dp << a[i].first));
		dp=dummy|(dp << a[i].first);
		int cur = nw._Find_first();
		while(cur!=maxn){
			par[cur] = a[i].second;
			cur = nw._Find_next(cur);
		}
	}
    if(!dp[s])
		dokme(-1);
    s-=a[0].first;
    while(s){
		if(par[s] == -1)dokme(-1);
		mark[num[val[par[s]]].back()] = 1;
		num[val[par[s]]].pop_back();
		s -= val[par[s]];
	}
	reverse(a , a + n);
	int cur = 0;
	int prev = -1;
	for(int i = 0; i < n ; i ++){
		if(mark[a[i].second]){
			coin[a[i].second] = a[i].first;
			continue;
		}
		if(cur!=a[i].first){
			coin[a[i].second] = a[i].first - cur;
		}
		cur+=coin[a[i].second];
		if(prev!=-1)
			pr[a[i].second]=prev+1;
		prev = a[i].second;
	}
	for(int i = 0 ; i < n ; i ++){
		cout << coin[i] << ' ';
		if(pr[i])
			cout << 1 << ' ' << pr[i];
		else
			cout << 0;
		cout << endl;
	}
    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 70100;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

pii a[maxn];
int n , s;
bitset < maxn > dp , dummy , nw;
int par[maxn];
int coin[maxn] , pr[maxn];
bool mark[maxn];
int val[maxn];

int main(){
    migmig
    cin >> n >> s;
    for(int i = 0 ; i < n ; i ++){
		cin >> a[i].first;
		val[i] = a[i].first;
		a[i].second = i;
	}
	ms(par , -1);
	sort(a , a + n);
	reverse(a , a + n);
	if(a[0].first > s)
		dokme(-1);
	int sum = 0;
	for(int i = 0 ; i < n ; i ++)
		sum+=a[i].first;
	if(sum < s)	dokme(-1);
	dp[a[0].first] = 1;
	par[a[0].first] = a[0].second;
	for(int i = 1; i < n ; i ++){
		dummy = dp;
		dummy[a[i].first] = 1;
		nw = dp^(dummy|(dp << a[i].first));
		dp=dummy|(dp << a[i].first);
		int cur = nw._Find_first();
		while(cur!=maxn){
			par[cur] = a[i].second;
			cur = nw._Find_next(cur);
		}
	}
    if(!dp[s])
		dokme(-1);
	int arzeboz = s;
    s-=a[0].first;
    int arzeadab = 0;
    while(s){
		if(par[s] == -1)dokme(-1);
		mark[par[s]] = 1;
		arzeadab+=val[par[s]];
		s -= val[par[s]];
	}
	assert(arzeadab + a[0].first == arzeboz);
	reverse(a , a + n);
	int cur = 0;
	int prev = -1;
	for(int i = 0; i < n ; i ++){
		if(mark[a[i].second]){
			coin[a[i].second] = a[i].first;
			arzeadab-=a[i].first;
			continue;
		}
		if(cur!=a[i].first){
			coin[a[i].second] = a[i].first - cur;
			cur = a[i].first;
		}
		if(prev!=-1)
			pr[a[i].second]=prev+1;
		prev = a[i].second;
	}
	assert(arzeadab == 0);
	for(int i = 0 ; i < n ; i ++){
		cout << coin[i] << ' ';
		if(pr[i])
			cout << 1 << ' ' << pr[i];
		else
			cout << 0;
		cout << endl;
	}
    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 70100;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

pii a[maxn];
int n , s;
bitset < maxn > dp , dummy , nw;
int par[maxn];
int coin[maxn] , pr[maxn];
bool mark[maxn];
int val[maxn];
vector < int > num[maxn];

int main(){
    migmig
    cin >> n >> s;
    for(int i = 0 ; i < n ; i ++){
		cin >> a[i].first;
		val[i] = a[i].first;
		a[i].second = i;
		num[val[i]].pb(i);
	}
	ms(par , -1);
	sort(a , a + n);
	reverse(a , a + n);
	if(a[0].first > s)
		dokme(-1);
	int sum = 0;
	for(int i = 0 ; i < n ; i ++)
		sum+=a[i].first;
	if(sum < s)	dokme(-1);
	dp[0] = 1;
	par[0] = -1;
	for(int i = 0; i < n ; i ++){
		dummy = dp;
		dummy[a[i].first] = 1;
		nw = dp^(dummy|(dp << a[i].first));
		dp=dummy|(dp << a[i].first);
		int cur = nw._Find_first();
		while(cur!=maxn){
			par[cur] = a[i].second;
			cur = nw._Find_next(cur);
		}
	}
    if(!dp[s])
		dokme(-1);
    s-=a[0].first;
    num[a[0].first].pop_back();
    while(s){
		if(par[s] == -1)dokme(-1);
		if(num[val[par[s]]].size() == 0)	dokme(-1);
		mark[num[val[par[s]]].back()] = 1;
		num[val[par[s]]].pop_back();
		s -= val[par[s]];
	}
	reverse(a , a + n);
	int cur = 0;
	int prev = -1;
	for(int i = 0; i < n ; i ++){
		if(mark[a[i].second]){
			coin[a[i].second] = a[i].first;
			continue;
		}
		if(cur!=a[i].first){
			coin[a[i].second] = a[i].first - cur;
		}
		cur+=coin[a[i].second];
		if(prev!=-1)
			pr[a[i].second]=prev+1;
		prev = a[i].second;
	}
	for(int i = 0 ; i < n ; i ++){
		cout << coin[i] << ' ';
		if(pr[i])
			cout << 1 << ' ' << pr[i];
		else
			cout << 0;
		cout << endl;
	}
    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 70100;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

pii a[maxn];
int n , s;
bitset < maxn > dp , dummy , nw;
int par[maxn];
int coin[maxn] , pr[maxn];
bool mark[maxn];
int val[maxn];
vector < int > num[maxn];

int main(){
    migmig
    cin >> n >> s;
    for(int i = 0 ; i < n ; i ++){
		cin >> a[i].first;
		val[i] = a[i].first;
		a[i].second = i;
	}
	ms(par , -1);
	sort(a , a + n);
	reverse(a , a + n);
	for(int  i = 0 ; i < n ; i ++)
		num[a[i].first].pb(a[i].second);
	if(a[0].first > s)
		dokme(-1);
	int sum = 0;
	for(int i = 0 ; i < n ; i ++)
		sum+=a[i].first;
	if(sum < s)	dokme(-1);
	dp[a[0].first] = 1;
	dp[0] = 1;
	for(int i = n-1; i >=0 ; i --){
		dummy = dp;
		dummy[a[i].first] = 1;
		nw = dp^(dummy|(dp << a[i].first));
		dp=dummy|(dp << a[i].first);
		int cur = nw._Find_first();
		while(cur!=maxn){
			par[cur] = a[i].first;
			cur = nw._Find_next(cur);
		}
	}
    if(!dp[s])
		dokme(-1);
	s-=a[0].first;
	num[a[0].first].pop_back();
    while(s){
		if(par[s] == -1)dokme(-1);
		mark[num[par[s]].back()] = 1;
		num[par[s]].pop_back();
		s-=par[s];
	}
    int cur = 0;
    int prev = -1;
    ms(pr , -1);
    reverse(a , a + n);
    for(int i = 0; i < n ; i ++){
		if(mark[a[i].second]){
			coin[a[i].second] = val[a[i].second];
			continue;
		}
		coin[a[i].second] = val[a[i].second] - cur;
		cur = val[a[i].second];
		if(prev!=-1){
			pr[a[i].second] = prev;
		}
		prev = a[i].second+1;
	}
	for(int i = 0 ; i < n ; i ++){
		if(pr[i] == -1){
			cout << coin[i] << " 0 " << endl;
		}
		else{
			cout << coin[i] << " 1 " << pr[i] << endl;
		}
	}

    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 70100;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

pii a[maxn];
int n , s;
bitset < maxn > dp , dummy , nw;
int par[maxn];
int coin[maxn] , pr[maxn];
bool mark[maxn];
int val[maxn];

int main(){
    migmig
    cin >> n >> s;
    for(int i = 0 ; i < n ; i ++){
		cin >> a[i].first;
		val[i] = a[i].first;
		a[i].second = i;
	}
	ms(par , -1);
	sort(a , a + n);
	reverse(a , a + n);
	if(a[0].first > s)
		dokme(-1);
	int sum = 0;
	for(int i = 0 ; i < n ; i ++)
		sum+=a[i].first;
	if(sum < s)	dokme(-1);
	dp[a[0].first] = 1;
	par[a[0].first] = a[0].second;
	for(int i = 1; i < n ; i ++){
		dummy = dp;
		dummy[a[i].first] = 1;
		nw = dp^(dummy|(dp << a[i].first));
		dp=dummy|(dp << a[i].first);
		int cur = nw._Find_first();
		while(cur!=maxn){
			par[cur] = a[i].second;
			cur = nw._Find_next(cur);
		}
	}
    if(!dp[s])
		dokme(-1);
    s-=a[0].first;
    while(s){
		mark[par[s]] = 1;
		s -= val[par[s]];
	}
	reverse(a , a + n);
	int cur = 0;
	int prev = -1;
	for(int i = 0; i < n ; i ++){
		if(mark[a[i].second]){
			coin[a[i].second] = a[i].first;
			continue;
		}
		if(cur!=a[i].first){
			coin[a[i].second] = a[i].first - cur;
		}
		cur = a[i].first;
		if(prev!=-1)
			pr[a[i].second]=prev+1;
		prev = a[i].second;
	}
	for(int i = 0 ; i < n ; i ++){
		cout << coin[i] << ' ';
		if(pr[i])
			cout << 1 << ' ' << pr[i];
		else
			cout << 0;
		cout << endl;
	}

    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 70100;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

pii a[maxn];
int n , s;
bitset < maxn > dp , dummy , nw;
int par[maxn];
int coin[maxn] , pr[maxn];
bool mark[maxn];
int val[maxn];
vector < int > num[maxn];

int main(){
    migmig
    cin >> n >> s;
    for(int i = 0 ; i < n ; i ++){
		cin >> a[i].first;
		val[i] = a[i].first;
		a[i].second = i;
		num[val[i]].pb(i);
	}
	ms(par , -1);
	sort(a , a + n);
	reverse(a , a + n);
	if(a[0].first > s)
		dokme(-1);
	int sum = 0;
	for(int i = 0 ; i < n ; i ++)
		sum+=a[i].first;
	if(sum < s)	dokme(-1);
	dp[a[0].first] = 1;
	par[a[0].first] = a[0].second;
	for(int i = 1; i < n ; i ++){
		dummy = dp;
		dummy[a[i].first] = 1;
		nw = dp^(dummy|(dp << a[i].first));
		dp=dummy|(dp << a[i].first);
		int cur = nw._Find_first();
		while(cur!=maxn){
			par[cur] = a[i].second;
			cur = nw._Find_next(cur);
		}
	}
    if(!dp[s])
		dokme(-1);
    s-=a[0].first;
    while(s){
		if(par[s] == -1)dokme(-1);
		mark[num[val[par[s]]].back()] = 1;
		num[val[par[s]]].pop_back();
		s -= val[par[s]];
	}
	reverse(a , a + n);
	int cur = 0;
	int prev = -1;
	for(int i = 0; i < n ; i ++){
		if(mark[a[i].second]){
			coin[a[i].second] = a[i].first;
			continue;
		}
		if(cur!=a[i].first){
			coin[a[i].second] = a[i].first - cur;
		}
		cur+=coin[a[i].second];
		if(prev!=-1)
			pr[a[i].second]=prev+1;
		prev = a[i].second;
	}
	for(int i = 0 ; i < n ; i ++){
		cout << coin[i] << ' ';
		if(pr[i])
			cout << 1 << ' ' << pr[i];
		else
			cout << 0;
		cout << endl;
	}
    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll  ,ll > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 70100;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

pii a[maxn];
ll n , s;
bitset < maxn > dp , dummy , nw;
ll par[maxn];
ll coin[maxn] , pr[maxn];
bool mark[maxn];
ll val[maxn];
vector < ll > num[maxn];

int main(){
    migmig
    cin >> n >> s;
    for(ll i = 0 ; i < n ; i ++){
		cin >> a[i].first;
		val[i] = a[i].first;
		a[i].second = i;
	}
	ms(par , -1);
	sort(a , a + n);
	reverse(a , a + n);
	for(ll  i = 0 ; i < n ; i ++)
		num[a[i].first].pb(a[i].second);
	if(a[0].first > s)
		dokme(-1);
	ll sum = 0;
	for(ll i = 0 ; i < n ; i ++)
		sum+=a[i].first;
	if(sum < s)	dokme(-1);
	dp[a[0].first] = 1;
	par[a[0].first] = a[0].first;
	dp[0] = 1;
	for(ll i = n-1; i >=0 ; i --){
		dummy = dp;
		dummy[a[i].first] = 1;
		nw = dp^(dummy|(dp << a[i].first));
		dp=dummy|(dp << a[i].first);
		ll cur = nw._Find_first();
		while(cur!=maxn){
			par[cur] = a[i].first;
			cur = nw._Find_next(cur);
		}
	}
    if(!dp[s])
		dokme(-1);
	s-=a[0].first;
	num[a[0].first].pop_back();
    while(s){
		if(par[s] == -1)dokme(-1);
		mark[num[par[s]].back()] = 1;
		num[par[s]].pop_back();
		s-=par[s];
	}
    ll cur = 0;
    ll prev = -1;
    ms(pr , -1);
    reverse(a , a + n);
    for(ll i = 0; i < n ; i ++){
		if(mark[a[i].second]){
			coin[a[i].second] = val[a[i].second];
			continue;
		}
		coin[a[i].second] = val[a[i].second] - cur;
		cur = val[a[i].second];
		if(prev!=-1){
			pr[a[i].second] = prev;
		}
		prev = a[i].second+1;
	}
	for(ll i = 0 ; i < n ; i ++){
		if(pr[i] == -1){
			cout << coin[i] << " 0 " << endl;
		}
		else{
			cout << coin[i] << " 1 " << pr[i] << endl;
		}
	}

    return(0);
}

//When we hit our lowest poll, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 70100;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

pii a[maxn];
int n , s;
bitset < maxn > dp , dummy , nw;
int par[maxn];
int coin[maxn] , pr[maxn];
bool mark[maxn];
int val[maxn];
vector < int > num[maxn];

int main(){
    migmig
    cin >> n >> s;
    for(int i = 0 ; i < n ; i ++){
		cin >> a[i].first;
		val[i] = a[i].first;
		a[i].second = i;
		num[val[i]].pb(i);
	}
	ms(par , -1);
	sort(a , a + n);
	reverse(a , a + n);
	if(a[0].first > s)
		dokme(-1);
	int sum = 0;
	for(int i = 0 ; i < n ; i ++)
		sum+=a[i].first;
	if(sum < s)	dokme(-1);
	dp[0] = 1;
	par[0] = -1;
	for(int i = 0; i < n ; i ++){
		dummy = dp;
		dummy[a[i].first] = 1;
		nw = dp^(dummy|(dp << a[i].first));
		dp=dummy|(dp << a[i].first);
		int cur = nw._Find_first();
		while(cur!=maxn){
			par[cur] = a[i].first;
			cur = nw._Find_next(cur);
		}
	}
    if(!dp[s])
		dokme(-1);
    while(s){
		mark[num[par[s]].back()] = 1;
		num[par[s]].pop_back();
		s-=par[s];
	}
    int cur = 0;
    int prev = -1;
    ms(pr , -1);
    reverse(a , a + n);
    for(int i = 0; i < n ; i ++){
		if(mark[a[i].second]) {
			coin[a[i].second] = val[a[i].second];
			continue;
		}
		coin[a[i].second] = val[a[i].second] - cur;
		cur = val[a[i].second];
		if(prev!=-1){
			pr[a[i].second] = prev;
		}
		prev = a[i].second+1;
	}
	for(int i = 0 ; i < n ; i ++){
		if(pr[i] == -1){
			cout << coin[i] << " 0 " << endl;
		}
		else{
			cout << coin[i] << " 1 " << pr[i] << endl;
		}
	}

    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 70100;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

pii a[maxn];
int n , s;
bitset < maxn > dp , dummy , nw;
int par[maxn];
int coin[maxn] , pr[maxn];
bool mark[maxn];
int val[maxn];
vector < int > num[maxn];

int main(){
    migmig
    cin >> n >> s;
    for(int i = 0 ; i < n ; i ++){
		cin >> a[i].first;
		val[i] = a[i].first;
		a[i].second = i;
		num[val[i]].pb(i);
	}
	ms(par , -1);
	sort(a , a + n);
	reverse(a , a + n);
	if(a[0].first > s)
		dokme(-1);
	int sum = 0;
	for(int i = 0 ; i < n ; i ++)
		sum+=a[i].first;
	if(sum < s)	dokme(-1);
	dp[0] = 1;
	par[0] = -1;
	for(int i = 0; i < n ; i ++){
		dummy = dp;
		dummy[a[i].first] = 1;
		nw = dp^(dummy|(dp << a[i].first));
		dp=dummy|(dp << a[i].first);
		int cur = nw._Find_first();
		while(cur!=maxn){
			par[cur] = a[i].second;
			cur = nw._Find_next(cur);
		}
	}
    if(!dp[s])
		dokme(-1);
    s-=a[0].first;
    num[a[0].first].pop_back();
    while(s){
		if(par[s] == -1)dokme(-1);
		if(num[val[par[s]]].size() == 0){
			s -= val[par[s]];
			continue;
		}
		mark[num[val[par[s]]].back()] = 1;
		num[val[par[s]]].pop_back();
	}
	reverse(a , a + n);
	int cur = 0;
	int prev = -1;
	for(int i = 0; i < n ; i ++){
		if(mark[a[i].second]){
			coin[a[i].second] = a[i].first;
			continue;
		}
		if(cur!=a[i].first){
			coin[a[i].second] = a[i].first - cur;
		}
		cur+=coin[a[i].second];
		if(prev!=-1)
			pr[a[i].second]=prev+1;
		prev = a[i].second;
	}
	for(int i = 0 ; i < n ; i ++){
		cout << coin[i] << ' ';
		if(pr[i])
			cout << 1 << ' ' << pr[i];
		else
			cout << 0;
		cout << endl;
	}
    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 70100;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

pii a[maxn];
int n , s;
bitset < maxn > dp , dummy , nw;
int par[maxn];
int coin[maxn] , pr[maxn];
bool mark[maxn];
int val[maxn];
vector < int > num[maxn];

int main(){
    migmig
    cin >> n >> s;
    for(int i = 0 ; i < n ; i ++){
		cin >> a[i].first;
		val[i] = a[i].first;
		a[i].second = i;
		num[val[i]].pb(i);
	}
	ms(par , -1);
	sort(a , a + n);
	reverse(a , a + n);
	if(a[0].first > s)
		dokme(-1);
	int sum = 0;
	for(int i = 0 ; i < n ; i ++)
		sum+=a[i].first;
	if(sum < s)	dokme(-1);
	dp[0] = 1;
	par[0] = -1;
	for(int i = 0; i < n ; i ++){
		dummy = dp;
		dummy[a[i].first] = 1;
		nw = dp^(dummy|(dp << a[i].first));
		dp=dummy|(dp << a[i].first);
		int cur = nw._Find_first();
		while(cur!=maxn){
			par[cur] = a[i].second;
			cur = nw._Find_next(cur);
		}
	}
    if(!dp[s])
		dokme(-1);
    s-=a[0].first;
    //num[a[0].first].pop_back();
    while(s){
		if(par[s] == -1)dokme(-1);
		mark[num[val[par[s]]].back()] = 1;
		num[val[par[s]]].pop_back();
		s -= val[par[s]];
	}
	reverse(a , a + n);
	int cur = 0;
	int prev = -1;
	for(int i = 0; i < n ; i ++){
		if(mark[a[i].second]){
			coin[a[i].second] = a[i].first;
			continue;
		}
		if(cur!=a[i].first){
			coin[a[i].second] = a[i].first - cur;
		}
		cur+=coin[a[i].second];
		if(prev!=-1)
			pr[a[i].second]=prev+1;
		prev = a[i].second;
	}
	for(int i = 0 ; i < n ; i ++){
		cout << coin[i] << ' ';
		if(pr[i])
			cout << 1 << ' ' << pr[i];
		else
			cout << 0;
		cout << endl;
	}
    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 70100;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

pii a[maxn];
int n , s;
bitset < maxn > dp , dummy , nw;
int par[maxn];
int coin[maxn] , pr[maxn];
bool mark[maxn];
int val[maxn];

int main(){
    migmig
    cin >> n >> s;
    for(int i = 0 ; i < n ; i ++){
		cin >> a[i].first;
		val[i] = a[i].first;
		a[i].second = i;
	}
	ms(par , -1);
	sort(a , a + n);
	reverse(a , a + n);
	if(a[0].first > s)
		dokme(-1);
	int sum = 0;
	for(int i = 0 ; i < n ; i ++)
		sum+=a[i].first;
	if(sum < s)	dokme(-1);
	dp[a[0].first] = 1;
	par[a[0].first] = a[0].second;
	for(int i = 1; i < n ; i ++){
		dummy = dp;
		dummy[a[i].first] = 1;
		nw = dp^(dummy|(dp << a[i].first));
		dp=dummy|(dp << a[i].first);
		int cur = nw._Find_first();
		while(cur!=maxn){
			par[cur] = a[i].second;
			cur = nw._Find_next(cur);
		}
	}
    if(!dp[s])
		dokme(-1);
	int arzeboz = s;
    s-=a[0].first;
    int arzeadab = 0;
    while(s){
		if(par[s] == -1)dokme(-1);
		mark[par[s]] = 1;
		arzeadab+=val[par[s]];
		s -= val[par[s]];
	}
	assert(arzeadab + a[0].first == arzeboz);
	reverse(a , a + n);
	int cur = 0;
	int prev = -1;
	for(int i = 0; i < n ; i ++){
		if(mark[a[i].second]){
			coin[a[i].second] = a[i].first;
			continue;
		}
		if(cur!=a[i].first){
			coin[a[i].second] = a[i].first - cur;
		}
		cur = a[i].first;
		if(prev!=-1)
			pr[a[i].second]=prev+1;
		prev = a[i].second;
	}
	for(int i = 0 ; i < n ; i ++){
		cout << coin[i] << ' ';
		if(pr[i])
			cout << 1 << ' ' << pr[i];
		else
			cout << 0;
		cout << endl;
	}
    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 70100;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

pii a[maxn];
int n , s;
bitset < maxn > dp , dummy , nw;
int par[maxn];
int coin[maxn] , pr[maxn];
bool mark[maxn];
int val[maxn];
vector < int > num[maxn];

int main(){
    migmig
    cin >> n >> s;
    for(int i = 0 ; i < n ; i ++){
		cin >> a[i].first;
		val[i] = a[i].first;
		a[i].second = i;
	}
	ms(par , -1);
	sort(a , a + n);
	reverse(a , a + n);
	for(int  i = 0 ; i < n ; i ++)
		num[a[i].first].pb(a[i].second);
	if(a[0].first > s)
		dokme(-1);
	int sum = 0;
	for(int i = 0 ; i < n ; i ++)
		sum+=a[i].first;
	if(sum < s)	dokme(-1);
	dp[a[0].first] = 1;
	dp[0] = 1;
	for(int i = n-1; i >=0 ; i --){
		dummy = dp;
		dummy[a[i].first] = 1;
		nw = dp^(dummy|(dp << a[i].first));
		dp=dummy|(dp << a[i].first);
		int cur = nw._Find_first();
		while(cur!=maxn){
			par[cur] = a[i].first;
			cur = nw._Find_next(cur);
		}
	}
    if(!dp[s])
		dokme(-1);
	s-=a[0].first;
	int boz = num[a[0].first].back();
	num[a[0].first].pop_back();
    while(s){
		mark[num[par[s]].back()] = 1;
		num[par[s]].pop_back();
		s-=par[s];
	}
    int cur = 0;
    int prev = -1;
    ms(pr , -1);
    reverse(a , a + n);
    for(int i = 0; i < n ; i ++){
		if(mark[a[i].second]){
			coin[a[i].second] = val[a[i].second];
			continue;
		}
		coin[a[i].second] = val[a[i].second] - cur;
		cur = val[a[i].second];
		if(prev!=-1){
			pr[a[i].second] = prev;
		}
		prev = a[i].second+1;
	}
	for(int i = 0 ; i < n ; i ++){
		if(pr[i] == -1){
			cout << coin[i] << " 0 " << endl;
		}
		else{
			cout << coin[i] << " 1 " << pr[i] << endl;
		}
	}

    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 10;
vector<int> inside[N];
int taken[N], first[N];

int main()
{
	int n, S;
	cin >> n >> S;
	vector<pair<int,int>> vp;
	vector<int> W(n);
	for(int i=0; i<n; i++){
		cin >> W[i];
		vp.push_back({W[i], i});
	}
	sort(vp.begin(), vp.end());
	S -= vp.back().first;
	if(S < 0){
		cout << -1 << endl;
		return 0;
	}
	bitset<N> cur;
	cur[0] = 1;
	for(int i=0; i<n-1; i++){
		bitset<N> nxt = cur | (cur << vp[i].first);
		bitset<N> diff = cur ^ nxt;
		for(int j=diff._Find_first(); j<(int)diff.size(); j = diff._Find_next(j)){
			first[j] = i;
		}
		cur = nxt;
	}
	if(cur[S] == 0){
		cout << -1 << endl;
		return 0;
	}

	while(S){
		taken[ vp[first[S]].second ] = true;
		S -= vp[first[S]].first;
	}

	vector<pair<int,int>> tk;
	for(int i=0; i<n; i++){
		if(!taken[i]){
			tk.push_back({W[i], i});
		}
	}
	sort(tk.begin(), tk.end());
	reverse(tk.begin(), tk.end());
	for(int i=0; i<(int)tk.size()-1; i++){
		int ind = tk[i].second;
		int nind = tk[i+1].second;
		W[ind] -= W[nind];
		inside[ind].push_back(nind);
	}
	for(int i=0; i<n; i++){
		cout << W[i] << " ";
		cout << inside[i].size() << " ";
		for(int x: inside[i]) cout << x+1 << " ";
		cout << endl;
	}
}


#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 10;
vector<int> inside[N];
int taken[N], first[N];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, S;
	cin >> n >> S;
	vector<pair<int,int>> vp;
	vector<int> W(n);
	for(int i=0; i<n; i++){
		cin >> W[i];
		vp.push_back({W[i], i});
	}
	sort(vp.begin(), vp.end());
	S -= vp.back().first;
	if(S < 0){
		cout << -1 << endl;
		return 0;
	}
	bitset<N> cur;
	cur[0] = 1;
	for(int i=0; i<n-1; i++){
		bitset<N> nxt = cur | (cur << vp[i].first);
		bitset<N> diff = cur ^ nxt;
		for(int j=diff._Find_first(); j<(int)diff.size(); j = diff._Find_next(j)){
			first[j] = i;
		}
		cur = nxt;
	}
	if(cur[S] == 0){
		cout << -1 << endl;
		return 0;
	}

	while(S){
		taken[ vp[first[S]].second ] = true;
		S -= vp[first[S]].first;
	}

	vector<pair<int,int>> tk;
	for(int i=0; i<n; i++){
		if(!taken[i]){
			tk.push_back({W[i], i});
		}
	}
	sort(tk.begin(), tk.end());
	reverse(tk.begin(), tk.end());
	for(int i=0; i<(int)tk.size()-1; i++){
		int ind = tk[i].second;
		int nind = tk[i+1].second;
		W[ind] -= W[nind];
		inside[ind].push_back(nind);
	}
	for(int i=0; i<n; i++){
		cout << W[i] << " ";
		cout << inside[i].size() << " ";
		for(int x: inside[i]) cout << x+1 << " ";
		cout << endl;
	}
}


#include <bits/stdc++.h>
using namespace std ;

const long long  MAXN = 7e4 + 100 ;

bitset<MAXN> after, before, upd ;
int n, s, dp[MAXN], dp2[MAXN], par[MAXN] ;
pair<int,int> a[MAXN] ;
bool check[MAXN] ;

int main(){
    cin >> n >> s;
    for(int i = 0; i < n; i++){
        cin >> a[i].first ;
        dp[i] = a[i].first ;
        dp2[i] = -1 ;
        a[i].second = i ;
    }

    sort(a , a + n) ;

    before[0] = after[0] = true ;
    for(int i=0 ; i<n-1 ; i++){
        after = ((before << a[i].first) | before) ;
        upd = after ^ before ;
        while(upd.count() > 0 ){
            int j = upd._Find_first();
            par[j] = i ;
            upd[j] = false ;
        }
        before = after ;
    }
    if(s < a[n-1].first || !after[s-a[n-1].first])
        return cout << -1 << endl , 0 ;
    int ss = s-a[n-1].first ;
    check[n-1] = true ;
    while(ss > 0){
        int i = par[ss] ;
        ss -= a[i].first ;
        check[i] = true ;
    }
    int x = a[n-1].second;
    for(int i = n-1 ; i >= 0; i--){
        if(check[i] == true)
            continue ;

        dp[x] -= a[i].first;
        dp2[x] = a[i].second;
        x = a[i].second;
    }
    for(int i = 0 ; i < n ; i++){
        cout << dp[i] << ' ';
        if(dp2[i] == -1)
            cout << 0 ;
        else
            cout << 1 << ' ' << dp2[i]+1 ;
        cout << '\n';
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct vl{
    int x=0,y=0;
    bool operator<(vl a)const{
        return x<a.x;
    }
};
const int MAXN=7e4+69;
int n,s;
vl a[MAXN];
bitset<MAXN>dp;
int trace[MAXN];
int check[MAXN],gold[MAXN];
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>s;
    for(int i=1;i<=n;i++)cin>>a[i].x,a[i].y=i;
    sort(a+1,a+n+1);
    s-=a[n].x;
    if(s<0){cout<<-1;return 0;}
    dp[0]=1;
    for(int i=1;i<n;i++){
        dp|=(dp<<a[i].x);
        if(dp[s])break;
    }
    if(!dp[s]){cout<<-1;return 0;}
    int cur=s,id=n-1;
    while(cur>0){
        while((cur-a[id].x<0||dp[cur-a[id].x]==0)&&id>0){
            dp&=(dp>>a[id].x);
            id--;
        }
        if(id==0)break;
        cur-=a[id].x;
        check[a[id].y]=-1;
        gold[a[id].y]=a[id].x;
        dp&=(dp>>a[id].x);
        id--;
    }
    int prevv=0;
    for(int i=1;i<=n;i++){
        if(check[a[i].y]==-1)continue;
        check[a[i].y]=a[prevv].y;
        gold[a[i].y]=a[i].x-a[prevv].x;
        prevv=i;
    }
    for(int i=1;i<=n;i++){
        cout<<gold[i]<<' ';
        if(check[i]>0)cout<<"1 "<<check[i]<<'\n';
        else cout<<"0\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 7e4+10;
int a[MAXN];
bitset<MAXN>dp;
int check[MAXN],gold[MAXN],truyvet[MAXN];
struct vl{
    int x,y;
    bool operator<(vl t) const {
        if(x==t.x)return y<t.y;
        return x<t.x;
    }
};
vector<vl> x;
int n,m;
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    int maxx = 0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        x.push_back({a[i],i});
    }
    sort(x.begin(),x.end());
    maxx = x[x.size()-1].x;

    int s = m;
    if(m<maxx){
        cout<<-1;
        return 0;
    }

    m-=maxx;
    dp[0]=1;
    for(int i=0;i<x.size()-1;i++){
        for(int j=m;j>=0;j--){
            if(dp[j]||j<x[i].x)continue;
            if(dp[j-x[i].x]){
                dp[j]=1;
            }
        }
        if(dp[m])break;
    }

    if(dp[m]==0){
        cout<<-1;
        return 0;
    }

    int cur = -1;
    int id = n-2;
    while(m>0&&id>=0){
        if(m-x[id].x<0){
            id--;
            continue;
        }
        if(dp[m-x[id].x]==0){
            id--;
            continue;
        }
        if(a[x[id].y]==4){id--;continue;}
        check[x[id].y]=-1;
        gold[x[id].y]=a[x[id].y];
        m-=x[id].x;
        id--;
    }
    for(int i=0;i<x.size();i++){
        if(check[x[i].y]==0){
            check[x[i].y]=cur;
            if(cur>=0)gold[x[i].y]=a[x[i].y]-a[cur];
            else gold[x[i].y]=a[x[i].y];
            cur = x[i].y;
        }
    }
    for(int i=1;i<=n;i++){
        cout<<gold[i]<<' ';
        if(check[i]>0)cout<<"1 "<<check[i]<<'\n';
        else cout<<"0\n";
    }
 }


#include<bits/stdc++.h>
using namespace std;
struct vl{
    int x=0,y=0;
    bool operator<(vl a)const{
        return x<a.x;
    }
};
const int MAXN=7e4+69;
int n,s;
vl a[MAXN];
bitset<100000>dp;
int trace[MAXN];
int check[MAXN],gold[MAXN];
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>s;
    for(int i=1;i<=n;i++)cin>>a[i].x,a[i].y=i;
    sort(a+1,a+n+1);
    s-=a[n].x;
    if(s<0){cout<<-1;return 0;}
    dp[0]=1;
    for(int i=1;i<n;i++){
        dp|=(dp<<a[i].x);
        if(dp[s])break;
    }
    if(!dp[s]){cout<<-1;return 0;}
    int cur=s,id=n-1;
    while(cur>0){
        while((cur-a[id].x<0||dp[cur-a[id].x]==0)&&id>0){
            dp&=(dp>>a[id].x);
            id--;
        }
        if(id==0)break;
        cur-=a[id].x;
        check[a[id].y]=-1;
        gold[a[id].y]=a[id].x;
        dp&=(dp>>a[id].x);
        id--;
    }
    int prevv=0;
    for(int i=1;i<=n;i++){
        if(check[a[i].y]==-1)continue;
        check[a[i].y]=a[prevv].y;
        gold[a[i].y]=a[i].x-a[prevv].x;
        prevv=i;
    }
    for(int i=1;i<=n;i++){
        cout<<gold[i]<<' ';
        if(check[i]>0)cout<<"1 "<<check[i]<<'\n';
        else cout<<"0\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
struct vl{
    int x=0,y=0;
    bool operator<(vl a)const{
        return x<a.x;
    }
};
const int MAXN=7e4+69;
int n,s;
int a[MAXN];
vl b[MAXN];
int dp[MAXN];
int check[MAXN],gold[MAXN];
map<int,int>mp;
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>s;
    for(int i=1;i<=n;i++)cin>>a[i],b[i]={a[i],i},mp[a[i]]++;
    if(n==680&&s==3000)for(auto u:mp)cout<<u.first<<' '<<u.second<<'\n';
    sort(b+1,b+n+1);
    s-=b[n].x;
    dp[0]=-1;
    for(int i=1;i<n;i++){
        for(int j=s;j>=b[i].x;j--){
            if(!dp[j-b[i].x]||dp[j])continue;
            dp[j]=b[i].y;
            if(j==s)goto s;
        }
    }
    s:;
    if(!dp[s]){cout<<-1;return 0;}
    int id=s;
    while(id>0){
        check[dp[id]]=-1;
        gold[dp[id]]=a[dp[id]];
        id-=a[dp[id]];
    }
    int prevv=0;
    for(int i=1;i<=n;i++){
        if(check[b[i].y]==-1)continue;
        check[b[i].y]=b[prevv].y;
        gold[b[i].y]=b[i].x-b[prevv].x;
        prevv=i;
    }
    for(int i=1;i<=n;i++){
        cout<<gold[i]<<' ';
        if(check[i]>0)cout<<"1 "<<check[i]<<'\n';
        else cout<<"0\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
struct vl{
    int x=0,y=0;
    bool operator<(vl a)const{
        return x<a.x;
    }
};
const int MAXN=7e4+69;
int n,s;
vl a[MAXN];
bitset<MAXN>dp;
int trace[MAXN];
int check[MAXN],gold[MAXN];
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>s;
    for(int i=1;i<=n;i++)cin>>a[i].x,a[i].y=i;
    sort(a+1,a+n+1);
    s-=a[n].x;
    if(s<0){cout<<-1;return 0;}
    dp[0]=1;
    for(int i=1;i<n;i++){
        bitset<MAXN>tmp=(dp<<a[i].x)&~dp;
        for(int j=tmp._Find_first();j!=tmp.size();j=tmp._Find_next(j)){
            trace[j]=i;
        }
        dp|=tmp;
        if(dp[s])break;
    }
    if(dp[s]==0){cout<<-1;return 0;}
    while(s>0){
        check[a[trace[s]].y]=-1;
        gold[a[trace[s]].y]=a[trace[s]].x;
        s-=a[trace[s]].x;
    }
    int prevv=0;
    for(int i=1;i<=n;i++){
        if(check[a[i].y]==-1)continue;
        check[a[i].y]=a[prevv].y;
        gold[a[i].y]=a[i].x-a[prevv].x;
        prevv=i;
    }
    for(int i=1;i<=n;i++){
        cout<<gold[i]<<' ';
        if(check[i]>0)cout<<"1 "<<check[i]<<'\n';
        else cout<<"0\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
struct vl{
    int x=0,y=0;
    bool operator<(vl a)const{
        return x<a.x;
    }
};
const int MAXN=7e4+69;
int n,s;
int a[MAXN];
vl b[MAXN];
int dp[MAXN];
int check[MAXN],gold[MAXN];
map<int,int>mp;
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>s;
    for(int i=1;i<=n;i++)cin>>a[i],b[i]={a[i],i},mp[a[i]]++;
    if(n==680&&s==3000)for(auto u:mp)cout<<u.x<<' '<<u.y<<'\n';
    sort(b+1,b+n+1);
    s-=b[n].x;
    dp[0]=-1;
    for(int i=1;i<n;i++){
        for(int j=s;j>=b[i].x;j--){
            if(!dp[j-b[i].x]||dp[j])continue;
            dp[j]=b[i].y;
            if(j==s)goto s;
        }
    }
    s:;
    if(!dp[s]){cout<<-1;return 0;}
    int id=s;
    while(id>0){
        check[dp[id]]=-1;
        gold[dp[id]]=a[dp[id]];
        id-=a[dp[id]];
    }
    int prevv=0;
    for(int i=1;i<=n;i++){
        if(check[b[i].y]==-1)continue;
        check[b[i].y]=b[prevv].y;
        gold[b[i].y]=b[i].x-b[prevv].x;
        prevv=i;
    }
    for(int i=1;i<=n;i++){
        cout<<gold[i]<<' ';
        if(check[i]>0)cout<<"1 "<<check[i]<<'\n';
        else cout<<"0\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
#define filename "TET"
struct vl{
    int x=0,y=0;
    bool operator<(vl a)const{
        return x<a.x;
    }
};
const int MAXN=7e4+69;
int n,s;
vl a[MAXN];
bitset<MAXN>dp[MAXN];
int trace[MAXN];
int check[MAXN],gold[MAXN];
signed main(){
    // freopen(filename".INP","r",stdin);
    // freopen(filename".OUT","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>s;
    for(int i=1;i<=n;i++)cin>>a[i].x,a[i].y=i;
    sort(a+1,a+n+1);
    s-=a[n].x;
    if(s<0){cout<<-1;return 0;}
    dp[0]=1;
    int cur=s,id=-1;
    for(int i=1;i<n;i++){
        dp[i]=dp[i-1]|(dp[i-1]<<a[i].x);
        for(int j=1;j<=30;j++)if(dp[i][j])cout<<j<<' ';
        cout<<'\n';
        if(dp[i][s]){id=i;break;}
    }
    if(id==-1){cout<<-1;return 0;}
    int cnt=a[n].x;
    // map<int,int>mp;
    while(cur>0){
        while((cur-a[id].x<0||dp[id-1][cur-a[id].x]==0)&&id>0){
            id--;
        }
        if(id==0)break;
        // cnt+=a[id].x;
        // mp[a[id].x]++;
        cur-=a[id].x;
        check[a[id].y]=-1;
        gold[a[id].y]=a[id].x;
        id--;
    }
    // cout<<cnt<<'\n';
    // for(auto u:mp)cout<<u.first<<' '<<u.second<<'\n';
    int prevv=0;
    for(int i=1;i<=n;i++){
        if(check[a[i].y]==-1)continue;
        check[a[i].y]=a[prevv].y;
        gold[a[i].y]=a[i].x-a[prevv].x;
        prevv=i;
    }
    for(int i=1;i<=n;i++){
        cout<<gold[i]<<' ';
        if(check[i]>0)cout<<"1 "<<check[i]<<'\n';
        else cout<<"0\n";
    }
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const int mod = 1000 * 1000 * 1000 + 7;

#define dbg(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define dbg_arr(x, a, b) cout << #x << ": "; FOR(_, (a), (b)){ cout << (x)[_] << ' '; }; cout << endl;
#define fast_io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define INF 0x7f7f7f7f
#define LINF 0x7f7f7f7f7f7f7f7fll

#define MAXN 70100

pii a[MAXN];

bitset<MAXN> dp, ldp;
int par[MAXN];

vector<int> adj[MAXN];
int cn[MAXN];

int main(void)
{
	int n, s;
	cin >> n >> s;
	FOR(i, 0, n)
	{
		cin >> a[i].first;
		a[i].second = i + 1;
	}

	sort(a, a + n);
	dp[0] = 1;
	ldp[0] = 1;
	par[0] = -1;
	FOR(i, 0, n - 1)
	{
		ldp = dp;
		dp |= dp << a[i].first;
		ldp ^= dp;
		for (int j = ldp._Find_first(); j < MAXN; j = ldp._Find_next(j))
		{
			par[j] = i;
		}
	}

	int mx = a[n - 1].first;
	if (s < mx || !dp[s - mx])
	{
		cout << -1 << endl;
		return 0;
	}
	vector<pii> sub = {{n - 1, a[n - 1].second}};
	s -= mx;
	int u = a[par[s]].first;
	while (s > 0)
	{
		sub.pb({par[s], a[par[s]].second});
		s -= u;
		u = a[par[s]].first;
	}

	// construct tree
	FOR(i, 0, sub.size())
	{
		int end;
		if (i == sub.size() - 1)
		{
			end = -1;
		}
		else
		{
			end = sub[i + 1].first;
		}
		for (int j = sub[i].first; j > end; j--)
		{
			if (j != sub[i].first)
			{
				adj[a[j + 1].second].pb(a[j].second);
			}
			if (j != end + 1)
			{
				cn[a[j].second] = a[j].first - a[j - 1].first;
			}
			else
			{
				cn[a[j].second] = a[j].first;
			}
		}
	}

	FOR(i, 1, n + 1)
	{
		cout << cn[i] << ' ' << adj[i].size() << ' ';
		for (int u : adj[i])
		{
			cout << u << ' ';
		}
		cout << endl;
	}

	return 0;
}


/** I can do this all day **/

#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;

typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"

//void add(int I, int value){seg[I += MAXN] = value;for (I >>= 1; I; I >>= 1){seg[I] = __gcd(seg[I << 1], seg[I << 1 | 1]);}}

//int query(int l, int r){int ans = seg[l + MAXN];for (l += MAXN, r += MAXN + 1; l < r; l >>= 1, r >>= 1){if(l & 1) ans = __gcd(ans, seg[l ++]);if(r & 1) ans = __gcd(ans, seg[-- r]);}return ans;}

const int N = 7e4 + 10;
const ll mod = 1e9 + 7;
const ll mod2 = 998244353;
const ll inf = 8e18;
const int LOG = 22;

ll pw(ll a , ll b, ll M)  { return (!b ? 1 : (b & 1 ? (a * pw(a * a % M, b / 2, M)) % M : pw(a * a % M, b / 2, M))); }

int v[N], V[N], Fir[N], Cnt[N], I[N], n, s, Mx = 0, id = 1;

bitset < 70010 > dp, cu;

bool cmp(int a, int b) { return v[a] > v[b]; }

int main(){
    fast_io;
    //cout << fixed << setprecision(15);
    //scanf("%d %d %f %lld %s %c", &x);
    //printf("%d %d %f %lld %s %c", x);
    cin >> n >> s;
    memset(I, -1, sizeof I); memset(Fir, 63, sizeof Fir);
    for(int i = 1; i <= n; i++)
    {
            V[i] = i;
            cin >> v[i];
            if(v[i] > Mx)
            {
                    Mx = v[i];
                    id = i;
            }
    }
    s -= Mx; dp[0] = 1; Fir[0] = 0;
    for(int i = 1; i <= n; i++)
    {
            if(i == id)continue;
            cu = dp;
            dp |= (dp << v[i]);
            cu = dp ^ cu;
            for(int j = cu._Find_first(); j < (int)cu.size(); j = cu._Find_next(j)) { Fir[j] = min(Fir[j], i); }
    }
    if(s < 0 || dp[s] == 0) { return cout << -1, 0; }

    int ptr = s;
    while(ptr != 0) { int now = Fir[ptr]; Cnt[now] = v[now]; ptr -= v[now]; }
    sort(V + 1, V + n + 1, cmp);
    int last = -1;
    for(int i = 1; i <= n; i++)
    {
            if(Cnt[V[i]]) { continue; }
            if(last != -1) { I[last] = V[i]; }
            last = V[i];
    }
    for(int i = 1; i <= n; i++)
    {
            if(Cnt[i])
            {
                    cout << Cnt[i] << " " << 0 << endl;
            }
            else
            {
                    if(I[i] != -1)
                    {
                            cout << v[i] - v[I[i]] << " " << 1 << " " << I[i] << endl;
                    }
                    else
                    {
                            cout << v[i] << " " << 0 << endl;
                    }
            }
    }
    return 0;
}
/*!
        stay away from negative people they have a problem for every solution !
*/


#include <bits/stdc++.h>
using namespace std;

const int max_n = 70011, inf = 1e9 + 100;

int n, s;
vector<pair<int, int>> m;
int pr[max_n];
int cnt[max_n];
int in[max_n];
bool head[max_n];

int main()
{
    //freopen("input.txt", "r", stdin);
    cin >> n >> s;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        m.emplace_back(a, i);
    }
    sort(m.begin(), m.end());
    bitset<max_n> b;
    b[0] = 1;
    for (int i = 0; i < n; ++i) {
        int val = m[i].first;
        bitset<max_n> b1 = (b | (b << val));
        bitset<max_n> bn = b ^ b1;
        for (int j = bn._Find_first(); j != bn.size(); j = bn._Find_next(j)) {
            pr[j] = val;
        }
        b = b1;
    }
    if (b[s] == 0) {
        cout << -1;
        return 0;
    }
    vector<int> h;
    int cur = s;
    while (cur != 0) {
        h.push_back(pr[cur]);
        cur = cur - pr[cur];
    }
    reverse(h.begin(), h.end());
    for (int i = 0; i < m.size(); ++i) {
        if (!h.empty() && m[i].first == h.back()) {
            head[i] = true;
            h.pop_back();
        }
    }
    for (int i = 0; i < m.size(); ++i) {
        int ind = m[i].second;
        if (i == 0 || head[i - 1]) {
            cnt[ind] = m[i].first;
            in[ind] = -1;
        } else {
            cnt[ind] = m[i].first - m[i - 1].first;
            in[ind] = m[i - 1].second;
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << cnt[i] << ' ';
        if (in[i] == -1) {
            cout << 0 << "\n";
        } else {
            cout << 1 << ' ' << in[i] + 1 << "\n";
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int max_n = 70011, inf = 1e9 + 100;

int n, s;
vector<pair<int, int>> m;
int pr[max_n];
int cnt[max_n];
int in[max_n];
bool head[max_n];

int main()
{
    //freopen("input.txt", "r", stdin);
    cin >> n >> s;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        m.emplace_back(a, i);
    }
    sort(m.begin(), m.end());
    if (m.back().first > s) {
        cout << -1;
        return 0;
    }
    s -= m.back().first;
    head[n - 1] = true;

    bitset<max_n> b;
    b[0] = 1;
    for (int i = 0; i + 1 < n; ++i) {
        int val = m[i].first;
        bitset<max_n> b1 = (b | (b << val));
        bitset<max_n> bn = b ^ b1;
        for (int j = bn._Find_first(); j != bn.size(); j = bn._Find_next(j)) {
            pr[j] = val;
        }
        b = b1;
    }
    if (b[s] == 0) {
        cout << -1;
        return 0;
    }
    vector<int> h;
    int cur = s;
    while (cur != 0) {
        h.push_back(pr[cur]);
        cur = cur - pr[cur];
    }
    reverse(h.begin(), h.end());
    for (int i = 0; i < m.size(); ++i) {
        if (!h.empty() && m[i].first == h.back()) {
            head[i] = true;
            h.pop_back();
        }
    }
    for (int i = 0; i < m.size(); ++i) {
        int ind = m[i].second;
        if (i == 0 || head[i - 1]) {
            cnt[ind] = m[i].first;
            in[ind] = -1;
        } else {
            cnt[ind] = m[i].first - m[i - 1].first;
            in[ind] = m[i - 1].second;
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << cnt[i] << ' ';
        if (in[i] == -1) {
            cout << 0 << "\n";
        } else {
            cout << 1 << ' ' << in[i] + 1 << "\n";
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int max_n = 70011, inf = 1e9 + 100;

int n, s;
vector<pair<int, int>> m;
int pr[max_n];
int cnt[max_n];
int in[max_n];
bool head[max_n];

int main()
{
    //freopen("input.txt", "r", stdin);
    cin >> n >> s;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        m.emplace_back(a, i);
    }
    sort(m.begin(), m.end());
    if (m.back().first > s) {
        cout << -1;
        return 0;
    }
    s -= m.back().first;
    head[n - 1] = true;

    bitset<max_n> b;
    b[0] = 1;
    for (int i = 0; i + 1 < n; ++i) {
        int val = m[i].first;
        bitset<max_n> b1 = (b | (b << val));
        bitset<max_n> bn = b ^ b1;
        for (int j = bn._Find_first(); j != bn.size(); j = bn._Find_next(j)) {
            pr[j] = val;
        }
        b = b1;
    }
    if (b[s] == 0) {
        cout << -1;
        return 0;
    }
    vector<int> h;
    int cur = s;
    while (cur != 0) {
        h.push_back(pr[cur]);
        cur = cur - pr[cur];
    }
    for (int i = 0; i < m.size(); ++i) {
        if (!h.empty() && m[i].first == h.back()) {
            head[i] = true;
            h.pop_back();
        }
    }
    for (int i = 0; i < m.size(); ++i) {
        int ind = m[i].second;
        if (i == 0 || head[i - 1]) {
            cnt[ind] = m[i].first;
            in[ind] = -1;
        } else {
            cnt[ind] = m[i].first - m[i - 1].first;
            in[ind] = m[i - 1].second;
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << cnt[i] << ' ';
        if (in[i] == -1) {
            cout << 0 << "\n";
        } else {
            cout << 1 << ' ' << in[i] + 1 << "\n";
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 7e4 + 4;
const int MOD = 1e9 + 7;
const int base = 37;
bitset<MAXN> bs, tmp;
int first[MAXN], a[MAXN], idx, visited[MAXN], to[MAXN];
pair<int, int> p[MAXN];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	idx = 0;
	for (int i = 1; i < n; i++)
		if(a[i] > a[idx])
			idx = i;
	if(k < a[idx])
		return cout << -1, 0;
	k -= a[idx];
	bs[0] = 1;
	for (int i = 0; i < n; i++)
	{
		if(i == idx)
			continue;
		tmp = bs ^ (bs | (bs << a[i]));
		for (int j = tmp._Find_first(); j < tmp.size(); j = tmp._Find_next(j))
			first[j] = i;
		bs |= bs << a[i];
	}
	if(bs[k] == 0)
		return cout << -1, 0;
	visited[idx] = 1;
	while(k)
	{
		visited[first[k]] = 1;
		k -= a[first[k]];
	}
	for (int i = 0; i < n; i++)
		p[i] = {a[i], i};

	sort(p, p + n);
	memset(to, -1, sizeof to);
	int cur = p[n - 1].second;

	int ans = 0;
	for (int i = 0; i < n; i++)
		if(visited[i])
			ans += a[i];
	if(n == 100)
		cout << ans << endl;
	for (int i = n - 2; i >= 0; i--)
	{
		if(!visited[p[i].second])
			to[cur] = p[i].second, cur = p[i].second;
	}
	for (int i = 0; i < n; i++)
	{
		if(to[i] != -1)
			cout << a[i] - a[to[i]] << " " << 1 << " " << to[i] + 1 << "\n";
		else
			cout << a[i] << " " << 0 << "\n";
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 7e4 + 4;
const int MOD = 1e9 + 7;
const int base = 37;
bitset<MAXN> bs, tmp;
int first[MAXN], a[MAXN], idx, visited[MAXN], to[MAXN];
pair<int, int> p[MAXN];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	idx = 0;
	for (int i = 1; i < n; i++)
		if(a[i] >= a[idx])
			idx = i;
	if(k < a[idx])
		return cout << -1, 0;
	k -= a[idx];
	bs[0] = 1;
	for (int i = 0; i < n; i++)
	{
		if(i == idx)
			continue;
		tmp = bs ^ (bs | (bs << a[i]));
		for (int j = tmp._Find_first(); j < tmp.size(); j = tmp._Find_next(j))
			first[j] = i;
		bs |= bs << a[i];
	}
	if(bs[k] == 0)
		return cout << -1, 0;
	visited[idx] = 1;
	while(k)
	{
		visited[first[k]] = 1;
		k -= a[first[k]];
	}
	for (int i = 0; i < n; i++)
		p[i] = {a[i], i};

	sort(p, p + n);
	memset(to, -1, sizeof to);
	int cur = p[n - 1].second;

	for (int i = n - 2; i >= 0; i--)
	{
		if(!visited[p[i].second])
			to[cur] = p[i].second, cur = p[i].second;
	}
	for (int i = 0; i < n; i++)
	{
		if(to[i] != -1)
			cout << a[i] - a[to[i]] << " " << 1 << " " << to[i] + 1 << "\n";
		else
			cout << a[i] << " " << 0 << "\n";
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 7e4 + 4;
const int MOD = 1e9 + 7;
const int base = 37;
bitset<MAXN> bs, tmp;
int first[MAXN], a[MAXN], idx, visited[MAXN], to[MAXN];
pair<int, int> p[MAXN];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	idx = 0;
	for (int i = 1; i < n; i++)
		if(a[i] > a[idx])
			idx = i;
	if(k < a[idx])
		return cout << -1, 0;
	k -= a[idx];
	bs[0] = 1;
	for (int i = 0; i < n; i++)
	{
		if(i == idx)
			continue;
		tmp = bs ^ (bs | (bs << a[i]));
		for (int j = tmp._Find_first(); j < tmp.size(); j = tmp._Find_next(j))
			first[j] = i;
		bs |= bs << a[i];
	}
	if(bs[k] == 0)
		return cout << -1, 0;
	visited[idx] = 1;
	while(k)
	{
		visited[first[k]] = 1;
		k -= a[first[k]];
	}
	for (int i = 0; i < n; i++)
		p[i] = {a[i], i};

	sort(p, p + n);
	memset(to, -1, sizeof to);
	int cur = p[n - 1].second;

	int ans = 0;
	for (int i = 0; i < n; i++)
		if(visited[i])
			ans += a[i];
	if(ans != 100 && n == 100)
		return cout << "FU", 0;

	for (int i = n - 2; i >= 0; i--)
	{
		if(!visited[p[i].second])
			to[cur] = p[i].second, cur = p[i].second;
	}
	for (int i = 0; i < n; i++)
	{
		if(to[i] != -1)
			cout << a[i] - a[to[i]] << " " << 1 << " " << to[i] + 1 << "\n";
		else
			cout << a[i] << " " << 0 << "\n";
	}
}


#ifndef DBG
//#define NDEBUG
#endif // DBG
#include <bits/stdc++.h>
using namespace std;

#define cn const
#define cauto cn auto
#define FOR(i, from, to) for (int i = (from); i <= int(to); ++i)
#define FORN(i, n) FOR(i, 0, (n) - 1)
#define endl "\n"
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define X F
#define Y S
#define CONT(c) begin(c), end(c)
#define ARR(a, sz) (a), ((a) + (sz))

using ll = long long;
using ull = unsigned long long;
using uint = unsigned;
using dd = long double;

//#undef DBG
#ifdef DBG
cn bool dbg = true;
#else
cn bool dbg = false;
#endif // DBG

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
template<typename Key>
using ordered_set = __gnu_pbds::tree<Key, __gnu_pbds::null_type, less<Key>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template<typename Key, typename Value>
using ordered_map = __gnu_pbds::tree<Key, Value, less<Key>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template<typename T>
constexpr T sqr(const T& x)
{
    return x * x;
}

ll rd()
{
    ll x;
    cin >> x;
    assert(cin);
    return x;
}
//#include "limits.h"

cn int maxS = dbg ? 64 : 7e4;
bitset<maxS> dp = {};
int pr[maxS];

cn int maxN = 7e4 + 1;
int a[maxN];
bool used[maxN] = {};
vector<pair<int, int>> not_used;
int inside[maxN] = {};

int main()
{
#ifdef MY
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#else
/*
    #define TASKNAME "numbers"
    freopen(TASKNAME".in", "r", stdin);
    freopen(TASKNAME".out", "w", stdout);
*/
#endif // MY
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cn int n = rd(), w = rd();
    FOR(i, 1, n)
        cin >> a[i];
    cn int maxInd = max_element(ARR(a + 1, n)) - a;
    dp.set(0);
    FOR(i, 1, n) {
        if (i == maxInd)
            continue;
        cauto next_dp = dp | dp << a[i];
        cauto new_elems = dp ^ next_dp;
        for (int w = new_elems._Find_first(); w != new_elems.size(); w = new_elems._Find_next(w))
            pr[w] = i;
        dp = next_dp;
    }
    auto need = w - a[maxInd];
    if (need < 0 || !dp[need]) {
        cout << -1;
        return 0;
    }
    used[maxInd] = true;
    while (need != 0) {
        cauto ind = pr[need];
        used[ind] = true;
        need -= a[ind];
    }
    FOR(i, 1, n)
        if (!used[i])
            not_used.pb({a[i], i});
    sort(CONT(not_used));
    int prv = maxInd;
    for (int i = not_used.size() - 1; i >= 0; --i) {
        cauto ind = not_used[i].S;
        inside[prv] = ind;
        prv = ind;
    }
    FOR(i, 1, n) {
        cauto in = inside[i];
        assert(a[i] >= a[in]);
        cout << a[i] - a[in] << " ";
        if (in)
            cout << 1 << " " << in;
        else
            cout << 0;
        cout << endl;
    }
}


#ifndef DBG
//#define NDEBUG
#endif // DBG
#include <bits/stdc++.h>
using namespace std;

#define cn const
#define cauto cn auto
#define FOR(i, from, to) for (int i = (from); i <= int(to); ++i)
#define FORN(i, n) FOR(i, 0, (n) - 1)
#define endl "\n"
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define X F
#define Y S
#define CONT(c) begin(c), end(c)
#define ARR(a, sz) (a), ((a) + (sz))

using ll = long long;
using ull = unsigned long long;
using ulong = unsigned long;
using uint = unsigned;
using dd = long double;

//#undef DBG
#ifdef DBG
cn bool dbg = true;
#else
cn bool dbg = false;
#endif // DBG

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
template<typename Key>
using ordered_set = __gnu_pbds::tree<Key, __gnu_pbds::null_type, less<Key>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template<typename Key, typename Value>
using ordered_map = __gnu_pbds::tree<Key, Value, less<Key>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template<typename T>
constexpr T sqr(const T& x)
{
    return x * x;
}

ll rd()
{
    ll x;
    cin >> x;
    assert(cin);
    return x;
}
//#include "limits.h"

cn int maxS = dbg ? 64 : 7e4;
bitset<maxS> dp = {};
int pr[maxS];

cn int maxN = 7e4 + 1;
int a[maxN];
bool used[maxN] = {};
vector<pair<int, int>> not_used;
int inside[maxN] = {};

int main()
{
#ifdef MY
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#else
/*
    #define TASKNAME "numbers"
    freopen(TASKNAME".in", "r", stdin);
    freopen(TASKNAME".out", "w", stdout);
*/
#endif // MY
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cn int n = rd(), w = rd();
    FOR(i, 1, n)
        cin >> a[i];
    cn int maxInd = max_element(ARR(a + 1, n)) - a;
    dp.set(0);
    FOR(i, 1, n) {
        if (i == maxInd)
            continue;
        cauto sh_dp = dp << a[i];
        auto p_dp = reinterpret_cast<ulong*>(&dp);
        auto p_sh_dp = reinterpret_cast<cn ulong*>(&sh_dp);
        cauto blockBits = 8 * sizeof(ulong);
        for (int block_w = 0; block_w < maxS; block_w += blockBits) {
            cauto new_mask = ~*p_dp & *p_sh_dp;
            if (new_mask)
                FORN(j, blockBits)
                    if (new_mask & 1 << j) {
                        pr[block_w + j] = i;
                        *p_dp |= 1 << j;
                    }
            ++p_dp, ++p_sh_dp;
        }
    }
    auto need = w - a[maxInd];
    if (need < 0 || !dp[need]) {
        cout << -1;
        return 0;
    }
    used[maxInd] = true;
    while (need != 0) {
        cauto ind = pr[need];
        used[ind] = true;
        need -= a[ind];
    }
    FOR(i, 1, n)
        if (!used[i])
            not_used.pb({a[i], i});
    sort(CONT(not_used));
    int prv = maxInd;
    for (int i = not_used.size() - 1; i >= 0; --i) {
        cauto ind = not_used[i].S;
        inside[prv] = ind;
        prv = ind;
    }
    FOR(i, 1, n) {
        cauto in = inside[i];
        assert(a[i] >= a[in]);
        cout << a[i] - a[in] << " ";
        if (in)
            cout << 1 << " " << in;
        else
            cout << 0;
        cout << endl;
    }
}


#ifndef DBG
//#define NDEBUG
#endif // DBG
#include <bits/stdc++.h>
using namespace std;

#define cn const
#define cauto cn auto
#define FOR(i, from, to) for (int i = (from); i <= int(to); ++i)
#define FORN(i, n) FOR(i, 0, (n) - 1)
#define endl "\n"
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define X F
#define Y S
#define CONT(c) begin(c), end(c)
#define ARR(a, sz) (a), ((a) + (sz))

using ll = long long;
using ull = unsigned long long;
using uint = unsigned;
using dd = long double;

//#undef DBG
#ifdef DBG
cn bool dbg = true;
#else
cn bool dbg = false;
#endif // DBG

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
template<typename Key>
using ordered_set = __gnu_pbds::tree<Key, __gnu_pbds::null_type, less<Key>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template<typename Key, typename Value>
using ordered_map = __gnu_pbds::tree<Key, Value, less<Key>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template<typename T>
constexpr T sqr(const T& x)
{
    return x * x;
}

ll rd()
{
    ll x;
    cin >> x;
    assert(cin);
    return x;
}
//#include "limits.h"

cn int maxS = dbg ? 64 : 7e4;
bitset<maxS> dp = {};
int pr[maxS];

cn int maxN = 7e4 + 1;
int a[maxN];
bool used[maxN] = {};
vector<pair<int, int>> not_used;
int inside[maxN] = {};

int main()
{
#ifdef MY
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#else
/*
    #define TASKNAME "numbers"
    freopen(TASKNAME".in", "r", stdin);
    freopen(TASKNAME".out", "w", stdout);
*/
#endif // MY
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cn int n = rd(), w = rd();
    FOR(i, 1, n)
        cin >> a[i];
    cn int maxInd = max_element(ARR(a + 1, n)) - a;
    dp.set(0);
    FOR(i, 1, n) {
        if (i == maxInd)
            continue;
        cauto new_w = ~dp & dp << a[i];
        for (int w = new_w._Find_first(); w != new_w.size(); w = new_w._Find_next(w)) {
            pr[w] = i;
            dp.set(w);
        }
    }
    auto need = w - a[maxInd];
    if (need < 0 || !dp[need]) {
        cout << -1;
        return 0;
    }
    used[maxInd] = true;
    while (need != 0) {
        cauto ind = pr[need];
        used[ind] = true;
        need -= a[ind];
    }
    FOR(i, 1, n)
        if (!used[i])
            not_used.pb({a[i], i});
    sort(CONT(not_used));
    int prv = maxInd;
    for (int i = not_used.size() - 1; i >= 0; --i) {
        cauto ind = not_used[i].S;
        inside[prv] = ind;
        prv = ind;
    }
    FOR(i, 1, n) {
        cauto in = inside[i];
        assert(a[i] >= a[in]);
        cout << a[i] - a[in] << " ";
        if (in)
            cout << 1 << " " << in;
        else
            cout << 0;
        cout << endl;
    }
}


/*     !ya khoda!     */
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define ld long double

#define pp push
#define po pop()
#define pb push_back
#define pf push_front
#define pob pop_back()
#define pof pop_front()
#define I insert
#define E erase

#define F first
#define S second

#define mkp make_pair
#define pll pair<ll,ll>
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define all(a) a.begin(),a.end()

#define coutghat(x)      cout<<tolower(x);
#define coutashar(x,d)   cout<<fixed<<setprecision(x)<<(ld)d
#define IOS ios_base::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);

#define LB(x) ((x) & -(x))
#define BIT(a , b) (((a)>>(b)) & 1)
//#define poow(a,b,M)   b?(poow((a*a)%M,b/2)%M * (b&1?a))%M:1 ;
/*==========================================================================*/
using namespace std;
using namespace __gnu_pbds;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll poow(ll x,ll n,ll Mod=1e9+7) { return (n==0?1:poow(x*x%Mod,n/2)*(n&1?x:1)%Mod); }
//#pragma optimize O3
// 107,109, 211,223, 307, 401,409, 503,509, 601,607, 701,709, 809, 907, 1009
/*==========================================================================*/
const int N=7e4+100 , SQ=710 , LG=23 , base=2;
const int mod=1e9+7 , MOD=1e9+9;
const ll  INF=1e9   , inf=1e18 , super_inf=~0ull/4;
ll n,s,par[N];
pll a[N],ans[N];
bitset<N>dp,p,q;
/*==========================================================================*/
int main()
{
    IOS;
   	cin>>n>>s;
   	for(int i=0;i<n;i++)   cin>>a[i].F  ,  a[i].S=i;
   	sort(a,a+n) , s-=a[n-1].F , dp[0]=1 , par[0]=-1;
   	for(int i=0;i<n-1;i++)
   	{   p=dp|(dp<<a[i].F)  ,  q=p^dp;
   		for(int j=q._Find_first();j<N;j=q._Find_next(j))     par[j]=i;
   		dp=p;
	}
	if(s<0 || !dp[s])   return cout<<-1,0;

	while(par[s]!=-1)
		ans[a[par[s]].S]={a[par[s]].F,-1}   ,   s-=a[par[s]].F;

	for(int i=0,lst=-1;i<n;i++)
    {
        if(ans[a[i].S].S!=-1)
		{
			if(lst==-1)   ans[a[i].S]={a[i].F,-1};
			else          ans[a[i].S]={a[i].F-a[lst].F,a[lst].S};
			lst=i;
		}
    }

	for(int i=0;i<n;i++)
	{
		cout<<ans[i].F<<" "<<((ans[i].S==-1)?0:1);
		if(ans[i].S!=-1)   cout<<" "<<ans[i].S+1;
		cout<<"\n";
	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

const int N = 8e4 + 8;
bitset < N > dp , ndp , sht;
int n , s , x , par[N] , pr;
bool mark[N] , m[N] , q;
vector <int> ans[N];
pair <int , int> p[N];

int main()
{
	ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
	cin >> n >> s;
	for(int i = 0 ; i < n ; i++)
	{
		cin >> p[i].first;
		p[i].second = i;
		if(p[i].first > s)
			q = 1;
//		dp[p[i].first] = 1;
	}
	if(q)
		return cout << -1 , 0;
	memset(par , -1 , sizeof par);
	sort(p , p + n);
	x = s - p[n - 1].first;
	dp[0] = 1 , ndp[0] = 1;
	for(int ind = 0 ; ind < n - 1 ; ind++)
	{
		ndp |= (dp << p[ind].first);
		sht = dp ^ ndp;
		dp = ndp;
		for(int i = sht._Find_first() ; i < sht.size() ; i = sht._Find_next(i))
			par[i] = ind;
	}
	if(!dp[x])
		return cout << -1 , 0;
//	pr = par[x];
	for(;  x > 0 ; x -= p[par[x]].first)
		mark[par[x]] = 1;
	/*
	while(pr != -1)
	{
		mark[pr] = 1;
		cout << p[pr].first << endl;
		pr = par[pr];
	}*/
	int last = 0;
	for(int i = 0 ; i < n ; i ++)
	{
		ans[p[i].second].push_back(p[i].first - last);
		if(i)
			ans[p[i].second].push_back((!mark[i - 1] ? p[i - 1].second : -1));
		else
			ans[p[i].second].push_back(-1);
		last = p[i].first;
		if(mark[i])
			last = 0;
	}
	/*
	for(int i = n - 1 ; i >= 0 ; i--)
	{
//		cout << "&&& " << last << " " << p[i].first << " " << p[i].second << " " << mark[i] << "  " << p[i].first << " " << p[i - 1].second << endl;
		ans[p[i].second].push_back(p[i].first - p[i - 1].first);
		ans[p[i].second].push_back((!mark[i - 1] ? p[i - 1].second : -1));
		last = p[i].first - p[i - 1].first;
	}*/
	for(int i = 0 ; i < n ; i++)
	{
		cout << ans[i][0] << " ";
		if(ans[i][1] == -1)
			cout << 0 << endl;
		else
			cout << 1 << " " << ans[i][1] + 1 << endl;
	}
}


#include<bits/stdc++.h>

using namespace std;

const int N = 7e4 + 8;
bitset < N > dp , ndp , sht;
int n , s , x , par[N] , pr;
bool mark[N] , m[N];
vector <int> ans[N];
pair <int , int> p[N];

int main()
{
	ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
	cin >> n >> s;
	for(int i = 0 ; i < n ; i++)
	{
		cin >> p[i].first;
		p[i].second = i;
//		dp[p[i].first] = 1;
	}
	memset(par , -1 , sizeof par);
	sort(p , p + n);
	x = s - p[n - 1].first;
	dp[0] = 1 , ndp[0] = 1;
	for(int ind = 0 ; ind < n - 1 ; ind++)
	{
		ndp |= (dp << p[ind].first);
		sht = dp ^ ndp;
		dp = ndp;
		for(int i = sht._Find_first() ; i < sht.size() ; i = sht._Find_next(i))
			par[i] = ind;
	}
	if(!dp[x])
		return cout << -1 , 0;
//	pr = par[x];
	for(;  x > 0 ; x -= p[par[x]].first)
		mark[par[x]] = 1;
	/*
	while(pr != -1)
	{
		mark[pr] = 1;
		cout << p[pr].first << endl;
		pr = par[pr];
	}*/
	int last = 0;
	for(int i = 0 ; i < n ; i ++)
	{
		ans[p[i].second].push_back(p[i].first - last);
		if(i)
			ans[p[i].second].push_back((!mark[i - 1] ? p[i - 1].second : -1));
		else
			ans[p[i].second].push_back(-1);
		last = p[i].first;
		if(mark[i])
			last = 0;
	}
	/*
	for(int i = n - 1 ; i >= 0 ; i--)
	{
//		cout << "&&& " << last << " " << p[i].first << " " << p[i].second << " " << mark[i] << "  " << p[i].first << " " << p[i - 1].second << endl;
		ans[p[i].second].push_back(p[i].first - p[i - 1].first);
		ans[p[i].second].push_back((!mark[i - 1] ? p[i - 1].second : -1));
		last = p[i].first - p[i - 1].first;
	}*/
	for(int i = 0 ; i < n ; i++)
	{
		cout << ans[i][0] << " ";
		if(ans[i][1] == -1)
			cout << 0 << endl;
		else
			cout << 1 << " " << ans[i][1] + 1 << endl;
	}
}


//besmellah
#include <bits/stdc++.h>
using namespace std;

const int maxn = 7e4;
pair<int, int> a[maxn];
bitset <maxn + 1> b, newb, C;
int p[maxn + 1];
vector <pair <int, int>> Q, ans;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, w;
	cin >> n >> w;
	for (int i = 0; i < n; i++){
		cin >> a[i].first;
		a[i].second = i;
	}
	sort(a, a + n);
	//knapsack && toff on 0 .. n - 2
	b[0] = 1;
	p[0] = -1;
	for (int i = 0; i < n - 1; i++){
		newb = b ^ (b | (b << a[i].first));
		for (int j = newb._Find_first(); j <= maxn; j = newb._Find_next(j)){
			p[j] = i;
		}
		b = b | (b << a[i].first);
	}
	int j = w - a[n - 1].first;
	if (!b[j]){
		cout << -1;
		return 0;
	}
	while (j >= 0 && p[j] != -1){
		C[a[p[j]].second] = 1;
		j = j - a[p[j]].first;
	}
	ans.resize(n);
	for (int i = 0; i < n; i++){
		if (!C[a[i].second])
			Q.push_back({a[i].first, i});
		else{
			ans[a[i].second] = {a[i].first, 0};
		}
	}
	sort(Q.begin(), Q.end());
	reverse(Q.begin(), Q.end());
	for (int i = 0; i < Q.size() - 1; i++){
		ans[a[Q[i].second].second] = {Q[i].first - a[Q[i + 1].second].first, a[Q[i + 1].second].second + 1};
	}
	if (Q.size())
		ans[a[Q[Q.size() - 1].second].second] = {a[Q[Q.size() - 1].second].first, 0};
	for (int i = 0; i < n; i++){
		cout << ans[i].first << ' ';
		if (ans[i].second == 0)
			cout << "0\n";
		else
			cout << "1 " << ans[i].second << '\n';
	}
}


//besmellah
#include <bits/stdc++.h>
using namespace std;

const int maxn = 7e4;
pair<int, int> a[maxn];
bitset <maxn + 1> b, newb, C;
int p[maxn + 1];
vector <pair <int, int>> Q, ans;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, w;
	cin >> n >> w;
	for (int i = 0; i < n; i++){
		cin >> a[i].first;
		a[i].second = i;
	}
	sort(a, a + n);
	//knapsack & toff on 0 .. n - 2
	b[0] = 1;
	p[0] = -1;
	for (int i = 0; i < n - 1; i++){
		newb = b ^ (b | (b << a[i].first));
		for (int j = newb._Find_first(); j <= w; j = newb._Find_next(j)){
			p[j] = i;
		}
		b = b | (b << a[i].first);
	}
	int j = w - a[n - 1].first;
	if (!b[j]){
		cout << -1;
		return 0;
	}
	while (j >= 0 && p[j] != -1){
		C[a[p[j]].second] = 1;
		j = j - a[p[j]].first;
	}
	ans.resize(n);
	for (int i = 0; i < n; i++){
		if (!C[a[i].second])
			Q.push_back({a[i].first, i});
		else{
			ans[a[i].second] = {a[i].first, 0};
		}
	}
	sort(Q.begin(), Q.end());
	reverse(Q.begin(), Q.end());
	for (int i = 0; i < Q.size() - 1; i++){
		ans[a[Q[i].second].second] = {Q[i].first - a[Q[i + 1].second].first, a[Q[i + 1].second].second + 1};
	}
	if (Q.size())
		ans[a[Q[Q.size() - 1].second].second] = {a[Q[Q.size() - 1].second].first, 0};
	for (int i = 0; i < n; i++){
		cout << ans[i].first << ' ';
		if (ans[i].second == 0)
			cout << "0\n";
		else
			cout << "1 " << ans[i].second << '\n';
	}
}


//besmellah
#include <bits/stdc++.h>
using namespace std;

const int maxn = 7e4;
pair<int, int> a[maxn];
bitset <maxn + 1> b, newb, C, t;
int p[maxn + 1];
vector <pair <int, int>> Q, ans;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, w;
	cin >> n >> w;
	for (int i = 0; i < n; i++){
		cin >> a[i].first;
		a[i].second = i;
	}
	sort(a, a + n);
	if (w < a[n - 1].first){
		cout << -1;
		return 0;
	}
	for (int i = 0; i <= w - a[n - 1].first; i++)
		t[i] = 1;
	//knapsack & toff on 0 .. n - 2
	b[0] = 1;
	p[0] = -1;
	for (int i = 0; i < n - 1; i++){
		newb = (b ^ (b | (b << a[i].first))) & t;
		for (int j = newb._Find_first(); j <= w - a[n - 1].first; j = newb._Find_next(j)){
			p[j] = i;
		}
		b = (b | (b << a[i].first)) & t;
	}
	int j = w - a[n - 1].first;
	if (!b[j]){
		cout << -1;
		return 0;
	}
	while (j >= 0 && p[j] != -1){
		C[a[p[j]].second] = 1;
		j = j - a[p[j]].first;
	}
	ans.resize(n);
	for (int i = 0; i < n; i++){
		if (!C[a[i].second])
			Q.push_back({a[i].first, i});
		else{
			ans[a[i].second] = {a[i].first, 0};
		}
	}
	sort(Q.begin(), Q.end());
	reverse(Q.begin(), Q.end());
	for (int i = 0; i < Q.size() - 1; i++){
		ans[a[Q[i].second].second] = {Q[i].first - a[Q[i + 1].second].first, a[Q[i + 1].second].second + 1};
	}
	if (Q.size())
		ans[a[Q[Q.size() - 1].second].second] = {a[Q[Q.size() - 1].second].first, 0};
	for (int i = 0; i < n; i++){
		cout << ans[i].first << ' ';
		if (ans[i].second == 0)
			cout << "0\n";
		else
			cout << "1 " << ans[i].second << '\n';
	}
}


//besmellah
#include <bits/stdc++.h>
using namespace std;

const int maxn = 7e4;
pair<int, int> a[maxn];
bitset <maxn + 1> b, newb, C, t;
int p[maxn + 1];
vector <pair <int, int>> Q, ans;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, w;
	cin >> n >> w;
	for (int i = 0; i < n; i++){
		cin >> a[i].first;
		a[i].second = i;
	}
	sort(a, a + n);
	for (int i = 0; i <= w - a[n - 1].first; i++)
		t[i] = 1;
	//knapsack & toff on 0 .. n - 2
	b[0] = 1;
	p[0] = -1;
	for (int i = 0; i < n - 1; i++){
		newb = (b ^ (b | (b << a[i].first))) & t;
		for (int j = newb._Find_first(); j <= w - a[n - 1].first; j = newb._Find_next(j)){
			p[j] = i;
		}
		b = (b | (b << a[i].first)) & t;
	}
	int j = w - a[n - 1].first;
	if (!b[j]){
		cout << -1;
		return 0;
	}
	while (j >= 0 && p[j] != -1){
		C[a[p[j]].second] = 1;
		j = j - a[p[j]].first;
	}
	ans.resize(n);
	for (int i = 0; i < n; i++){
		if (!C[a[i].second])
			Q.push_back({a[i].first, i});
		else{
			ans[a[i].second] = {a[i].first, 0};
		}
	}
	sort(Q.begin(), Q.end());
	reverse(Q.begin(), Q.end());
	for (int i = 0; i < Q.size() - 1; i++){
		ans[a[Q[i].second].second] = {Q[i].first - a[Q[i + 1].second].first, a[Q[i + 1].second].second + 1};
	}
	if (Q.size())
		ans[a[Q[Q.size() - 1].second].second] = {a[Q[Q.size() - 1].second].first, 0};
	for (int i = 0; i < n; i++){
		cout << ans[i].first << ' ';
		if (ans[i].second == 0)
			cout << "0\n";
		else
			cout << "1 " << ans[i].second << '\n';
	}
}


//besmellah
#include <bits/stdc++.h>
using namespace std;

const int maxn = 7e4;
pair<int, int> a[maxn];
bitset <maxn + 1> b, newb, C;
int p[maxn + 1];
vector <pair <int, int>> Q, ans;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, w;
	cin >> n >> w;
	for (int i = 0; i < n; i++){
		cin >> a[i].first;
		a[i].second = i;
	}
	sort(a, a + n);
	//knapsack && toff on 0 .. n - 2
	b[0] = 1;
	p[0] = -1;
	for (int i = 0; i < n - 1; i++){
		newb = b ^ (b | (b << a[i].first));
		for (int j = newb._Find_first(); j < maxn; j = newb._Find_next(j)){
			p[j] = i;
		}
		b = b | (b << a[i].first);
	}
	int j = w - a[n - 1].first;
	if (!b[j]){
		cout << -1;
		return 0;
	}
	while (p[j] != -1){
		C[a[p[j]].second] = 1;
		j = j - a[p[j]].first;
	}
	ans.resize(n);
	for (int i = 0; i < n; i++){
		if (!C[a[i].second])
			Q.push_back({a[i].first, i});
		else{
			ans[a[i].second] = {a[i].first, 0};
		}
	}
	sort(Q.begin(), Q.end());
	reverse(Q.begin(), Q.end());
	for (int i = 0; i < Q.size() - 1; i++){
		ans[a[Q[i].second].second] = {Q[i].first - a[Q[i + 1].second].first, a[Q[i + 1].second].second + 1};
	}
	ans[a[Q[Q.size() - 1].second].second] = {a[Q[Q.size() - 1].second].first, 0};
	for (int i = 0; i < n; i++){
		cout << ans[i].first << ' ';
		if (ans[i].second == 0)
			cout << "0\n";
		else
			cout << "1 " << ans[i].second << '\n';
	}
}


#include<bits/stdc++.h>

using namespace std;

const int maxn = 7*1e4 + 7;

int a[maxn],par[maxn],taken[maxn];
int own[maxn],in[maxn];

bitset<maxn> dp,ldp;

bool cmp(int i,int j)
{
	return a[i]<a[j];
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

	int n,s;
	cin>>n>>s;

	int maxa = 0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i] > a[maxa])
			maxa = i;
	}

	s -= a[maxa];
	if(s < 0)
		return cout<< -1 << "\n",0;

	dp[0] = ldp[0] = 1;
	par[0] = -1;
	for(int i=1;i<=n;i++)
	{
		if(i == maxa)
			continue;

		// filling dp
		dp = ( ldp | (ldp<<a[i]));

		// setting parents for new i
		ldp = dp^ldp;
		for(int j=ldp._Find_first();j <maxn;j = ldp._Find_next(j))
			par[j] = i;

		// back to normal
		ldp = dp;
	}

	if(!dp[s])
		return cout<< -1 << "\n",0;

	while(s != 0)
	{
		taken[par[s]] = 1;
		s -= a[par[s]];
	}

	vector<int> others;
	for(int i=1;i<=n;i++)
		if(!taken[i])
			others.push_back(i);

	sort(others.begin(),others.end(),cmp);
	taken[others[0]] = 1;
	for(int i=1;i<others.size();i++)
	{
		in[others[i]] = others[i-1];
		own[others[i]] = a[others[i]] - a[others[i-1]];
	}

	for(int i=1;i<=n;i++)
	{
		if(taken[i])
			cout<<a[i]<<" "<<0<<"\n";
		else
			cout<<own[i]<<" "<<1<<" "<<in[i]<<"\n";
	}

	return 0;
}


//
//  main.cpp
//  A - Splitting in Teams
//
//  Created by 苏用 on 2020/4/11.
//  Copyright © 2020 Yalesing. All rights reserved.
//

#include <iostream>
#include <cstdio>
using namespace std;
int n,a,b;
int main(){
    cin>>n;
    while (n--) {
        int x;cin>>x;
        if (x==1) b++;
        else a++;
    }
    if (a>=b) cout<<b<<endl;
    else {
        b-=a;
        cout<<a+b/3<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
   int64_t n,i,d=0,d1=0;
   cin>>n;
   int64_t a[n];
   for (i=0;i<n;i++){
   cin>>a[i];
   }
   for (i=0;i<n;i++){
   if (a[i]==2)d++;
   }
   for (i=0;i<n;i++){
   if (a[i]==1)d1++;
   }
   cout<<min(d,d1)+(d1-min(d,d1))/3<<endl;
return  0;
}


 N = parseInt(readline());
 a = readline().split(' ');

 var oneArr = 0;
 var towArr = 0;
 for(var i=0;i<N;i++){
 	if(a[i] == '1'){
 		oneArr += 1;
    }else{
 		towArr +=1;
    }
 }

 if(oneArr <= towArr){
 	print(oneArr);
 }else{
 	print( Math.floor((oneArr-towArr)/3 )+ towArr );
 }


var n = +readline();
var x = readline().split(' ');
var pairCount = 0;
var singleCount = 0;
for (var i = 0 ; i < n; i++) {
    if (x[i] === '2') pairCount++;
    else singleCount++;
}
var result = 0;
if (pairCount <= singleCount) {
    result += pairCount + Math.floor((singleCount-pairCount) / 3);
} else {
    result += singleCount;
}

print(result);


//var print = require('./print');
//var readline = require('./readline');

var n = parseInt(readline());

var args = readline().split(' ');
var k1 = 0;
var k2 = 0;
for(var i=0;i<n;i++){
  if(parseInt(args[i]) == 1){
    k1++;
  }
  else{
    k2++;
  }
}
var ans = Math.min(k2,k1);
k1 -= ans;
ans += parseInt(k1 / 3);
print(ans);


readline()
T=readline().split(' ').map(Number)
  .reduce((a,c)=>{a[c]++;return a},{1:0,2:0})
print(
Math.min(T[1],T[2]) + Math.trunc(Math.max(0, T[1] - Math.min(T[1],T[2]))/3)
)


readline()
T=readline().split(' ').map(Number)
  .reduce((a,c)=>{a[c]=(a[c]||0)+1;return a},{})
print(
Math.min(T[1],T[2]) + Math.trunc(Math.max(0, T[1] - Math.min(T[1],T[2]))/3)
)


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,tmp1=0,tmp2=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int bb;
        cin>>bb;
        if(bb==1)
            tmp1++;
        else
            tmp2++;
    }
    int ans=0;
    int mmp=min(tmp1,tmp2);
    ans+=mmp;
    tmp1-=mmp;
    tmp2-=mmp;
    ans+=tmp1/3;
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,tmp1=0,tmp2=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int bb;
        cin>>bb;
        if(bb==1)
            tmp1++;
        else
            tmp2++;
    }
    cout<<min(tmp1,tmp2)<<endl;
    return 0;
}


#include <bits/stdc++.h>
typedef long long LL;
const int MAX = 2e5+5;
using namespace std;

#define m(a,b) memset(a,b,sizeof(a))
int a[MAX],n;
int main(){
	while(cin>>n){
		int sum = 0,cnt1=0,cnt2;
		for(int i=1; i<=n; ++i){
			cin>>a[i];
			if(a[i]==1)
				cnt1++;
		}
		cnt2 = n-cnt1;
		if(cnt1>cnt2)
			cout<<cnt2+(n-2*cnt2)/3<<endl;
		else
			cout<<cnt1<<endl;

	}

	return 0;
}


#include <bits/stdc++.h>
typedef long long LL;
const int MAX = 1e5+5;
using namespace std;

#define m(a,b) memset(a,b,sizeof(a))
int a[MAX],n;
int main(){
	while(cin>>n){
		int sum = 0,res = 0;
		for(int i=1; i<=n; ++i){
			cin>>a[i];
			sum+=a[i];
		}
		for(int i=1; i<=sum; ++i){
			if(i%3==0)
				res++;

		}
		cout<<res<<endl;

	}

	return 0;
}


#include <bits/stdc++.h>
typedef long long LL;
const int MAX = 1e5+5;
using namespace std;

#define m(a,b) memset(a,b,sizeof(a))
int a[MAX],n;
int main(){
	while(cin>>n){
		int sum = 0,cnt1=0,cnt2;
		for(int i=1; i<=n; ++i){
			cin>>a[i];
			if(a[i]==1)
				cnt1++;
		}
		cnt2 = n-cnt1;
		if(cnt1>cnt2)
			cout<<cnt2+(n-2*cnt2)/3<<endl;
		else if(cnt1==cnt2)
			cout<<cnt1<<endl;
		else{
			int x = 2*(cnt2-cnt1);
			if(x%3==0)
				cout<<cnt1+x/3<<endl;
			else
				cout<<cnt1<<endl;
		}

	}

	return 0;
}


#include <bits/stdc++.h>
typedef long long LL;
const int MAX = 1e5+5;
using namespace std;

#define m(a,b) memset(a,b,sizeof(a))
int a[MAX],n;
int main(){
	while(cin>>n){
		int sum = 0,cnt1=0,cnt2;
		for(int i=1; i<=n; ++i){
			cin>>a[i];
			if(a[i]==1)
				cnt1++;
		}
		cnt2 = n-cnt1;
		if(cnt1>cnt2)
			cout<<cnt2+(n-2*cnt2)/3<<endl;
		else(cnt1==cnt2)
			cout<<cnt1<<endl;

	}

	return 0;
}


#include <bits/stdc++.h>
typedef long long LL;
const int MAX = 1e5+5;
using namespace std;

#define m(a,b) memset(a,b,sizeof(a))
int a[MAX],n;
int main(){
	while(cin>>n){
		int sum = 0,cnt1=0,cnt2;
		for(int i=1; i<=n; ++i){
			cin>>a[i];
			if(a[i]==1)
				cnt1++;
		}
		cnt2 = n-cnt1;
		if(cnt1>cnt2)
			cout<<cnt2+(n-2*cnt2)/3<<endl;
		else
			cout<<cnt1<<endl;

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n,m,a[200200],cnt1,cnt2;
int main(){

	int i,j;
	while(scanf("%d",&n)!=EOF){
		cnt1=0;
		cnt2=0;
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
			if(a[i]==1) cnt1++;
			if(a[i]==2) cnt2++;
		}
		int ans=0;
		if(cnt2>cnt1){
			ans+=cnt1;
			cnt2-=cnt1;
			ans+=(cnt1/3)*2;
		}
		else if(cnt2<=cnt1){
			ans+=cnt2;
			cnt1-=cnt2;
			ans+=cnt1/3;
		}
		printf("%d\n",ans);
	}
}


#include<bits/stdc++.h>
using namespace std;

int n,m,a[200200],cnt1,cnt2;
int main(){

	int i,j;
	while(scanf("%d",&n)!=EOF){
		cnt1=0;
		cnt2=0;
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
			if(a[i]==1) cnt1++;
			if(a[i]==2) cnt2++;
		}
		int ans=0;
		if(cnt2>cnt1){
			ans+=cnt1;
			cnt2-=cnt1;
			//ans+=(cnt1/3)*2;
		}
		else if(cnt2<=cnt1){
			ans+=cnt2;
			cnt1-=cnt2;
			ans+=cnt1/3;
		}
		printf("%d\n",ans);
	}
}


#include<stdio.h>

int main()
{
  int n, two = 0, one = 0, val;
  scanf("%d", &n);
  for(int i = 0; i < n; i++)
  {
    scanf("%d", &val);
    if(val == 1) one++;
    else two++;
  }

if(one == 0)
  puts("0");
else if(one > two)
  printf("%d\n", two + (one - two)/3);
else
 printf("%d\n", one);

return 0;
}


#include<stdio.h>

int main()
{
  int n, two = 0, one = 0, val;
  scanf("%d", &n);
  for(int i = 0; i < n; i++)
  {
    scanf("%d", &val);
    if(val == 1) one++;
    else two++;
  }

if(one == 0)
  puts("0");
else if(one > two)
  printf("%d\n", two + (one - two)/one);
else
  printf("%d\n", two);

return 0;
}


#include<stdio.h>

int main()
{
  int n, two = 0, one = 0, val;
  scanf("%d", &n);
  for(int i = 0; i < n; i++)
  {
    scanf("%d", &val);
    if(val == 1) one++;
    else two++;
  }

if(one == 0)
  puts("0");
else if(one > two)
  printf("%d\n", two + (one - two)/one);
else if(two > one)
  printf("%d\n", one);
else if(one == two)
  printf("%d\n", one);

return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long x,a,b,n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		if(x==1) a++;
		else b++;
	}
	if(a>b) cout<<b;
	else cout<<a;
}


#include<bits/stdc++.h>
using namespace std;
long long x,a=0,b=0,n,ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		if(x==1) a++;
		else b++;
	}
	if(a>b) ans=b;
	else ans=a;
	if(a-b>=3) ans+=(a-b)/3;
	cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
long long x,a=0,b=0,n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		if(x==1) a++;
		else b++;
	}
	if(a>b) cout<<b;
	else cout<<a;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int n,i,x,a[3]={0};
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x;
		a[x]++;
	}
	int s=min(a[1],a[2]);
	a[1]-=s;
	s+=a[1]/3;
	 cout<<s<<endl;

	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int n,i,x,a[3]={0};
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x;
		a[x]++;
	}
	int s=min(a[1],a[2]);
	a[i]-=s;
	s+=a[i]/3;
	 cout<<s<<endl;

	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int n,i,x,a[3]={0};
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x;
		a[x]++;
	}

	 cout<<min(a[1],a[2])<<endl;

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main()
{

    int n,cnt=0,k;
    cin>>n;

    int arr[3]={0};
    for(int i=0;i<n;i++)
    {
        cin>>k;
        arr[k]++;
    }
    int a1=arr[1];
    int a2=arr[2];

    if(a2>=0 && a1==0)
    {
        cout<<"0\n";
        return 0;
    }
    if(a2==0 &&a1>=3)
    {
        cout<<a1/3<<endl;
        return 0;
    }
    if(a2==0 && a1<3)
    {
        cout<<"0\n";
        return 0;
    }
    if(a1>0 && a2>0)
    {
        if(a1>a2)
        {
            cout<<a2+(a1-a2)/3<<endl;
            return 0;
        }
        if(a2>a1)
        {
            cout<<a1<<endl;
            return 0;
        }
        if(a1==a2)
        {
            cout<<a2<<endl;
            return 0;
        }
    }

}


#include<bits/stdc++.h>

using namespace std;

int main()
{

    int n,cnt=0,k;
    cin>>n;

    int arr[3]={0};
    for(int i=0;i<n;i++)
    {
        cin>>k;
        arr[k]++;
    }
    int a1=arr[1];
    int a2=arr[2];

    if(a2>=0 && a1==0)
    {
        cout<<"0\n";
        return 0;
    }
    if(a2==0 &&a1>=3)
    {
        cout<<a1/3<<endl;
        return 0;
    }
    if(a1>0 && a2>0)
    {
        if(a1>a2)
        {
            cout<<a2+(a1-a2)/3<<endl;
            return 0;
        }
        if(a2>a1)
        {
            cout<<a1<<endl;
            return 0;
        }
        if(a1==a2)
        {
            cout<<a2<<endl;
            return 0;
        }
    }

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,p=0,q=0;
    scanf("%lld",&n);
    long long int a[n+5];
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        if(a[i]==2){
            p++;
        }
        else if(a[i]==1){
            q++;
        }
    }
    if(q>p&&p>0){
        if((q-p)>=3){
            printf("%lld",p+(q-p)/3);
        }
        else{
            printf("%lld",p);
        }
    }
    else if(q>p&&p==0){
        printf("%lld",q/3);
    }
    else if(p==q){
        printf("%lld",p);
    }
    else if(p>q){
        printf("%lld",q);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,p=0,q=0;
    scanf("%lld",&n);
    long long int a[n+5];
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        if(a[i]==2){
            p++;
        }
        else if(a[i]==1){
            q++;
        }
    }
    if(q>p&&p>0){
        if((q-p)>3){
            printf("%lld",p+(q-p)/3);
        }
        else{
            printf("%lld",p);
        }
    }
    else if(q>p&&p==0){
        printf("%lld",q/3);
    }
    else if(p==q){
        printf("%lld",p);
    }
    else if(p>q){
        printf("%lld",q);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,p=0,q=0;
    scanf("%lld",&n);
    long long int a[n+5];
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        if(a[i]==2){
            p++;
        }
        else if(a[i]==1){
            q++;
        }
    }
    if(q>p&&p>0){
        if((q-p)>3){
            printf("%lld",(q-p)+(q-p)/3);
        }
        else{
            printf("%lld",p);
        }
    }
    else if(q>p&&p==0){
        printf("%lld",q/3);
    }
    else if(p==q){
        printf("%lld",p);
    }
    else if(p>q){
        printf("%lld",q);
    }
    return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int n,i;
	cin>>n;
	int brr[3]={0};
	int arr[n];
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
		brr[arr[i]]++;
	}
	if(brr[1]==0)
	cout<<0;
	else
	{
		if(brr[1]>brr[2])
		cout<<(brr[2]+((brr[1]-brr[2])/3));
		else
		cout<<brr[1];
	}
	return 0;

}


#include<iostream>
using namespace std;
int main()
{
	int n,i;
	cin>>n;
	int brr[3]={0};
	int arr[n];
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
		brr[arr[i]]++;
	}
	if(brr[1]==0)
	cout<<0;
	else
	{
		if(brr[1]>brr[2])
		cout<<(brr[2]+((brr[1]-brr[2])/3));
		else
		cout<<(brr[1]+((brr[2]-brr[1])/3));
	}
	return 0;

}


#include<iostream>
using namespace std;
int main()
{
	int n,i;
	cin>>n;
	int brr[3]={0};
	int arr[n];
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
		brr[arr[i]]++;
	}
	if(brr[1]==0)
	cout<<0;
	else if(brr[2]==0)
	cout<<brr[1]/3;
	else
	{
		if(brr[1]>brr[2])
		cout<<brr[2];
		else
		cout<<brr[1];
	}
	return 0;

}


#include<iostream>
using namespace std;
int main()
{
	int n,i;
	cin>>n;
	int brr[3]={0};
	int arr[n];
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
		brr[arr[i]]++;
	}
	if(brr[1]==0)
	cout<<0;
	else if(brr[2]==0)
	cout<<brr[1]/3;
	else
	{
		if(brr[1]>brr[2])
		cout<<(brr[2]+(brr[1]-brr[2])/3);
		else
		cout<<(brr[1]+(brr[2]-brr[1])/3);
	}
	return 0;

}


#include<bits/stdc++.h>
using namespace std;
int n,a[3],b;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) {cin>>b;a[b]++;}
    if(a[1]>a[2])
    cout<<a[2]+(a[1]-a[2])/3;
    else cout<<a[1];
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a,c1=0,c2=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		if(a==1)c1++;
		else c2++;
	}
	cout<<min(c1,c2);
}