#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s, lp;
  cin >> n;
  int a[n][102], b[n], d[n];
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    for (int j = 0; j < b[i]; j++) {
      cin >> a[i][j];
      sum += a[i][j];
    }
  }
  int fox = 0, k = 0;
  for (int i = 0; i < n; i++) {
    if (b[i] % 2 == 0) {
      for (int j = 0; j < b[i] / 2; j++) {
        fox += a[i][j];
      }
    } else {
      for (int j = 0; j < b[i] / 2; j++) {
        fox += a[i][j];
      }
      d[k++] = a[i][b[i] / 2];
    }
  }
  sort(d, d + k);
  for (int i = k - 1; i >= 0; i -= 2) {
    fox += d[i];
  }
  cout << fox << " " << sum - fox;
  return 0;
}
