#include<iostream>
#include<map>
#include<string>
using namespace std;

int main()
{
	int n, i;
	string s;
	map<string, int> m, m2;
	map<string, int>::iterator it;
	for (i = 0; i < 8; i++) {
		cin>>n>>s;
		m[s] = n;
		m2[s] = n;
	}
	it = m.begin();
	cout<<(*it).second<<" "<<(*it).first<<endl;
	m2.erase(m2.find((*it).first));
	it++;
	cout<<(*it).second<<" "<<(*it).first<<endl;
	m2.erase(m2.find((*it).first));
	m.clear();
	for (i = 8; i < 16; i++) {
		cin>>n>>s;
		m[s] = n;
		m2[s] = n;
	}
	it = m.begin();
	cout<<(*it).second<<" "<<(*it).first<<endl;
	m2.erase(m2.find((*it).first));
	it++;
	cout<<(*it).second<<" "<<(*it).first<<endl;
	m2.erase(m2.find((*it).first));
	m.clear();
	for (i = 16; i < 24; i++) {
		cin>>n>>s;
		m[s] = n;
		m2[s] = n;
	}
	it = m.begin();
	cout<<(*it).second<<" "<<(*it).first<<endl;
	m2.erase(m2.find((*it).first));
	it++;
	cout<<(*it).second<<" "<<(*it).first<<endl;
	m2.erase(m2.find((*it).first));
	it = m2.begin();
	cout<<(*it).second<<" "<<(*it).first<<endl;
	it++;
	cout<<(*it).second<<" "<<(*it).first<<endl;
	return 0;
}