#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wwrite-strings"
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &out, const pair<T, U> &A) {
  out << A.first << "_" << A.second;
  return out;
}
template <template <typename, typename> class ContainerT, typename ValueT>
ostream &operator<<(ostream &out,
                    const ContainerT<ValueT, std::allocator<ValueT> > &A) {
  for (__typeof((A).begin()) i = (A).begin(); i != (A).end(); ++i)
    out << *i << " ";
  return out;
}
template <template <typename, typename> class ContainerT, typename ValueT,
          typename ValueU>
ostream &operator<<(
    ostream &out, const ContainerT<pair<ValueT, ValueU>,
                                   std::allocator<pair<ValueT, ValueU> > > &A) {
  for (__typeof((A).begin()) i = (A).begin(); i != (A).end(); ++i)
    out << *i << " ";
  return out;
}
template <class T>
void mini(T &a, const T &b) {
  if (b < a) a = b;
}
template <class T>
void maxi(T &a, const T &b) {
  if (b > a) a = b;
}
int N;
deque<int> sum;
long long solve() {
  cin >> N;
  sum.clear();
  vector<vector<int> > A(N);
  vector<vector<int> > AS(N);
  sum.push_back(0);
  for (int i = 0; i < (N); ++i) {
    int s;
    cin >> s;
    sum.push_back(sum.back() + s);
    A[i] = vector<int>(s);
    for (int j = 0; j < (s); ++j) cin >> A[i][j];
    AS[i] = vector<int>(1);
    for (int j = 0; j < (s); ++j) AS[i].push_back(AS[i].back() + A[i][j]);
  }
  sum.pop_front();
  int SSS = 0;
  for (int i = 0; i < (N); ++i)
    for (__typeof((A[i]).begin()) j = (A[i]).begin(); j != (A[i]).end(); ++j)
      SSS += *j;
  long long ans = 0;
  vector<int> div;
  for (int i = 0; i < (N); ++i)
    if (A[i].size() % 2 == 0)
      ans += AS[i][A[i].size() / 2];
    else {
      ans += AS[i][A[i].size() / 2];
      div.push_back(A[i][A[i].size() / 2]);
    }
  sort((div).begin(), (div).end(), greater<int>());
  for (int i = 0; i < (div.size()); ++i)
    if (i % 2 == 0) ans += div[i];
  cout << ans << " " << SSS - ans << endl;
  return 0;
}
long long solve_() {
  cin >> N;
  sum.clear();
  vector<vector<int> > A(N);
  vector<vector<int> > AS(N);
  sum.push_back(0);
  for (int i = 0; i < (N); ++i) {
    int s;
    cin >> s;
    sum.push_back(sum.back() + s);
    A[i] = vector<int>(s);
    for (int j = 0; j < (s); ++j) cin >> A[i][j];
    AS[i] = vector<int>(1);
    for (int j = 0; j < (s); ++j) AS[i].push_back(AS[i].back() + A[i][j]);
  }
  sum.pop_front();
  int SSS = 0;
  for (int i = 0; i < (N); ++i)
    for (__typeof((A[i]).begin()) j = (A[i]).begin(); j != (A[i]).end(); ++j)
      SSS += *j;
  int curS = 0;
  int S = sum.back();
  vector<int> D(S + 1, -1);
  D[0] = 0;
  for (int i = 0; i < (N); ++i) {
    curS += sum[i];
    vector<int> newD(D);
    for (int j = 0; j < (S + 1); ++j) {
      if (D[j] == -1) break;
      for (int k = (j + 1); k <= (min(j + sum[i], S)); ++k) {
        if (k > (curS + 1) / 2) break;
        if (k < (curS - 1) / 2) continue;
        if (k - j > (A[i].size() + 1) / 2) break;
        maxi(newD[k], D[j] + AS[i][k - j]);
      }
    }
    D = newD;
    cout << "D"
         << ": " << D << endl;
  }
  int max = D[(S + 1) / 2];
  cout << max << " " << SSS - max << endl;
  return 0;
}
int main() {
  solve();
  return 0;
}
