#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int F[N][10];
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 10; ++j) {
      cin >> F[i][j];
    }
  }
  int P[N][11];
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 11; ++j) {
      cin >> P[i][j];
    }
  }
  int ans = 0, cnt = 0, tmp = -1000;
  for (int i = 0; i < N; ++i) {
    for (int j = 1; j < 11; ++j) {
      tmp = max(tmp, P[i][j]);
    }
    ans += tmp;
    tmp = -1000;
  }
  cout << ans << endl;
  return 0;
}
