#include <bits/stdc++.h>
using namespace std;
vector<int> djw[105];
int c[105];
int main() {
  int n, m, x;
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) djw[i].clear();
    for (int i = 0; i < n; i++) {
      scanf("%d", &m);
      for (int j = 0; j < m; j++) {
        scanf("%d", &x);
        djw[i].push_back(x);
      }
    }
    int a = 0, b = 0, t = 0, j;
    for (int i = 0; i < n; i++) {
      if ((djw[i].size() & 1) == 0) {
        for (j = 0; j < djw[i].size() / 2; j++) a += djw[i][j];
        for (; j < djw[i].size(); j++) b += djw[i][j];
      } else {
        for (j = 0; j < djw[i].size() / 2; j++) a += djw[i][j];
        c[t++] = djw[i][j++];
        for (; j < djw[i].size(); j++) b += djw[i][j];
      }
    }
    sort(c, c + t);
    int flag = 0;
    for (int i = t - 1; i >= 0; i--) {
      if (!flag) {
        a += c[i];
        flag = 1;
      } else {
        b += c[i];
        flag = 0;
      }
    }
    printf("%d %d\n", a, b);
  }
  return 0;
}
