#include <iostream>
struct Elev {
double h;
char name[256];
} a[100];
int n, sol[100], used[100];
void display() {
for(int i = 1; i <= n; ++i) printf("%s ", a[sol[i]].name);
printf("\n");
}
void bk(int k) {
if(k>n) display();
else
for(int i = 1; i <= n; ++i) {
if(!used[i]) {
if( (k == 1) || (k >1 && a[i].h >= a[ sol[k-1] ].h)) {
sol[k] = i;
used[i] = 1;
bk(k+1);
used[i] = 0; }
}
}
}
int main() {
double x;
char name[256];
n = 3;
std::cout<<"elevi=";
std::cin>>n;
for(int i = 1; i <= n; ++i) scanf("%s %lf", a[i].name, &a[i].h);
bk(1);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgpzdHJ1Y3QgRWxldiB7CiAgIGRvdWJsZSBoOwogICBjaGFyIG5hbWVbMjU2XTsKfSBhWzEwMF07CmludCBuLCBzb2xbMTAwXSwgdXNlZFsxMDBdOwoKdm9pZCBkaXNwbGF5KCkgewogIGZvcihpbnQgaSA9IDE7IGkgPD0gbjsgKytpKSBwcmludGYoIiVzICIsIGFbc29sW2ldXS5uYW1lKTsKICBwcmludGYoIlxuIik7Cn0Kdm9pZCBiayhpbnQgaykgewogICAgaWYoaz5uKSBkaXNwbGF5KCk7CiAgICBlbHNlCiAgICBmb3IoaW50IGkgPSAxOyBpIDw9IG47ICsraSkgewogICAgICAgIGlmKCF1c2VkW2ldKSB7CiAgICAgICAgICBpZiggKGsgPT0gMSkgfHwgKGsgPjEgJiYgYVtpXS5oID49IGFbIHNvbFtrLTFdIF0uaCkpIHsKICAgICAgICAgIHNvbFtrXSA9IGk7CiAgICAgICAgICB1c2VkW2ldID0gMTsKICAgICAgICAgIGJrKGsrMSk7CiAgICAgICAgICB1c2VkW2ldID0gMDsgfQogICAgICAgIH0KICAgIH0KfQppbnQgbWFpbigpIHsKICBkb3VibGUgeDsKICBjaGFyIG5hbWVbMjU2XTsKICBuID0gMzsKICBzdGQ6OmNvdXQ8PCJlbGV2aT0iOwogIHN0ZDo6Y2luPj5uOwogIGZvcihpbnQgaSA9IDE7IGkgPD0gbjsgKytpKSBzY2FuZigiJXMgJWxmIiwgYVtpXS5uYW1lLCAmYVtpXS5oKTsKCiAgYmsoMSk7Cn0K