#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int i, k, n, x, t;
  string s, r;
  cin >> t;
  while (t--) {
    cin >> x >> s;
    n = s.length();
    for (i = 0; i < x; i++) {
      cout << n << " ";
      r = s.substr(i + 1);
      n = (n + ((n - i - 1) * (s[i] - '0' - 1)) % 1000000007) % 1000000007;
      if ((long long int)(s.length()) < x) {
        k = s[i] - '0' - 1;
        while (k--) s.append(r);
      }
    }
    cout << n << '\n';
  }
  return 0;
}
