#include <bits/stdc++.h>
using namespace std;
;
template <class C>
void mini(C& a4, C b4) {
  a4 = min(a4, b4);
}
template <class C>
void maxi(C& a4, C b4) {
  a4 = max(a4, b4);
}
template <class T1, class T2>
ostream& operator<<(ostream& out, pair<T1, T2> pair) {
  return out << "(" << pair.first << ", " << pair.second << ")";
};
int main() {
  ios_base::sync_with_stdio();
  cout << fixed << setprecision(10);
  int lsum = 0, rsum = 0;
  vector<int> middle;
  int n;
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) {
    int k;
    scanf("%d", &k);
    for (int j = 0; j < (k); ++j) {
      int x;
      scanf("%d", &x);
      if (j < k / 2) lsum += x;
      if (j * 2 + 1 == k) middle.push_back(x);
      if (j >= (k + 1) / 2) rsum += x;
    }
  }
  sort((middle).begin(), (middle).end());
  reverse((middle).begin(), (middle).end());
  for (int i = 0; i < (((int)(middle).size())); ++i) {
    if (i & 1)
      rsum += middle[i];
    else
      lsum += middle[i];
  }
  printf("%d %d\n", lsum, rsum);
  return 0;
}
