n = int(input())
x = []
for i in range(n):
x.append(int(input()))
m = int(input())
for i in range(len(x)):
for j in range(len(x) // 2):
if (x[i] + x[j]) % m == 0 and i != j:
print(x[i], x[j])
#include <iostream>
main()
{
int x = 5;
}