#include <bits/stdc++.h>
using namespace std;
int a[105];
int main() {
  vector<int> ve;
  int t;
  scanf("%d", &t);
  int x = 0, y = 0;
  while (t--) {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    for (int i = 0; i < n / 2; i++) x += a[i];
    for (int i = n - 1; i >= (n + 1) / 2; i--) y += a[i];
    if (n % 2) ve.push_back(a[n / 2]);
  }
  sort(ve.begin(), ve.end(), [](int x, int y) { return x > y; });
  for (int i = 0; i < (int)ve.size(); i += 2) x += ve[i];
  for (int i = 1; i < (int)ve.size(); i += 2) y += ve[i];
  printf("%d %d\n", x, y);
  return 0;
}
