#include <bits/stdc++.h>
int cmp(const void* a, const void* b) { return *(int*)b - *(int*)a; }
int main() {
  int i, j, n, m, s[111], x, k = 0;
  int sum = 0, sum1 = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &m);
    for (j = 1; j < m + 1; j++) {
      scanf("%d", &x);
      sum += x;
      if (j * 2 < m + 1) sum1 += x;
      if (j * 2 == m + 1) s[k++] = x;
    }
  }
  qsort(s, k, sizeof(int), cmp);
  for (i = 0; i < k; i += 2) sum1 += s[i];
  printf("%d %d\n", sum1, sum - sum1);
  return 0;
}
