#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:36777216")
using namespace std;
int n, sz[111], a[111], sum1, sum2;
vector<int> vec;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &sz[i]);
    for (int j = 1; j <= sz[i]; j++) scanf("%d", &a[j]);
    if (sz[i] % 2 == 1) {
      vec.push_back(a[sz[i] / 2 + 1]);
    }
    for (int j = 1; j <= sz[i] / 2; j++) sum1 += a[j];
    int st;
    if (sz[i] % 2 == 0)
      st = sz[i] / 2 + 1;
    else
      st = sz[i] / 2 + 2;
    for (int j = st; j <= sz[i]; j++) sum2 += a[j];
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  for (int i = 0; i < vec.size(); i++) {
    if (i % 2 == 0)
      sum1 += vec[i];
    else
      sum2 += vec[i];
  }
  printf("%d %d\n", sum1, sum2);
}
