#include <bits/stdc++.h>
using namespace std;
const int N = 60;
int a[N];
string b[N];
int main(){
int n;
cin>>n;
for(int i = 0;i < n; i++){
cin>>a[i]>>b[i];
// cout<<a[i]<<' '<<b[i]<<endl;
}
for(int i=0,j;i<n/2;i++){
j = n - 1;
while(a[j] == -1){
j--;
}
while(a[j]!=-1){
if(a[i] + a[j] == 1){
cout<<b[i]<<' '<<b[j]<<endl;
a[j]=-1;
break;
}
j--;
}
}
return 0;
}
改正后的代码while(a[j]!=-1)改为while(a[j]!=-1||a[n/2]!=-1)即可通过