#include <iostream>
#include <bits/stdc++.h>
#include <string>
using namespace std;
typedef struct
{
int end;
bool isDrop;
}Tree;
vector<Tree> tree;
int main()
{
int n,m;
cin>>n;
while(n--)
{
cin>>m;
Tree temp;
temp.isDrop=false;
for(int i=0;i<m;i++)
{
int tempp;
cin>>tempp;
if(i==0)
{
// temp.base=tempp;
temp.end=tempp;
continue;
}
if(tempp<=0)
{
//temp.subtract.push_back(tempp);
temp.end+=tempp;
}
else
{
if(temp.end!=tempp)
{
temp.isDrop=true;
temp.end=tempp;
}
}
}
tree.push_back(temp);
}
int t=0,d=0,e=0;
for(int i=0;i<tree.size();i++)
{
t+=tree[i].end;
if(tree[i].isDrop)
d++;
if(i==0&&tree[0].isDrop&&tree[1].isDrop&&tree[tree.size()-1].isDrop)
e++;
else if((i==tree.size()-1)&&tree[0].isDrop&&tree[tree.size()-2].isDrop&&tree[tree.size()-1].isDrop)
e++;
else
{
if(tree[i-1].isDrop&&tree[i].isDrop&&tree[i+1].isDrop)
e++;
}
}
cout<<t<<" "<<d<<" "<<e<<endl;
}
/*
4
4 74 -7 -12 -5
5 73 -8 -6 59 -4
5 76 -5 -10 60 -2
5 80 -6 -15 59 0
*/