#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> qq(n + 1, 0);
vector<vector<int>> q(n);
int total_apples = 0, drop_count = 0, group_count = 0;
vector<bool> dropped(n, false);
for (int i = 0; i < n; i++) {
int a;
cin >> a;
q[i].resize(a);
for (int j = 0; j < a; j++) {
cin >> q[i][j];
if (j == 0) {
qq[i] = q[i][j];
} else {
if (q[i][j] > 0) {
if (q[i][j] < qq[i]) {
dropped[i] = true;
}
qq[i] = q[i][j];
} else {
qq[i] += q[i][j];
}
}
}
total_apples += qq[i];
}
for (int i = 0; i < n; i++) {
if (dropped[i]) {
drop_count++;
}
}
for (int i = 0; i < n; i++) {
if (dropped[i] && dropped[(i + 1) % n] && dropped[(i + 2) % n]) {
group_count++;
}
}
cout << total_apples << " " << drop_count << " " << group_count << endl;
return 0;
}
-