#include <bits/stdc++.h>
using namespace std;
char M[11] = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};
int a[17] = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
int n;
int main()
{
cin >> n;
int cnt = 0;
while (n--)
{
string s;
int sum = 0;
bool flog = true;
cin >> s;
for (int i = 0; i < 17; i++)
{
if (isdigit(s[i])) sum += (s[i] - '0') * a[i];
else flog = false;
}
if (M[sum % 11] != s.back()) flog = false;
if (!flog)
{
cnt++;
cout << s << endl;
}
}
if (!cnt) puts("All passed");
return 0;
}