#include <bits/stdc++.h>
using namespace std;
long long cn1, cn2;
vector<int> v;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  cn1 = cn2 = 0;
  for (int i = 0; i < (n); i++) {
    int x;
    cin >> x;
    for (int j = 0; j < x; j++) {
      int y;
      cin >> y;
      if (x % 2 == 1 && j == x / 2)
        v.push_back(y);
      else if (j < x / 2)
        cn1 += y;
      else
        cn2 += y;
    }
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  for (int i = 0; i < (((int)v.size())); i++)
    if (i % 2 == 0)
      cn1 += v[i];
    else
      cn2 += v[i];
  cout << cn1 << " " << cn2 << endl;
  return 0;
}
