#include <bits/stdc++.h>
using namespace std;
inline void file() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  if (0) {
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
  }
}
inline void read(int& n) {
  char h;
  n = 0;
  for (h = getchar(); h < '0' || h > '9'; h = getchar())
    ;
  for (; h >= '0' && h <= '9'; h = getchar()) n = n * 10 + h - '0';
}
const clock_t MAXT = (100 * CLOCKS_PER_SEC) / 1000;
const int PX[8] = {1, 0, -1, 0, 1, 1, -1, -1},
          PY[8] = {0, 1, 0, -1, -1, 1, 1, -1}, N = 3e5 + 10, INF = 1e9,
          MOD = 1e9 + 7;
const long long INFL = 1e18, MODL = 1e9 + 7;
const long double EPS = 1e-6;
inline int rnd(int l = 0, int r = INF) {
  unsigned ans = rand();
  ans = (ans << 8) ^ rand();
  ans = (ans << 8) ^ rand();
  ans = (ans << 8) ^ rand();
  ans %= r - l + 1;
  ans += l;
  return ans;
}
int n, m, x, sum_a, sum_b;
vector<int> kek;
int main() {
  file();
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> m;
    int pos = (m + 1) / 2;
    for (int j = 1; j <= m; ++j) {
      cin >> x;
      if ((m & 1)) {
        if (j < pos) sum_a += x;
        if (j > pos) sum_b += x;
        if (j == pos) kek.push_back(x);
      } else {
        if (j <= pos)
          sum_a += x;
        else
          sum_b += x;
      }
    }
  }
  sort(kek.begin(), kek.end());
  reverse(kek.begin(), kek.end());
  for (int i = 0; i < kek.size(); ++i) {
    if (i & 1)
      sum_b += kek[i];
    else
      sum_a += kek[i];
  }
  cout << sum_a << ' ' << sum_b << '\n';
}
