#include <bits/stdc++.h>
bool cmp(int a, int b) { return a > b; }
int main() {
  int n, a = 0, b = 0, rec[110], num_rec = 0;
  scanf("%d", &n);
  for (int i = 1, num, buf[110]; i <= n; i++) {
    scanf("%d", &num);
    for (int j = 1; j <= num; j++) scanf("%d", &buf[j]);
    for (int j = 1; j <= (num >> 1); j++) a += buf[j];
    if (num & 1) {
      for (int j = (num >> 1) + 2; j <= num; j++) b += buf[j];
      rec[++num_rec] = buf[(num >> 1) + 1];
    } else
      for (int j = (num >> 1) + 1; j <= num; j++) b += buf[j];
  }
  std::sort(rec + 1, rec + num_rec + 1, cmp);
  for (int i = 1; i <= num_rec; i++)
    if (i & 1)
      a += rec[i];
    else
      b += rec[i];
  printf("%d %d\n", a, b);
  return 0;
}
