#include<stdio.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
const int MAX = 9999;
using namespace std;
int main()
{
int n, m;
cin >> n;
int tree[n];
int isfall[n];
memset(tree, 0, sizeof(tree));
memset(isfall, 0, sizeof(isfall));
for (int i = 0; i < n; i++)
{
cin >> m;
cin >> tree[i];
for (int j = 0; j < m - 1; j++)
{
int temp;
cin >> temp;
if (temp > 0)
{
if (tree[i] - temp != 0)
{
isfall[i] = 1;
tree[i] = temp;
}
}
else {
tree[i] += temp;
}
}
}
int sum = 0;
int fallcount = 0;
for (int i = 0; i < n; i++)
{
if (isfall[i] == 1)
{
fallcount++;
}
sum += tree[i];
}
int threefall=0;
for (int i = 0; i < n-2; i++)
{
if (isfall[i]==1&& isfall[i+1] == 1&& isfall[i+2] == 1)
{
threefall++;
}
}
if (isfall[n-2]==1 && isfall[n - 1] == 1&& isfall[0] == 1)
threefall++;
if (isfall[1] == 1 && isfall[n - 1] == 1 && isfall[0] == 1)
threefall++;
cout << sum << " " << fallcount << " "<< threefall;
return 0;
}