#include <bits/stdc++.h>
using namespace std;
int n, a[110][110];
int num[110];
int used[110];
int s[110];
bool cmp(int a, int b) { return a > b; }
int main() {
  while (scanf("%d", &n) != EOF) {
    int sum = 0;
    for (int i = 0; i < n; ++i) {
      scanf("%d", &num[i]);
      for (int j = 0; j < num[i]; ++j) {
        scanf("%d", &a[i][j]);
      }
    }
    int ans = 0, ans2 = 0;
    memset(s, 0, sizeof(s));
    for (int i = 0; i < n; ++i) {
      int p = num[i];
      if (p % 2 == 0) {
        for (int j = 0; j < p / 2; ++j) ans += a[i][j];
        for (int j = p / 2; j < p; ++j) ans2 += a[i][j];
      } else {
        for (int j = 0; j < p / 2; ++j) ans += a[i][j];
        for (int j = p / 2 + 1; j < p; ++j) ans2 += a[i][j];
        s[i] = a[i][p / 2];
      }
    }
    sort(s, s + n, cmp);
    for (int i = 0; i < n; ++i) {
      if (i % 2 == 0)
        ans += s[i];
      else
        ans2 += s[i];
    }
    printf("%d %d\n", ans, ans2);
  }
}
