#include <bits/stdc++.h>
using namespace std;
int N;
int c[100 + 10][100 + 10];
int s[100 + 10];
vector<int> Odd;
void _init() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &s[i]);
    for (int j = 1; j <= s[i]; ++j) {
      scanf("%d", &c[i][j]);
    }
  }
}
void _solve() {
  int Ciel = 0, Jiro = 0;
  for (int i = 1; i <= N; ++i) {
    if (s[i] & 1) {
      int mid = (s[i] + 1) >> 1;
      Odd.push_back(-c[i][mid]);
      for (int j = 1; j <= mid - 1; ++j) Ciel += c[i][j];
      for (int j = mid + 1; j <= s[i]; ++j) Jiro += c[i][j];
    } else {
      for (int j = 1; j <= (s[i] >> 1); ++j) Ciel += c[i][j];
      for (int j = (s[i] >> 1) + 1; j <= s[i]; ++j) Jiro += c[i][j];
    }
  }
  sort(Odd.begin(), Odd.end());
  int n = Odd.size();
  for (int i = 0; i <= n - 1; ++i) {
    if (!(i & 1))
      Ciel -= Odd[i];
    else
      Jiro -= Odd[i];
  }
  cout << Ciel << " " << Jiro << endl;
}
int main() {
  _init();
  _solve();
  return 0;
}
