#include <bits/stdc++.h>
using namespace std;
int a[105];
int b[105];
bool cmp(int a, int b) { return a > b; }
int main() {
  int n, x = 0, y = 0, m;
  int cnt = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &m);
    for (int j = 1; j <= m; j++) {
      scanf("%d", &a[j]);
    }
    if (m & 1) {
      for (int j = 1; j <= m / 2; j++) {
        x += a[j];
      }
      b[cnt++] = a[m / 2 + 1];
      for (int j = m / 2 + 2; j <= m; j++) {
        y += a[j];
      }
    } else {
      for (int j = 1; j <= m / 2; j++) {
        x += a[j];
      }
      for (int j = m / 2 + 1; j <= m; j++) {
        y += a[j];
      }
    }
  }
  sort(b, b + cnt, cmp);
  for (int i = 0; i < cnt; i++) {
    if (i & 1)
      y += b[i];
    else
      x += b[i];
  }
  printf("%d %d", x, y);
  return 0;
}
