#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#include<iostream>
using namespace std;

vector<int> inputs;
map<int, int> one, two;
int main(){
    int x, n;
    while(~scanf("%d,%*d", &x)){
	inputs.push_back(x);
    }
    for(int i = 0;i < inputs.size();i++){
	if(i < inputs.size() / 2)one[inputs[i]]++;
	else two[inputs[i]]++;
    }
    map<int, int>::iterator it = one.begin();
    while(it != one.end()){
	if(two[it->first]){
	    cout << (it->first) << " " << (it->second) + two[it->first] << endl;
	}
	it++;
    }
    return inputs.size()%2;
}