#include <iostream>
using namespace std;
int main(){
freopen("input.txt","r",stdin);
int T;
for (T = 0; T < 10; T++){
int A[10][10];
int i,j;
int max[10]= {0};
for (i = 0; i < 10; i++)
for (j = 0; j < 10; j++)
cin>>A[i][j];
for (i = 8; i >=0; i--){
for (j = 0; j < 9; j++){
int k = i;
if (A[k][j] == 1 && A[k][j+1] == 1)
while (k < 9 && A[k+1][j] == 0 && A[k+1][j+1] == 0){
A[k][j] = 0;
A[k][j+1] = 0;
A[k+1][j] = 1;
A[k+1][j+1] = 1;
k++;
}
}
for (j = 0; j < 10; j++){
int k = i;
if (A[k][j] == 1 && A[k+1][j] == 1)
while (k < 8 && A[k+2][j] == 0){
A[k][j] = 0;
A[k+2][j] = 1;
k++;
}
}
}
for (i = 0; i < 10; i++){
for (j = 0; j < 10; j++)
if (A[j][i] == 1){
max[i]= 10 - j;
break;
}
}
cout<<"#"<<T+1<<" ";
for (i = 0; i < 10; i++)
cout<<max[i]<<" ";
cout <<endl;
}
return 0;
}
/*
0 0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0 0 1
0 0 0 0 0 0 1 0 0 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0
1 0 0 0 1 0 0 0 0 0
1 0 0 0 0 0 1 1 0 0
0 0 0 1 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 1 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 1 1 0 0 0 1 1 0
0 1 0 0 0 0 0 0 0 0
0 1 0 1 1 0 0 0 0 0
0 0 0 0 0 0 1 1 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 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