#include<bits/stdc++.h>
using namespace std;
void targetSum(int arr[], int n, int s)
{
for (int i=0; i<n; i++){
for (int j=i+1; j<n; j++){
int sum = arr[i]+arr[j];
if (sum==s){
cout<<arr[i]<<" and "<<arr[j]<<endl;
}
}
}
}
int main() {
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
int x;
cin>>x;
targetSum(arr,n,x);
return 0;
}