#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <cstring>

using namespace std;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

int c[10];

int main(){
	int n;
	
	while (cin >> n, n){
		REP(i,10) c[i] = 0;
		
		REP(i,n){
			int a;
			
			scanf("%d", &a);
			
			c[a]++;
		}
		
		REP(i,10){
			if (c[i] == 0) printf("-\n");
			else {
				REP(j,c[i]) printf("*");
				puts("");
			}
		}
	}
	
	return 0;
}
#include <iostream>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <vector>
#include <map>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

long long n, bg, tn, su;
	
	while(cin >> n){
		if(n==0 || cin.eof()) break;
		map<int,long long> sk;
		vector<int> jun;
		rep(i,n){
			cin >> bg >> tn >> su;
			if(sk[bg]==0) jun.push_back(bg);
			sk[bg] += tn * su;
		}
		int cnt=0;
		rep(i,jun.size()){
			if(sk[jun[i]] >= 1000000){
				cout << jun[i] << endl;
				cnt++;
			}
		}	
		if(cnt==0) cout << "NA" << endl;
	}
	return 0;
	
}