17413
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;
map<string, int> m;
void solution(vector<string> v) {
for (int i = 0; i < v.size(); i++) {
int start = v[i].find('.') + 1;
string str = v[i].substr(start, v[i].length());
m[str]++;
}
for (auto str : m) {
cout << str.first << " " << str.second << endl;
}
}
int main() {
int n;
vector<string> v;
cin >> n;
cin.ignore();
for (int i = 0; i < n; i++) {
string input;
getline(cin, input);
v.push_back(input);
}
solution(v);
}