#include <bits/stdc++.h>
int a[105][105], n;
int b[105];
bool vis[105];
using namespace std;
struct node {
  int v, i;
  bool operator<(const node b) const {
    if (this->v == b.v) return this->i < b.i;
    return this->v > b.v;
  };
};
set<node> q;
int main() {
  scanf("%d", &n);
  int sum = 0;
  int sum2 = 0;
  int ans1 = 0, ans2 = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
    for (int j = 1; j <= b[i]; j++) {
      scanf("%d", &a[i][j]);
      if (j == b[i] / 2 + 1 && b[i] % 2 == 1) {
        node tmp;
        tmp.v = a[i][j];
        tmp.i = i;
        q.insert(tmp);
      }
      if (j != 1) {
        a[i][j] += a[i][j - 1];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (b[i] % 2 == 0) {
      ans1 += a[i][b[i] / 2];
      ans2 += a[i][b[i]] - a[i][b[i] / 2];
    } else {
      ans1 += a[i][b[i] / 2];
      ans2 += a[i][b[i]] - a[i][b[i] / 2 + 1];
    }
  }
  set<node>::const_iterator pos;
  int i;
  for (pos = q.begin(), i = 0; pos != q.end(); pos++, i++) {
    if (i % 2 == 0) {
      ans1 += pos->v;
    } else {
      ans2 += pos->v;
    }
  }
  printf("%d %d", ans1, ans2);
}
