#include <bits/stdc++.h>
using namespace std;
int flag[11];
int c[101];
int n;
void add_flag() {
  int carry = 1;
  for (int i = 1; i <= 10; i++) {
    if (flag[i] == 0 && carry == 1) {
      flag[i] = 1;
      return;
    } else {
      flag[i] = 0;
    }
  }
}
bool check() {
  for (int i = 1; i <= 10; i++) {
    if (flag[i] == 0) {
      return false;
    }
  }
  return true;
}
void clear_c() {
  for (int i = 1; i <= n; i++) {
    c[i] = 0;
  }
}
int main() {
  cin >> n;
  int f[n + 1][11];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 10; j++) {
      scanf("%d", &f[i][j]);
    }
  }
  int p[n + 1][11];
  for (int i = 1; i <= n; i++) {
    c[i] = 0;
    for (int j = 0; j < 11; j++) {
      scanf("%d", &p[i][j]);
    }
  }
  long long res = 0;
  while (!check()) {
    add_flag();
    clear_c();
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= 10; j++) {
        if (f[i][j] == 1 && flag[j] == 1) {
          ++c[i];
        }
      }
    }
    long long temp_res = 0;
    for (int i = 1; i <= n; i++) {
      temp_res += (long long)(p[i][c[i]]);
    }
    if (temp_res > res) {
      res = temp_res;
    }
  }
  cout << res << endl;
  return 0;
}
