#include <bits/stdc++.h>
using namespace std;
int arr[101][1005];
vector<int> v;
bool myfunction(int i, int j) { return (i > j); }
int main() {
  int n;
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    int t;
    std::cin >> t;
    arr[i][0] = t;
    for (int j = 1; j <= t; j++) {
      std::cin >> arr[i][j];
    }
  }
  int ceil_sum = 0;
  int jiro_sum = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i][0] % 2 == 0) {
      int mid = arr[i][0] / 2;
      for (int j = 1; j <= mid; j++) {
        ceil_sum = ceil_sum + arr[i][j];
      }
      for (int j = mid + 1; j <= arr[i][0]; j++) {
        jiro_sum = jiro_sum + arr[i][j];
      }
    } else {
      int mid = (arr[i][0] + 1) / 2;
      for (int j = 1; j < mid; j++) {
        ceil_sum = ceil_sum + arr[i][j];
      }
      for (int j = mid + 1; j <= arr[i][0]; j++) {
        jiro_sum = jiro_sum + arr[i][j];
      }
      v.push_back(arr[i][mid]);
    }
  }
  sort(v.begin(), v.begin() + v.size(), myfunction);
  for (int i = 0; i < v.size(); i = i + 2) {
    ceil_sum = ceil_sum + v[i];
  }
  for (int i = 1; i < v.size(); i = i + 2) {
    jiro_sum = jiro_sum + v[i];
  }
  std::cout << ceil_sum << " " << jiro_sum << endl;
  return 0;
}
