#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int NEGATIVE_INF = -INF;
const int MAXN = 1010;
bool cmp(const int &a, const int &b) { return a > b; }
int n, s_size[105], s[105][105];
int dp[105][105];
int for_sort[105], fop = 0;
int sum = 0;
int ans1 = 0;
int main() {
  ios_base::sync_with_stdio(false);
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s_size[i];
    for (int j = 1; j <= s_size[i]; j++) {
      cin >> s[i][j];
      sum += s[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= s_size[i] / 2; j++) ans1 += s[i][j];
    if (s_size[i] % 2 != 0) for_sort[fop++] = s[i][(s_size[i] + 1) / 2];
  }
  sort(for_sort, for_sort + fop, cmp);
  for (int i = 0; i < fop; i += 2) ans1 += for_sort[i];
  cout << ans1 << " " << sum - ans1 << endl;
  return 0;
}
