#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<vector<bool>> shops(N, vector<bool>(N, false));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      bool dummy;
      cin >> dummy;
      shops[i][j] = dummy;
    }
  }
  vector<vector<int>> money(N, vector<int>(N, 0));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> money[i][j];
    }
  }
  int maxmoney = -999999999;
  for (int a = 0; a < 2; a++) {
    for (int b = 0; b < 2; b++) {
      for (int c = 0; c < 2; c++) {
        for (int d = 0; d < 2; d++) {
          for (int e = 0; e < 2; e++) {
            for (int f = 0; f < 2; f++) {
              for (int g = 0; g < 2; g++) {
                for (int h = 0; h < 2; h++) {
                  for (int i = 0; i < 2; i++) {
                    for (int j = 0; j < 2; j++) {
                      if (!a && !b && !c && !d && !e && !f && !g && !h && !i &&
                          !j) {
                        continue;
                      }
                      int thistimemoney = 0;
                      for (int k = 0; k < N; k++) {
                        int time = 0;
                        if (shops[k][0] && a) time++;
                        if (shops[k][1] && b) time++;
                        if (shops[k][2] && c) time++;
                        if (shops[k][3] && d) time++;
                        if (shops[k][4] && e) time++;
                        if (shops[k][5] && f) time++;
                        if (shops[k][6] && g) time++;
                        if (shops[k][7] && h) time++;
                        if (shops[k][8] && i) time++;
                        if (shops[k][9] && j) time++;
                        thistimemoney += money[k][time];
                      }
                      maxmoney = max(maxmoney, thistimemoney);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << maxmoney << endl;
}
