#include <bits/stdc++.h>
using namespace std;
int sum[2];
int can[111];
int cann;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int dn;
    scanf("%d", &dn);
    int x;
    for (int j = 0; j < dn; j++) {
      scanf("%d", &x);
      if (j < dn / 2) {
        sum[0] += x;
      } else if (j > dn / 2) {
        sum[1] += x;
      } else {
        if (dn % 2 == 0) {
          sum[1] += x;
        } else {
          can[cann] = x;
          cann++;
        }
      }
    }
  }
  sort(can, can + cann);
  for (int i = cann - 1, in = 0; i >= 0; i--, in = 1 - in) {
    sum[in] += can[i];
  }
  printf("%d %d\n", sum[0], sum[1]);
  return 0;
}
