#include<stdio.h>
#include<string.h>
void main()
{
int n,i,j;
char inputChar[12];
char outCh[7]="6";
scanf("%d%*c",&n);
for(i=0;i<n;i++)
{
scanf("%s",inputChar);
outCh[1]=inputChar[6];
outCh[2]=inputChar[7];
outCh[3]=inputChar[8];
outCh[4]=inputChar[9];
outCh[5]=inputChar[10];
outCh[6]='\0';
printf("%s\n",outCh);
}
}