#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	vector<pair<string, pair<ll, string> > > hoge;
	vector<pair<string, pair<ll, string> > > a(8);
	vector<pair<string, pair<ll, string> > > b(8);
	vector<pair<string, pair<ll, string> > > c(8);
	REP(i, 8) {
		int p;
		string t;
		cin>>p>>t;
		string tn;
		a[i].second.first = p;
		a[i].second.second = t;
		REP(i, t.size()) {
			if(t[i] == '.') {
				t.erase(t.begin() + i);
			}
		}
		tn = t;
		a[i].first = tn;
	}
	sort(ALL(a));
	cout<<a[0].second.first<<" "<<a[0].second.second<<endl;
	cout<<a[1].second.first<<" "<<a[1].second.second<<endl;
	REP(i, 8) {
		int p;
		string t;
		cin>>p>>t;
		string tn;
		b[i].second.first = p;
		b[i].second.second = t;
		REP(i, t.size()) {
			if(t[i] == '.') {
				t.erase(t.begin() + i);
			}
		}
		tn = t;
		b[i].first = tn;
	}
	sort(ALL(b));
	cout<<b[0].second.first<<" "<<b[0].second.second<<endl;
	cout<<b[1].second.first<<" "<<b[1].second.second<<endl;
	REP(i, 8) {
		int p;
		string t;
		cin>>p>>t;
		string tn;
		c[i].second.first = p;
		c[i].second.second = t;
		REP(i, t.size()) {
			if(t[i] == '.') {
				t.erase(t.begin() + i);
			}
		}
		tn = t;
		c[i].first = tn;
	}
	sort(ALL(c));
	cout<<c[0].second.first<<" "<<c[0].second.second<<endl;
	cout<<c[1].second.first<<" "<<c[1].second.second<<endl;
	REP(i, 6) {
		hoge.pb(a[2 + i]);
	}
	REP(i, 6) {
		hoge.pb(b[2 + i]);
	}
	REP(i, 6) {
		hoge.pb(c[2 + i]);
	}
	sort(ALL(hoge));
	cout<<hoge[0].second.first<<" "<<hoge[0].second.second<<endl;
	cout<<hoge[1].second.first<<" "<<hoge[1].second.second<<endl;
}