#include <bits/stdc++.h>
using namespace std;
vector<long long> v[105];
int main() {
  long long n;
  cin >> n;
  for (long long i = (long long)1; i <= (long long)n; i++) {
    long long s;
    cin >> s;
    for (long long j = (long long)1; j <= (long long)s; j++) {
      long long c;
      cin >> c;
      v[i].push_back(c);
    }
  }
  long long a = 0, b = 0;
  vector<long long> grab;
  for (long long i = (long long)1; i <= (long long)n; i++) {
    if (v[i].size() % 2) {
      for (long long j = (long long)0; j <= (long long)(v[i].size() / 2) - 1;
           j++)
        a += v[i][j];
      for (long long j = (long long)(v[i].size() / 2) + 1;
           j <= (long long)v[i].size() - 1; j++)
        b += v[i][j];
      grab.push_back(v[i][v[i].size() / 2]);
    } else {
      for (long long j = (long long)0; j <= (long long)(v[i].size() / 2) - 1;
           j++)
        a += v[i][j];
      for (long long j = (long long)(v[i].size() / 2);
           j <= (long long)v[i].size() - 1; j++)
        b += v[i][j];
    }
  }
  sort(grab.rbegin(), grab.rend());
  for (long long i = (long long)0; i <= (long long)grab.size() - 1; i++) {
    if (i & 1)
      b += grab[i];
    else
      a += grab[i];
  }
  cout << a << ' ' << b;
}
