#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int a[17] = {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};//权重
int b[11] = {1,0,10,9,8,7,6,5,4,3,2};//这里把x替换成了10,方便后面判断
bool vl(){
int sum = 0;
for(int i=0;i<17;i++){
if(s[i]<'0' || s[i]>'9') return false;
sum += (s[i] - '0' ) * a[i];//乘上权重
}
int xx = (s[17] == 'X') ? 10 : s[17] - '0';
return b[sum%11] == xx;
}
int main()
{
cin>>n;
bool flag = false;
for(int i=0;i<n;i++){
cin>>s;
if(!vl()){
cout<<s<<endl;
flag= true;
}
}
if(!flag) cout<<"All passed";
return 0;
}