#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int f[101][11];
  for (int i = 1; i < n + 1; i++) {
    int b = 0;
    for (int j = 1; j < 11; j++) {
      int c;
      cin >> c;
      if (c == 1) {
        b++;
      }
      f[i][j] = c;
    }
    if (b == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  int p[101][11];
  for (int i = 1; i < n + 1; i++) {
    for (int j = 0; j < 11; j++) {
      int a;
      cin >> a;
      p[i][j] = a;
    }
  }
  int ans = 0;
  for (int i = 1; i < 11; i++) {
    int x = 0;
    for (int j = 1; j < n + 1; j++) {
      if (f[i][j] == 1) {
        x++;
      }
    }
    ans += p[i][x];
  }
  cout << ans << endl;
  return 0;
}
