#include <bits/stdc++.h>   using namespace std;   const int mx = 1123;   int limit[26];   const long long mod = 1e9 + 7;   int n;   string s;   struct Node {     int maxstr, minpart;     long long ways;     Node(int maxstr, int minpart, long long ways)         : maxstr(maxstr), minpart(minpart), ways(ways){};     Node() {       ways = -1;       minpart = 1e9;     }   };   Node dp[mx];   Node ways(int on = 0) {     if (on == n) {       return {0, 0, 1};     }     Node &ans = dp[on];     if (ans.ways == -1) {       ans.ways = 0;       int maxsz = 1e9;       for (int i = on; i < n; i++) {         maxsz = min(maxsz, limit[s[i] -  a ]);         if (i - on + 1 <= maxsz) {           auto r = ways(i + 1);           ans.ways += r.ways;           ans.minpart = (i != n - 1) + min(ans.minpart, r.minpart);           ans.maxstr = max(ans.maxstr, max(i - on + 1, r.maxstr));         }       }     }     ans.ways = (ans.ways) % mod;     return ans;   }   int main() {     cin >> n;     cin >> s;     for (int i = 0; i < 26; i++) {       cin >> limit[i];     }     auto ans = ways();     cout << ans.ways << endl;     cout << ans.maxstr << endl;     cout << ans.minpart + 1 << endl;   }   