var a = '66666',
b = '6...6',
c = '....6',
d = '6....';
var o ={
0:[a,b,b,b,a],
1:[c,c,c,c,c],
2:[a,c,a,d,a],
3:[a,c,a,c,a],
4:[b,b,a,c,c],
5:[a,d,a,c,a],
6:[a,d,a,b,a],
7:[a,c,c,c,c],
8:[a,b,a,b,a],
9:[a,b,a,c,a]
}
var n = readline();
n = parseInt(n);
var s = [];
for(var i = 0;i<n;i++){
s[i] = readline();
}
for(var i = 0;i<n;i++){
s[i] = eval(s[i]);
s[i] = s[i].toString().split('');
}
for(var i = 0;i<n;i++){
for(var j = 0;j<5;j++){
var temp = '';
for(var k = 0;k<s[i].length-1;k++){
temp += o[s[i][k]][j]+'..';
}
temp += o[s[i][k]][j];
print(temp);
}
}