#include <bits/stdc++.h>
using namespace std;
int n, x;
int s[105];
int ciel, jiro;
vector<int> mid;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (n); i++) {
    scanf("%d", &s[i]);
    for (int j = 0; j < (s[i]); j++) {
      scanf("%d", &x);
      if ((2 * j + 1) == s[i])
        mid.push_back(x);
      else if (j < s[i] / 2)
        ciel += x;
      else
        jiro += x;
    }
  }
  sort(mid.rbegin(), mid.rend());
  for (int i = 0; i < (mid.size()); i++)
    if (i & 1)
      jiro += mid[i];
    else
      ciel += mid[i];
  printf("%d %d\n", ciel, jiro);
  return 0;
}
