#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, m;
cin >> n >> m;
int a[1005][1005] = {};
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
cin >> a[i][j];
if (a[i][j] == 1)
{
a[0][j]++;
a[i][0]++;
}
}
}
cout << a[m][0] << " " << a[0][m] << " " << a[m][0] + a[0][m];
return 0;
}