#include <fstream>
#include <vector>
#define MOD 666013
#define NMAX 100
using namespace std;
///1017932
ifstream cin ("loto.in");
ofstream cout ("loto.out");
///1017932
int v[NMAX + 1];
struct suma {
int a, b, c, sum;
};
vector <suma> myhash[MOD];
///1017932
void add(int s, int x, int y, int z) {
int i, n, nr;
///1017932
nr = s % MOD;
n = myhash[nr].size();
i = 0;
while (i < n && myhash[nr][i].sum != s)
i++;
if (i == n)
myhash[nr].push_back({x, y, z, s});
}
///1017932
int search(int s) {
int i, n, nr;
///1017932
nr = s % MOD;
n = myhash[nr].size();
i = 0;
while (i < n && myhash[nr][i].sum != s)
i++;
if (i == n)
return -1;
return i;
}
///1017932
int main() {
int n, scautat, i, ok, x, y, z, j, l, poz, s, nr;
cin >> n >> scautat;
///1017932
for (i = 0; i < n; i++)
cin >> v[i];
///1017932
ok = 0;
for (i = 0; i < n && ok == 0; i++) {
for (j = i; j < n && ok == 0; j++) {
for (l = j; l < n && ok == 0; l++) {
x = v[i];
y = v[j];
z = v[l];
s = x + y + z;
add(s, x, y, z);
if (scautat >= s)
poz = search(scautat - s);
if (scautat >= s && poz != -1) {
nr = (scautat - s) % MOD;
ok = 1;
cout << x << " " << y << " " << z << " " << myhash[nr][poz].a << " " << myhash[nr][poz].b << " " << myhash[nr][poz].c;
}
}
}
}
if (ok == 0)
cout << -1;
return 0;
}