#include <bits/stdc++.h>
using namespace std;
int N;
int main() {
  scanf("%d", &N);
  int ans1 = 0, ans2 = 0;
  vector<int> v;
  for (int i = 0; i < (int)N; i++) {
    int s;
    scanf("%d", &s);
    for (int j = 0; j < (int)s; j++) {
      int c;
      scanf("%d", &c);
      if (j * 2 + 1 == s) {
        v.push_back(c);
      } else {
        if (j < s / 2)
          ans1 += c;
        else
          ans2 += c;
      }
    }
  }
  sort(v.begin(), v.end(), greater<int>());
  for (int i = 0; i < (int)v.size(); i++) {
    if (i % 2)
      ans2 += v[i];
    else
      ans1 += v[i];
  }
  printf("%d %d\n", ans1, ans2);
}
