#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a[105];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int sz;
    cin >> sz;
    for (int j = 0; j < sz; j++) {
      int x;
      cin >> x;
      a[i].push_back(x);
    }
  }
  int ans1 = 0, ans2 = 0;
  vector<int> v;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < a[i].size() / 2; j++) {
      ans1 += a[i][j];
    }
    for (int j = (a[i].size() + 1) / 2; j < a[i].size(); j++) {
      ans2 += a[i][j];
    }
    if (a[i].size() % 2) {
      v.push_back(a[i][a[i].size() / 2]);
    }
  }
  sort(v.begin(), v.end(), greater<int>());
  for (int i = 0; i < v.size(); i++) {
    if (i % 2) {
      ans2 += v[i];
    } else {
      ans1 += v[i];
    }
  }
  cout << ans1 << " " << ans2 << "\n";
  return 0;
}
