#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
const int maxn=1e5;
void solve() {
int n=0,past=0,mark=0;
string s,str="";
while(1){
cin>>s;
if(cin.eof()){
break;
}
str+=s;
n++;
}
cout<<n<<" ";
for(int i=0;i<n*n;i++){
if(str[i]-'0'!=mark){
cout<<i-past<<" ";
past=i;
mark^=1;
}
}
cout<<n*n-past;
}
int main(){
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int T=1;
while(T--){
solve();
}
return 0;
}