#include <bits/stdc++.h>
using namespace std;
bool bomp(int n, int m) { return n > m; }
int main() {
  int n;
  int sumJ = 0, sumR = 0;
  int ans[200], h = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    int mid = x / 2;
    int midn;
    for (int j = 0; j < x; j++) {
      int k;
      cin >> k;
      if (j == mid) midn = k;
      if (j < mid)
        sumJ += k;
      else
        sumR += k;
    }
    if (x & 1) {
      sumR -= midn;
      ans[h++] = midn;
    }
  }
  sort(ans, ans + h, bomp);
  for (int j = 0; j < h; j++)
    if (j & 1)
      sumR += ans[j];
    else
      sumJ += ans[j];
  cout << sumJ << " " << sumR << endl;
  return 0;
}
