#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, i, j, k, t, id, x, v, ans, nn, r, total;
  cin >> n;
  vector<vector<int>> a(n);
  ans = 0;
  total = 0;
  vector<int> qq;
  for (i = 0; i < n; i++) {
    cin >> r;
    a[i].resize(r);
    for (j = 0; j < r; j++) {
      cin >> a[i][j];
      total += a[i][j];
      if (j < r / 2) ans += a[i][j];
      if ((j == r / 2) && (r % 2 == 1)) qq.push_back(a[i][j]);
    }
  }
  sort(qq.rbegin(), qq.rend());
  for (i = 0; i < qq.size(); i += 2) ans += qq[i];
  cout << ans << " " << total - ans << "\n";
  return 0;
}
