#include <bits/stdc++.h>
using namespace std;
int cmp(int A, int B) { return A > B; }
int m[101];
int main() {
  int N, n[101], mid, left = 0, right = 0, M[101][1001], k = 0;
  scanf("%d", &N);
  for (int j = 1; j <= N; j++) {
    scanf("%d", &n[j]);
    mid = n[j] / 2;
    for (int i = 1; i <= n[j]; i++) {
      scanf("%d", &M[j][i]);
      if (i <= mid)
        left += M[j][i];
      else
        right += M[j][i];
    }
  }
  for (int i = 1; i <= N; i++) {
    if (n[i] % 2) {
      m[k] = M[i][n[i] / 2 + 1];
      right -= m[k];
      k++;
    }
  }
  sort(m, m + k, cmp);
  for (int i = 0; i < k; i++) {
    if (i % 2 == 1)
      right += m[i];
    else
      left += m[i];
  }
  printf("%d %d\n", left, right);
  return 0;
}
