#include <cstdio>
#include <vector>
#include <map>
using namespace std;
const int maxn = 1001;
int n;
int main(){
vector<int> apple(maxn, 0);
map<int, int> mp; //掉果子的树
int m, temp;
scanf("%d", &n);
for (int i = 1; i <= n; i++){
scanf("%d", &m);
scanf("%d", &apple[i]);
for (int j = 0; j < m - 1; j++){
scanf("%d", &temp);
if (temp > 0){
if (apple[i] > temp){ //掉果子了
mp.insert(make_pair(i, 1));
apple[i] = temp;
}
}else{
apple[i] += temp;
}
}
}
long long sum = 0;
for (int i = 1; i <= n; i++){
sum += apple[i];
}
int total = mp.size();
int count = 0;
for (int i = 1; i <= n; i++){
// int j = i + 1; 写法太难看了
// int k = i + 2;
// if (j == n + 1 ) j = 1;
// if (k == n + 1 ) k = 1;
// if (j == n + 2 ) j = 2;
// if (k == n + 2 ) k = 2;
//0->0 1->1 ...n-1->n-1 n->0 n+1->1 可以用取余 i%n
//1->1 2->2 ... n->n n+1->1 n+2->2 可以用条件表达式
//格式 ? : 注意第一个是?
if (mp[i] && mp[(i + 1) > n ? i + 1 - n : i + 1] && mp[(i + 2) > n ? i + 2 - n : i + 2]){
count++;
}
}
printf("%lld %d %d\n", sum, total, count);
return 0;
}