#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main() {
  int ciel = 0, jiro = 0, i, j, s[105], n, m;
  scanf("%d", &n);
  s[0] = 0;
  while (n--) {
    scanf("%d", &m);
    for (i = 1; i <= m; ++i) {
      scanf("%d", &j);
      s[i] = s[i - 1] + j;
    }
    ciel += s[m >> 1];
    jiro += s[m] - s[(m + 1) >> 1];
    if (m & 1) v.push_back(-s[(m >> 1) + 1] + s[m >> 1]);
  }
  sort(v.begin(), v.end());
  for (i = 0; i < v.size(); ++i)
    if (i & 1)
      jiro -= v[i];
    else
      ciel -= v[i];
  printf("%d %d", ciel, jiro);
}
