#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long n, x, ans;
string s;
signed main() {
  long long T;
  scanf("%lld", &T);
  for (; T--;) {
    scanf("%lld", &x);
    cin >> s;
    n = s.length();
    ans = n;
    for (long long i = 0; i < x; i++) {
      n = s.length();
      if (n >= x) {
        ans = (ans + (s[i] - 49) * (ans - i - 1)) % mod;
        ans = (ans + mod) % mod;
      } else {
        if (s[i] == 50) {
          string tmp;
          tmp = s.substr(i + 1);
          s += tmp;
        }
        if (s[i] == 51) {
          string tmp;
          tmp = s.substr(i + 1);
          tmp += tmp;
          s += tmp;
        }
        ans = s.length();
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}
