#include <iostream>
using namespace std;
int pc(int n)
{
while (n >= 10)
{
n /= 10;
}
return n;
}
int main()
{
int n, x, cnt = 0, a[10000];
cin >> n;
for (int i = 1; i <= n; ++i)
{
cin >> x;
if (pc(x) == x % 10)
{
cnt++;
a[cnt] = x;
}
}
for (int i = 1; i <= cnt; ++i)
{
cout << a[i] << " ";
}
return 0;
}