#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  scanf("%d", &N);
  int time[100][10] = {};
  int P[100][10] = {};
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      int f;
      scanf("%d", &f);
      if (f) {
        time[i][j] = 1;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      int f;
      scanf("%d", &f);
      time[i][j] *= f;
    }
  }
  long long total = 0;
  for (int time = 0; time < 10; time++) {
    int maxP = 1;
    int flag = 1;
    for (int i = 0; i < N; i++) {
      if (maxP < P[i][time]) {
        maxP = P[i][time];
      }
      if (P[i][time] >= 0) {
        total += P[i][time];
        flag = 0;
      }
    }
    if (flag) {
      total += maxP;
    }
  }
  cout << total << endl;
  return 0;
}
