#include <bits/stdc++.h>
using namespace std;
int w[110], inx = 0;
int main() {
  int sum = 0, s = 0, n, a, b, i, j;
  cin >> n;
  for (i = 0; i < n; i++) {
    scanf("%d", &a);
    for (j = 1; j <= a; j++) {
      scanf("%d", &b);
      sum += b;
      if (j * 2 <= a) s += b;
      if (j * 2 == a + 1) w[inx++] += b;
    }
  }
  sort(w, w + inx);
  for (i = inx - 1; i >= 0; i -= 2) s += w[i];
  cout << s << " " << sum - s << endl;
  return 0;
}
