#include
#include
using namespace std;
int main() {
int n;
int a[1000];
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
}
int sum;
cin>>sum;
sort(a,a+n);
// for(int i=0;i<n;i++){
// cout<<a[i]<<" ";
// }
for(int i=0;i<n;i++){
int l = i+1;
int r = n-1;
int newsum = sum - i;//10-1
while (l < r) {
if (a[l] + a[r] == newsum) {
cout<<a[i]<<","<<a[l]<<"and"<<a[r]<<endl;
}
else if (a[l] + a[r] < newsum) {
l++;
}
else {
r--;
}
}
}
return 0;
}