#include <bits/stdc++.h>
using namespace std;
const int INF = 100000000;
inline void solve(void) {
  int n;
  cin >> n;
  int s, x;
  vector<int> V;
  int c_score = 0, j_score = 0;
  int off;
  for (int i = (0); i < (n); i++) {
    cin >> s;
    for (int i = (0); i < (s / 2); i++) cin >> x, c_score += x;
    off = 0;
    if (s % 2 == 1) cin >> x, V.push_back(0 - x), off = 1;
    for (int i = (s / 2 + off); i < (s); i++) cin >> x, j_score += x;
  }
  sort(V.begin(), V.end());
  for (int i = (0); i < (V.size()); i++) {
    if (i & 1)
      j_score += 0 - V[i];
    else
      c_score += 0 - V[i];
  }
  cout << c_score << " " << j_score;
}
int main(int argc, const char* argv[]) {
  ios_base::sync_with_stdio(false);
  solve();
  return 0;
}
