#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
string s;
int n;

int enc(char c) {
	if (c >= 'a' && c <= 'z') {
		return (int)(c - 'a');
	}
	if (c >= 'A' && c <= 'Z') {
		return 26 + (int)(c - 'A');
	}
	return 52 + (int)(c - '0');
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int nc; cin >> nc;
	for (int cs = 1; cs <= nc; cs++) {
		int k; cin >> k;
		cin >> s;
		n = s.length();
		int m = 1;
		int counter = 0;
		bool seen[k];
		ll nums[k];
		ll numsnext[k];
		ll sum = 0;
		ll sumnext = 0;
		memset(seen, 0, sizeof seen);
		memset(nums, 0, sizeof nums);
		for (int i = 0; i < n; i++) {
			int c = enc(s[i]);
			if (!seen[c]) {
				seen[c] = true;
				counter++;
				if (m == 1) {
					sum = k - counter;
					numsnext[c] = sum + 1;
					sumnext += numsnext[c];
				} else {
					numsnext[c] = sum;
					sumnext = (sumnext + sum) % mod;
					sum = (sum - nums[c] + mod) % mod;
				}
				if (counter == k) {
					memset(seen, 0, sizeof seen);
					counter = 0;
					m++;
					sum = sumnext;
					sumnext = 0;
					for (int j = 0; j < k; j++) {
						nums[j] = numsnext[j];
					}
				}
			} else {
				sumnext = (sumnext - numsnext[c] + sum + mod) % mod;
				numsnext[c] = sum;
			}
			//cerr << m << " " << s[i] << " " << nums[c] << " " << numsnext[c] << " " << sum << endl;
		}
		//cerr << "Answer: " << endl;
		cout << m << " " << sum << endl;
	}
}