#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
#include <sstream>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;

struct Less{
   bool operator()(const pair<string, int>&a, const pair<string, int>&b){
        if(a.first==b.first){
            return a.second < b.second;
        }
       return a.first < b.first;
    }
};
int GCD(int a, int b){
    if(b==0) return a;
    return GCD(b, a%b);
}

int main() {
    vector<pair<string, int> > vp;
    string s; int n;
    while(cin >> s >> n){
        vp.push_back({s, n});
    }
    
    sort(vp.begin(), vp.end(), Less());
    vp.push_back({"BANPEI", 1});
    string ss=vp[0].first;
    cout << ss << endl;
    for(int i=1; i<vp.size(); ++i){
        if(vp[i].first==ss){
            cout << vp[i-1].second << " ";
        }else{
            cout << vp[i-1].second << endl;
            if(i==vp.size()-1) break;
            ss = vp[i].first;
            cout << ss << endl;
        }
    }
	return 0;
}
