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

map<int, int, less<int> > baka;

int main() {
  int aho, doji;

  while(scanf("%d,%d", &aho, &doji) != EOF) {
    baka[aho] ++;
  }
  
  for(map<int, int>::iterator it = baka.begin(); it!=baka.end(); it++) {
    if(it->second<=1) continue;
    cout << it->first << " " << it->second << endl;
  }
  
  return 0;
}