#include <bits/stdc++.h>
using namespace std;
int e[101];
int v[101][11];
int m[101];
int main() {
  int N;
  cin >> N;
  int temp = 0, maxV = -1000000, ans;
  for (int i = 0; i < N; i++) {
    for (int j = 1; j <= 10; j++) {
      cin >> temp;
      if (temp == 1) e[i]++;
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> temp;
      v[i][j] = temp;
    }
  }
  for (int i = 0; i < N; i++) {
    maxV = 0;
    for (int j = 0; j <= e[i]; j++) {
      maxV = max(maxV, v[i][j]);
    }
    m[i] = maxV;
  }
  for (int i = 0; i < N; i++) {
    ans += m[i];
  }
  cout << ans << endl;
  return 0;
}
