#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

const int MAX = 30;
int dp[MAX + 1];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	dp[0] = 1;
	for (int i = 0; i <= MAX - 1; i++) {
		for (int j = 1; j <= 3; j++) {
			if (i + j <= MAX)
				dp[i + j] += dp[i];
		}
	}

	int n;
	while (cin >> n , n) {
		cout << ((dp[n] + 9) / 10 + 364) / 365 << endl;
	}
}
#include<iostream>
using namespace std;

int main()
{
    int n;
    long long int e[4000], p[4000], q[4000], sum[4000];
    bool ej[4000];

    while( cin >> n )
    {
        if( n == 0 )
            break;

        for( int i = 0; i < 4000; i++ )
        {
            sum[i] = 0;
            ej[i] = false;
        }

        for( int i = 0; i < n; i++ )
        {
            cin >> e[i] >> p[i] >> q[i];
            sum[e[i]] += p[i] * q[i];
        }
        
        bool judge = false;
        for( int i = 0; i < n; i++ )
        {
            if( sum[e[i]] >= 1000000 && ej[e[i]] == false )
            {
                cout << e[i] << endl;
                judge = true;
                ej[e[i]] = true;
            }
        }
        if( judge == false )
            cout << "NA" << endl;
    }
    return 0;
}
