#include <iostream>
#include <fstream>
#include <unordered_map>
using namespace std;
ifstream f ("loto.in");
ofstream g ("loto.out");
unordered_map<int,pair<int,int>> dic;
unordered_map<int,pair<pair<int,int>,pair<int,int>>> dic2;
int v[100];
int main()
{
int n, s, nr;
f >> n >> s;
for (int i = 0; i < n; i++)
f >> v[i];
for (int i = 0; i < n;i ++)
for (int j = 0; j < n; j++)
dic[v[i]+v[j]] = {v[i],v[j]};
for (auto p1: dic)
for (auto p2:dic)
dic2[p1.second.first+p1.second.second+p2.second.first+p2.second.second] = {{p1.second.first,p1.second.second},{p2.second.first,p2.second.second}};
/*
for (auto p1: dic)
for (auto p2:dic)
for (auto p3:dic)
if (p1.first + p2.first + p3.first == s) {
g << p1.second.first << ' ' << p1.second.second << ' ' << p2.second.first << ' ' << p2.second.second << ' ' << p3.second.first << ' ' << p3.second.second;
return 0;
}
*/
for (auto p1: dic)
for (auto p2: dic2)
if (p1.first + p2.first == s){
g<< p1.second.first << ' ' << p1.second.second << ' ' << p2.second.first.first << ' ' << p2.second.first.second << ' '<< p2.second.second.first << ' ' << p2.second.second.second;
return 0;
}
g << -1;
return 0;
}