#include<iostream>
#include<string>
using namespace std;
string strall;
int n,k;
char t = '0';
int main() {
cin >> strall;
n = strall.length();
for (int i = 1; i < n; i++) {
string strtemp;
cin >> strtemp;
strall = strall + strtemp;
}
int num[100000] = {};
for (int j = 0; j < n * n; j++) {
if (strall[j] == t) {
num[k]++;
}
else {
num[k + 1]++;
k++;
if (t == '0')t = '1';
else t = '0';
}
}
cout << n<<" ";
for (int j = 0; j < n*n; j++) {
if (num[j] != 0) {
cout << num[j]<<" ";
}
}
}