>>679
#include <iostream>
#include <fstream>
#include <map>
#include <string>
int main()
{
 std::string filename;
 std::map <int,int> intmap;
 while(1)
 {
  std::cin >> filename;
  if(std::cin.fail())
   break;
  std::ifstream fin(filename.c_str());
  std::map<int, int> intmap;
  for(;;)
  {
   int val;
   fin >> val;
   if(fin.fail())
    break;
   intmap[val]++;
  }
 }
 std::ofstream fout("out.txt");
 for(std::map<int, int>::iterator it=intmap.begin(); it!=intmap.end(); ++it)
 {
  fout << (*it).first << " " << (*it).second << std::endl;
 }
 return 0;
}