#include <bits/stdc++.h>
using namespace std;
int n, s, jum, x;
int ar[105], ki[105], ka[105], gan[105], tem[105], tot[105];
int main() {
  memset(ar, 0, sizeof(ar));
  memset(ki, 0, sizeof(ki));
  memset(ka, 0, sizeof(ka));
  memset(gan, 0, sizeof(gan));
  memset(tem, 0, sizeof(tem));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &s);
    jum = 0;
    for (int j = 1; j <= s; j++) {
      scanf("%d", &x);
      jum += x;
      if (j <= s / 2) ki[i] += x;
      if (j > (s + 1) / 2) ka[i] += x;
      if (s % 2 != 0)
        if (j == (s + 1) / 2) gan[i] = x;
    }
    tot[i] = s;
    ar[i] = jum;
  }
  vector<pair<int, int> > v;
  vector<pair<int, int> > v2;
  for (int i = 1; i <= n; i++)
    if (gan[i] == 0)
      v.push_back(make_pair(ar[i], i));
    else {
      v2.push_back(make_pair(gan[i], i));
    }
  int ciel, jiro;
  ciel = jiro = 0;
  for (int i = 0; i < v.size(); i++) {
    ciel += ki[v[i].second];
    jiro += ka[v[i].second];
  }
  sort(v2.begin(), v2.end());
  reverse(v2.begin(), v2.end());
  int mark = 1;
  for (int i = 0; i < v2.size(); i++) {
    ciel += ki[v2[i].second];
    jiro += ka[v2[i].second];
    if (mark == 1) {
      ciel += v2[i].first;
      mark = 0;
    } else {
      jiro += v2[i].first;
      mark = 1;
    }
  }
  printf("%d %d\n", ciel, jiro);
  return 0;
}
