import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
for(int j=0;j<n;j++) {
a[j] = sc.nextInt();
}
int m = sc.nextInt();
int sum = 0;
for(int i=0;i<a.length;i++) {
for(int j=i+1; j<a.length;j++) {
sum = a[i]+a[j];
if(sum==m) {
System.out.println(a[i]+" "+"and"+" "+a[j]);
}
}
}
}
}