#include <bits/stdc++.h>
using namespace std;
const int maxx = 120;
int l[maxx], r[maxx], s1 = 0, s2 = 0, maj[maxx][maxx];
vector<int> v;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    for (int j = 0; j < x; j++) {
      int y;
      cin >> y;
      if (j == x / 2 && x % 2 == 1) v.push_back(y);
      if (j < (x / 2)) s1 += y;
      if (x % 2 == 1 && j > (x / 2)) s2 += y;
      if (x % 2 == 0 && j >= (x / 2)) s2 += y;
    }
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  for (int i = 0; i < v.size(); i++)
    if (i % 2)
      s2 += v[i];
    else
      s1 += v[i];
  cout << s1 << " " << s2 << endl;
  return 0;
}
