#include <bits/stdc++.h>
using namespace std;
vector<int> middle;
int N, size;
int L[1 << 10];
int main() {
  scanf("%d", &N);
  int first = 0, second = 0;
  for (int i = 0; (i) < (int)(N); (i)++) {
    scanf("%d", &size);
    for (int j = 0; (j) < (int)(size); (j)++) scanf("%d", &L[j]);
    for (int j = 0; j < size / 2; j++) first += L[j];
    for (int j = (size + 1) / 2; j < size; j++) second += L[j];
    if (size % 2 == 1) middle.push_back(L[size / 2]);
  }
  sort(middle.rbegin(), middle.rend());
  for (int i = 0; (i) < (int)(middle.size()); (i)++)
    if (i % 2 == 0)
      first += middle[i];
    else
      second += middle[i];
  printf("%d %d\n", first, second);
  return 0;
}
