#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, F = 0, sum = 0, x, lim, s, y;
  scanf("%d", &n);
  vector<int> V;
  for (int i = 0; i < n; i++) {
    scanf("%d", &m);
    lim = m / 2;
    s = y = 0;
    for (int j = 0; j < m; j++) {
      scanf("%d", &x);
      sum += x;
      if (j < lim) s += x;
      if (j == lim) y = x;
    }
    if (m & 1) V.push_back(y);
    F += s;
  }
  sort((V.rbegin()), (V.rend()));
  for (int i = 0; i < ((int)V.size()); i += 2) {
    F += V[i];
  }
  printf("%d %d\n", F, sum - F);
  return 0;
}
