/*MH RIYAD
mriyad94@gmail.com
*/
#include <cstdio>
#include<iostream>
#include<cmath>
#include<map>
#include<cstring>
#define fr freopen("in.txt","r",stdin);
#define fw freopen("out.txt","w",stdout);
using namespace std;
struct A
{
int l;
int h;
string str;
};
A H[10001];
int main()
{
// fr fw
int test,da,q,price;
scanf("%d", &test);
for (int j = 1; j <= test;j++)
{
scanf("%d", &da);
for (int i = 0; i < da; i++) cin >> H[i].str >> H[i].l >> H[i].h;
scanf("%d", &q);
while (q--)
{
scanf("%d", &price);
string res;
int c = 0;
for (int i = 0; i < da; i++)
{
if (price >= H[i].l && price <= H[i].h)
{
res = H[i].str;
c++;
}
}
if (c == 0 || c>1) cout << "UNDETERMINED" << endl;
else cout << res << endl;
}
if(j!=test)cout<<endl;
}
return 0;
}
mriyad94@gmail.com
*/
#include <cstdio>
#include<iostream>
#include<cmath>
#include<map>
#include<cstring>
#define fr freopen("in.txt","r",stdin);
#define fw freopen("out.txt","w",stdout);
using namespace std;
struct A
{
int l;
int h;
string str;
};
A H[10001];
int main()
{
// fr fw
int test,da,q,price;
scanf("%d", &test);
for (int j = 1; j <= test;j++)
{
scanf("%d", &da);
for (int i = 0; i < da; i++) cin >> H[i].str >> H[i].l >> H[i].h;
scanf("%d", &q);
while (q--)
{
scanf("%d", &price);
string res;
int c = 0;
for (int i = 0; i < da; i++)
{
if (price >= H[i].l && price <= H[i].h)
{
res = H[i].str;
c++;
}
}
if (c == 0 || c>1) cout << "UNDETERMINED" << endl;
else cout << res << endl;
}
if(j!=test)cout<<endl;
}
return 0;
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন