#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX 300000

int n, pm, pe, pj;

int main() {
	while (1) {
		scanf("%d", &n);
		if (n == 0)
			return 0;

		while(n-- > 0) {
			scanf("%d %d %d", &pm, &pe, &pj);
			if(max(pm, max(pe, pj)) == 100 || pm + pe >= 180 || pm + pe + pj >= 240)
				puts("A");
			else if(pm + pe + pj >= 210 || pm + pe + pj >= 150 && max(pm, pe) >= 80)
				puts("B");
			else
				puts("C");
		}
	}
}

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;


bool solve(){
	int n;
	cin>> n;
	if(!n) return false;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>> a[i];
	}
	string str;
	cin>> str;
	
	for(int i=0;i<str.size();i++){
		int k = a[i%n];
		k %= 52;
		char c = str[i];
		if(k>26){
			if(islower(c)){
				c = toupper(c);
			}else{
				c = tolower(c);
			}
			k -= 26;
		}
		if(islower(c)){
			if(islower(c-k)){
				c -= k;
			}else{
				k -= c - 'a';
				c = 'Z' - (k - 1);
			}
		}else if(isupper(c)){
			if(isupper(c-k)){
				c -= k;
			}else{
				k -= c - 'A';
				c = 'z' - (k - 1);
			}
		}
		cout<< c;
	}
	cout<< endl;

	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	while(solve()){}

	return 0;
}

 