#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int i, j, k;
  int ag[101], a[101][101];
  int g = 0, dr[101], dl[101];
  for (i = 1; i <= n; i++) {
    scanf("%d", &ag[i]);
    g += ag[i];
    dl[i] = 1;
    dr[i] = ag[i];
    for (j = 1; j <= ag[i]; j++) scanf("%d", &a[i][j]);
  }
  int m[10001], mg = 0;
  int s1 = 0, s2 = 0;
  for (i = 1; i <= n; i++) {
    if (ag[i] % 2 == 1) {
      m[mg] = a[i][(ag[i] + 1) / 2];
      mg++;
    }
    for (j = 1; j <= ag[i]; j++) {
      if (j <= ag[i] / 2) s1 += a[i][j];
      if (j > (ag[i] + 1) / 2) s2 += a[i][j];
    }
  }
  sort(m, m + mg);
  for (i = mg - 1; i >= 0; i--) {
    if ((mg - i) % 2 == 1)
      s1 += m[i];
    else
      s2 += m[i];
  }
  printf("%d %d", s1, s2);
  return 0;
}
