
	int N{};
	map<string, int> con;

	cin >> N;
	for(int i = 0; i < N; ++i)
	{
		string S;
		cin >> S;

		auto it = con.find(S);
		if(it != con.end())
		{
			*it++;
		}
		else
		{
			con[S] = 1;
		}
	}

	for(auto const& i : con)
	{
		cout << i.first << " x " << i.second << "\n";
	}