#include <bits/stdc++.h>
using namespace std;
int no[1000001], a[1001][1001];
vector<int> temp;
int main() {
  int i, j, n, sum = 0, sum1 = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> no[i];
    for (j = 1; j <= no[i]; j++) {
      cin >> a[i][j];
      sum += a[i][j];
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= no[i] / 2; j++) sum1 += a[i][j];
    if (no[i] % 2) temp.push_back(a[i][no[i] / 2 + 1]);
  }
  sort(temp.begin(), temp.end());
  reverse(temp.begin(), temp.end());
  for (i = 0; i < temp.size(); i += 2) sum1 += temp[i];
  cout << sum1 << " " << sum - sum1;
  return 0;
}
