//  #牛客春招刷题训练营# https://www.nowcoder.com/discuss/726480854079250432
#include <iostream>
using namespace std;
using ll = long long;
void hf_vr_uu_zi(string s){//---------字符串转二进制
  int hfv_ans = 0, w = 8;
  for (int i = 0; i < 4; i++){
    if (s[i] == '#')
      hfv_ans += w;
    w /= 2;
  }
  cout << hfv_ans << ' ';
}
int power(int n){//----------用快速幂计算2的n次
  int ans = 1;
  int temp = 2;
  while(n){
    if (n&1) ans *= temp;
    temp *= temp;
    n /= 2;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
  ll a;
  cin >> a;
  a = power(a);
  a *= a;//------平方算出一共要输入多少个
  int js = 0;
  char c;
  string s;
  while(a>0){
    js = 0;
    s = "";
    while(js < 4){//---------每输入4个转一次
      cin >> c;
      s+=c;
      a--;
      js++;
    }
    hf_vr_uu_zi(s);    
  }
  return 0;
}
// 64 位输出请用 printf("%lld")