#include <stdio.h>
#include <stdlib.h>
struct point {
short a,b,c;
point *leg;
};
point *h[200000];
long s,s1,s2,i,j,k,nr,x,v[101];
int n,n1,ok;
void insert(short a1, short b1, short c1, long x) {
point *p;
p=new point;
p->a=a1;
p->b=b1;
p->c=c1;
p->leg=h[x];
h[x]=p;
}
int chash(point *p, long s1,int &a1,int &b1,int &c1) {
int ok;
ok=0;
while (p!=NULL)
if (s2==((p->a)+(p->b)+(p->c))) {
a1=p->a;
b1=p->b;
c1=p->c;
return 1;
}
else p=p->leg;
return 0;
}
int cautare(int i) {
int ok,a1,b1,c1;
ok=0;
while (h[i]!=NULL) {
s2=s-((h[i]->a)+(h[i]->b)+(h[i]->c));
x=s2%n1;
a1=b1=c1=0;
ok=chash(h[x],s2,a1,b1,c1);
if (ok) {
printf("%d %d %d %d %d %d\n",h[i]->a,h[i]->b,h[i]->c,a1,b1,c1);
return 1;
}
h[i]=h[i]->leg;
}
return 0;
}
int main () {
freopen("loto.in","r",stdin);
freopen("loto.out","w",stdout);
scanf("%d%ld",&n,&s);
n1=n/3;
for (i=1; i<=n; i++) scanf("%d",&v[i]);
for (i=1; i<=n; i++)
for (j=i; j<=n; j++)
for (k=j; k<=n; k++) {
nr=v[i]+v[j]+v[k];
x=nr%n1;
insert(v[i],v[j],v[k],x);
}
for (i=0; i<=n1; i++) {
ok=0;
ok=cautare(i);
if (ok) break;
}
if (!ok) printf("-1");
return 0;
}