#include <bits/stdc++.h>
using namespace std;
template <typename T>
T Abs(T first) {
  return (first < 0 ? -first : first);
}
template <typename T>
T Sqr(T first) {
  return (first * first);
}
string plural(string s) {
  return (int((s).size()) && s[int((s).size()) - 1] == 'x' ? s + "en"
                                                           : s + "s");
}
const int INF = (int)1e9;
const double EPS = 1e-9;
const long double PI = acos(-1.0);
bool Read(int &first) {
  char c, r = 0, n = 0;
  first = 0;
  for (;;) {
    c = getchar();
    if ((c < 0) && (!r)) return (0);
    if ((c == '-') && (!r))
      n = 1;
    else if ((c >= '0') && (c <= '9'))
      first = first * 10 + c - '0', r = 1;
    else if (r)
      break;
  }
  if (n) first = -first;
  return (1);
}
int main() {
  if (0) freopen("in.txt", "r", stdin);
  int N;
  int i, j, v, mi, mv;
  int ans1 = 0, ans2 = 0;
  int M[100], L[100], R[100];
  static int V[100][100];
  Read(N);
  for (i = 0; i < N; i++) {
    Read(M[i]);
    L[i] = 0;
    R[i] = M[i] - 1;
    for (j = 0; j < M[i]; j++) Read(V[i][j]);
  }
  for (;;) {
    mv = -1;
    for (i = 0; i < N; i++)
      if (L[i] <= R[i]) {
        if ((R[i] - L[i] + 1) % 2 == 0)
          v = 0;
        else
          v = V[i][(L[i] + R[i]) / 2];
        if (v > mv) mv = v, mi = i;
      }
    if (mv < 0) break;
    ans1 += V[mi][L[mi]++];
    mv = -1;
    for (i = 0; i < N; i++)
      if (L[i] <= R[i]) {
        if ((R[i] - L[i] + 1) % 2 == 0)
          v = 0;
        else
          v = V[i][(L[i] + R[i]) / 2];
        if (v > mv) mv = v, mi = i;
      }
    if (mv < 0) break;
    ans2 += V[mi][R[mi]--];
  }
  printf("%d %d\n", ans1, ans2);
  return (0);
}
