#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t, n, m, k, q, x, a, b, c, d, w;
  cin >> n;
  string s;
  cin >> s;
  vector<long long int> ans(n + 1, 0), mx(n, 1), F(26);
  ans[n] = 1;
  for (int i = 0; i < 26; i++) {
    cin >> F[i];
  }
  if (n == 1) {
    cout << "1\n1\n1\n";
  } else {
    for (int i = n - 1; i >= 0; i--) {
      vector<bool> T(26);
      T[s[i] - 'a'] = true;
      for (int j = i + 1; j <= n; j++) {
        if (j == n) {
          ans[i] += ans[j];
          ans[i] %= mod;
          break;
        }
        T[s[j] - 'a'] = true;
        bool cond = false;
        for (int k = 0; k < 26; k++) {
          if (j - i + 1 > F[k] && T[k]) {
            cond = true;
            break;
          }
        }
        if (cond) {
          ans[i] += ans[j];
          ans[i] %= mod;
          break;
        } else {
          ans[i] += ans[j];
          mx[i] = j - i + 1;
          ans[i] %= mod;
        }
      }
    }
    m = 0;
    for (int i = 0; i < n; m++) {
      i += mx[i];
    }
    cout << ans[0] << "\n"
         << *max_element(mx.begin(), mx.end()) << "\n"
         << m << "\n";
  }
  return 0;
}
