#include <bits/stdc++.h>
using namespace std;
int vis[105][15];
int m[105][15];
int a[15];
int tmp[10];
int main() {
  int n;
  cin >> n;
  memset(tmp, 0, sizeof(0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> vis[i][j];
      if (vis[i][j]) tmp[i]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> m[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    ans += m[i][tmp[i]];
  }
  for (int i = 1; i < 1024; i++) {
    int num = i;
    int k = 9;
    while (k >= 0) {
      a[k--] = num % 2;
      num /= 2;
    }
    int tans = 0;
    for (int i = 0; i < n; i++) {
      int t = 0;
      for (int j = 0; j < 10; j++) {
        if (a[j] == 1 && vis[i][j] == 1) {
          t++;
        }
      }
      tans += m[i][t];
    }
    ans = max(ans, tans);
  }
  cout << ans << endl;
  return 0;
}
