#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 10;
int n;
int a[maxn], stk[maxn], cnt;
int A, B;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int k;
    scanf("%d", &k);
    for (int j = 1; j <= k; j++) scanf("%d", &a[j]);
    for (int j = 1; j <= k / 2; j++) A += a[j];
    for (int j = (k + 1) / 2 + 1; j <= k; j++) B += a[j];
    if (k & 1) stk[++cnt] = a[(k + 1) / 2];
  }
  sort(stk + 1, stk + 1 + cnt);
  reverse(stk + 1, stk + 1 + cnt);
  for (int i = 1; i <= n; i++)
    if (i & 1)
      A += stk[i];
    else
      B += stk[i];
  printf("%d %d\n", A, B);
}
