#include <stdio.h>
#include <math.h>
int main() {
int n;
scanf("%d", &n);
if (n == 0) return 0;
int row = pow(2, n);
while (1) {
int num = 0;
char t1 = getchar();
while (t1 == '\n') {
t1 = getchar();
}
if(t1 == EOF) return 0;
if(t1 == '#') num += 8;
char t2 = getchar();
while (t2 == '\n') {
t2 = getchar();
}
if(t2 == '#') num += 4;
char t3 = getchar();
while (t3 == '\n') {
t3 = getchar();
}
if(t3 == '#') num += 2;
char t4 = getchar();
while (t4 == '\n') {
t4 = getchar();
}
if(t4 == '#') num += 1;
printf("%d ",num);
}
return 0;
}