#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> f(n, 0);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 10; j++) {
      int tmp;
      cin >> tmp;
      if (tmp == 1) f[i] += (1 << j);
    }
  vector<vector<int> > p(n, vector<int>(10));
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= 10; j++) cin >> p[i][j];
  long long ans = -1000000000009;
  for (int i = 1; i < (1 << 10); i++) {
    long long tmpans = 0;
    for (int j = 0; j < n; j++) {
      int tmp = (i & f[j]);
      int count = 0;
      for (int k = 0; k <= 10; k++)
        if ((tmp & (1 << k)) != 0) count++;
      tmpans += p[j][count];
    }
    if (ans < tmpans) {
      for (int j = 0; j < n; j++) {
        int tmp = (i & f[j]);
        int count = 0;
        for (int k = 0; k <= 10; k++)
          if ((tmp & (1 << k)) != 0) count++;
      }
      ans = tmpans;
    }
  }
  cout << ans << endl;
}
