#include <bits/stdc++.h>
using namespace std;
int vals[105][105];
int n;
int cnt[105];
int p[105];
int k[105];
int mid(int p, int k, int id) {
  int m = (p + k) / 2;
  if ((k - p) % 2)
    if (id == 1) m++;
  return m;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &cnt[i]);
    for (int j = 1; j <= cnt[i]; j++) scanf("%d", &vals[i][j]);
    p[i] = 1;
    k[i] = cnt[i];
  }
  int sp, sd;
  sp = sd = 0;
  int ok = 1;
  int it = 1;
  while (ok) {
    int mxid, mx;
    mx = -1000;
    for (int i = 1; i <= n; i++)
      if (p[i] <= k[i]) {
        int m = mid(p[i], k[i], it);
        if (vals[i][m] > mx) {
          mx = vals[i][m];
          mxid = i;
        }
      }
    if (it == 1) {
      sp += vals[mxid][p[mxid]];
      p[mxid]++;
    } else {
      sd += vals[mxid][k[mxid]];
      k[mxid]--;
    }
    ok = 0;
    for (int i = 1; i <= n; i++)
      if (p[i] <= k[i]) ok = 1;
    it ^= 1;
  }
  printf("%d %d\n", sp, sd);
}
