#include<stdio.h> int main() { //freopen("in","r",stdin); int n,a,t,i; scanf("%d",&n);getchar(); while(n--) { char c,s[35]; for(int j=1;j<=4;j++){ for(i=0,t=128,a=0;i<8;i++) { while(scanf("%c",&c)==1) if(c=='0'||c=='1') break; if(c=='1') a+=t; t=t/2; } printf("%d",a); if(j!=4) printf("."); } printf(" "); } return 0; }