public class r7_8 {
public static void main(String[] args) {
String regexIdCard = "(^\\d{15}$)|(^\\d{17}([0-9]|X)$)";
int[] A = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
char[] M = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};
int n;
int sum = 0;
Set<String> t = new HashSet<>();
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
sc.nextLine();
String[] s = new String[n];
for (int i = 0; i < n; i++) {
s[i] = sc.nextLine();
}
for (int i = 0; i < n; i++) {
boolean isMatched = s[i].matches(regexIdCard);
if (!isMatched)
t.add(s[i]);
for (int j = 0; j < 17; j++) {
int m = s[i].charAt(j) - 48;
sum = sum + A[j] * m;
}
if (M[sum % 11] != s[i].charAt(17) || !isMatched) {
t.add(s[i]);
}
sum = 0;
}
if (t.isEmpty()) {
System.out.println("All passed");
} else {
for (int i = 0; i < t.size(); i++) {
System.out.println(t.toArray()[i]);
}
}
}
public static void main(String[] args) {
String regexIdCard = "(^\\d{15}$)|(^\\d{17}([0-9]|X)$)";
int[] A = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
char[] M = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};
int n;
int sum = 0;
Set<String> t = new HashSet<>();
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
sc.nextLine();
String[] s = new String[n];
for (int i = 0; i < n; i++) {
s[i] = sc.nextLine();
}
for (int i = 0; i < n; i++) {
boolean isMatched = s[i].matches(regexIdCard);
if (!isMatched)
t.add(s[i]);
for (int j = 0; j < 17; j++) {
int m = s[i].charAt(j) - 48;
sum = sum + A[j] * m;
}
if (M[sum % 11] != s[i].charAt(17) || !isMatched) {
t.add(s[i]);
}
sum = 0;
}
if (t.isEmpty()) {
System.out.println("All passed");
} else {
for (int i = 0; i < t.size(); i++) {
System.out.println(t.toArray()[i]);
}
}
}