#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, l[110], r[110], a[110][110];
  while (scanf("%d", &n) != EOF) {
    int sum = 0;
    for (int i = 1; i <= n; i++) {
      l[i] = 1;
      scanf("%d", &r[i]);
      for (int j = 1; j <= r[i]; j++) scanf("%d", &a[i][j]);
      sum += r[i];
    }
    int ans1 = 0, ans2 = 0;
    for (int i = 1; i <= sum; i++) {
      int tmp = -2, maxt = -1, pi, m = -1, pir;
      if (i % 2 == 1) {
        for (int j = 1; j <= n; j++)
          if (l[j] <= r[j]) {
            if (r[j] - l[j] > 1 && (r[j] - l[j] + 1) % 2 == 1)
              tmp = a[j][(r[j] + l[j]) / 2];
            if (l[j] == r[j]) tmp = a[j][l[j]];
            if (m < a[j][l[j]]) {
              m = a[j][l[j]];
              pir = j;
            }
            if (tmp > maxt) {
              maxt = tmp;
              pi = j;
            }
          }
        if (maxt == -1) pi = pir;
        ans1 += a[pi][l[pi]];
        l[pi]++;
      } else {
        for (int j = 1; j <= n; j++)
          if (l[j] <= r[j]) {
            if (r[j] - l[j] > 1 && (r[j] - l[j] + 1) % 2 == 1)
              tmp = a[j][(r[j] + l[j]) / 2];
            if (l[j] == r[j]) tmp = a[j][r[j]];
            if (m < a[j][r[j]]) {
              m = a[j][r[j]];
              pir = j;
            }
            if (tmp > maxt) {
              maxt = tmp;
              pi = j;
            }
          }
        if (maxt == -1) pi = pir;
        ans2 += a[pi][r[pi]];
        r[pi]--;
      }
    }
    printf("%d %d\n", ans1, ans2);
  }
  return 0;
}
