#include <iostream>
using namespace std;
int main()
{
int n, c, copie, v[101]; cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> v[i];
c = v[i] % 10;
copie = v[i];
while (copie > 9)
copie = copie / 10;
if (c == copie)
cout << v[i] << " ";
}
return 0;
}