#include <iostream>
bool cifre_impare_palindrom(const int n, const size_t k) {
size_t c = 0;
int m = n, x = 0;
while (m) {
x *= 10;
x += m % 10;
c += m & 1;
m /= 10;
}
return c == k && x == n;
}
int main() {
size_t i, k, n, c = 0;
std::cin >> k >> n;
int temp, *t = new int[n];
for (i = 0; i < n; ++i) {
std::cin >> temp;
if (cifre_impare_palindrom(temp, k))
t[c++] = temp;
}
for (i = 0; i < c; ++i)
std::cout << t[i] << ' ';
delete[] t;
}