#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int a = 0, b = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    for (int j = 0; j < x; j++) {
      int aa;
      cin >> aa;
      if (x % 2 == 1 and j == x / 2)
        v.push_back(aa);
      else if (j < x / 2)
        a += aa;
      else
        b += aa;
    }
  }
  sort((v).begin(), (v).end());
  int at = 0;
  for (int i = v.size() - 1; i >= 0; i--) {
    if (!at)
      a += v[i];
    else
      b += v[i];
    at = (1 - at);
  }
  cout << a << " " << b << endl;
  return 0;
}
