#include <bits/stdc++.h>
using namespace std;
int a[105][105];
int k[105];
int main() {
  int n;
  scanf("%d", &n);
  int zuo = 0;
  int you = 0;
  int r = 0;
  for (int i = 0; i < n; i++) {
    int p;
    scanf("%d", &p);
    for (int j = 0; j < p; j++) scanf("%d", &a[i][j]);
    if (p % 2 == 0) {
      int u;
      for (u = 0; u < p / 2; u++) zuo += a[i][u];
      for (; u < p; u++) you += a[i][u];
    } else {
      int u;
      for (u = 0; u < p / 2; u++) zuo += a[i][u];
      k[r++] = a[i][u++];
      for (; u < p; u++) you += a[i][u];
    }
  }
  sort(k, k + r);
  for (int i = r - 1; i >= 0; i--) {
    int j = r - 1 - i;
    if (j % 2 == 0)
      zuo += k[i];
    else
      you += k[i];
  }
  printf("%d %d\n", zuo, you);
}
