cpp
#include<iostream>
using namespace std;
int main(){
int n,m;
cin>>n;
int apple[n];
int drop[n];
for(int i=0;i<n;i++){
cin>>m>>apple[i];
drop[i]=0;
for (int j = 0; j < m-1; ++j) {
int temp;
cin>>temp;
if(temp<=0) apple[i]+=temp;
else {
if(temp!=apple[i]) {
drop[i]=1;
apple[i]=temp;
}
}
}
}
int sum=0,Applesum=0,dropsum=0;
for(int i=0;i<n;i++){
Applesum+=apple[i];
if(drop[i]==1) dropsum++;
int pre=i,mid=(i+1)%n,succ=(i+2)%n;
if(drop[pre]==1&&drop[mid]==1&&drop[succ]==1) {
sum++;
}
}
cout<<Applesum<<" "<<dropsum<<" "<<sum;
return 0;
}