#include <bits/stdc++.h>
using namespace std;
const int N = 1e2 + 100;
vector<int> a[N];
void addup(int v[], vector<int> &xs) {
  for (int i = 0, p = 0; i < xs.size(); ++i) {
    if (i == xs.size() / 2) ++p;
    v[p] += xs[i];
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int sz;
    cin >> sz;
    for (int j = 0; j < sz; ++j) {
      int x;
      cin >> x;
      a[i].push_back(x);
    }
  }
  int v[] = {0, 0};
  for (int i = 0; i < n; ++i) {
    if (a[i].size() & 1) continue;
    addup(v, a[i]);
  }
  vector<int> mids;
  for (int i = 0; i < n; ++i) {
    if (not(a[i].size() & 1)) continue;
    int midp = a[i].size() / 2;
    mids.push_back(a[i][midp]);
    swap(a[i][midp], a[i][a[i].size() - 1]);
    a[i].pop_back();
    addup(v, a[i]);
  }
  sort(mids.begin(), mids.end());
  reverse(mids.begin(), mids.end());
  for (int i = 0, p = 0; i < mids.size(); ++i) {
    v[p] += mids[i];
    p = 1 - p;
  }
  cout << v[0] << ' ' << v[1] << '\n';
}
