#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long LL; typedef unsigned long long ULL; const LL INF = 1e9+5; const int MAXN = 1e6+5; const int MOD = 1e9+7; const double eps = 1e-7; const double PI = acos(-1); struct Node { string name; int sc; }a[MAXN]; inline bool cmp(Node a, Node b){ if(a.name == b.name) return a.sc > b.sc; return a.name < b.name; } int main(){ int T; scanf("%d", &T); for (int cas=1; cas<=T; cas++){ int n; scanf("%d", &n); for (int i=0; i>a[i].name>>a[i].sc; if(n == 1){ cout<