import java.io.*;
import java.util.*;
public class Main
{
public Main() throws IOException
{
BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
int N = Integer.parseInt(f.readLine());
StringTokenizer st = null;
int T = 0;
boolean[] drop = new boolean[N + 1];
for (int i = 1; i <= N; i++)
{
st = new StringTokenizer(f.readLine());
int m = Integer.parseInt(st.nextToken());
int apples = 0;
for (int j = 1; j <= m; j++)
{
int a = Integer.parseInt(st.nextToken());
if (a <= 0)
{
apples += a;
}
else
{
if (apples > a)
{
drop[i] = true;
}
apples = a;
}
}
T += apples;
}
int D = 0, E = 0;
for (int i = 1; i <= N; i++)
{
if (drop[i]) {
D++;
}
if (drop[i % N + 1] && drop[(i + 1) % N + 1] && drop[(i + 2) % N + 1]) {
E++;
}
}
out.println(T + " " + D + " " + E);
out.close();
f.close();
}
public static void main(String[] args) throws IOException {
new Main();
}
}