#include <bits/stdc++.h>
using namespace std;
const int MAXN = (long long)1e2;
const int INF = (long long)1e9;
const int MOD = (long long)1e9 + 7;
const int CHR = 97;
int arr[MAXN];
vector<int> mid;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, pile_end, Jiro = 0, Ceil = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> m;
    pile_end = m - 1;
    for (int j = 0; j < m; j++) cin >> arr[j];
    if (m % 2) mid.push_back(arr[m / 2]);
    for (int j = 0; j < pile_end; j++)
      Ceil += arr[j], Jiro += arr[pile_end], pile_end--;
  }
  sort(mid.begin(), mid.end());
  reverse(mid.begin(), mid.end());
  for (int i = 0; i < mid.size(); i++)
    if (i % 2)
      Jiro += mid[i];
    else
      Ceil += mid[i];
  cout << Ceil << " " << Jiro << "\n";
}
