//
// main.cpp
// Loto
//
// Created by Mara Dascalu on 07/04/2021.
//
#include <iostream>
#include <fstream>
#include <unordered_map>
#include <tuple>
using namespace std;
ifstream input("loto.in");
ofstream output("loto.out");
unordered_map<int, tuple<int, int, int>> v_hash;
int nr, suma;
int v[101];
bool gasit;
int main(){
input>>nr>>suma;
for (int i = 0; i < nr; i++)
input>>v[i];
for (int i = 0; i < nr; i++)
for (int j = i ; j < nr; i++)
for (int k = j ; k < nr; k++)
v_hash[v[i] + v[j] + v[k]] = make_tuple(v[i], v[j], v[k]);
// for (auto i = v_hash.begin(); i != v_hash.end(); i++)
// cout<<i -> first<< " "<< get<0>(i -> second)<< " "<< get<1>(i -> second)<< " "<< get<2>(i -> second);
for (int i = 0; i < nr; i++)
for (int j = 0; j < nr; j++)
for (int k = 0; k < nr; k++)
{
int s = v[i] + v[j] + v[k];
s = suma - s;
if (v_hash.find(s) != v_hash.end())
{
output<<v[i]<<" "<<v[j]<<" "<<v[k]<<" "<<get<0>(v_hash[s])<<" "<<get<1>(v_hash[s])<<" "<<get<2>(v_hash[s]);
gasit = 1;
}
}
if (!gasit) output<<-1;
}