// page 483 of Bjarne
// page 431 tells where the includes are
// these are the necessary includes for using strings and the map container.
#include <string>
#include <map>

// Have to define this because g+ std library doesn't define a default
// less-than comparator.
typedef less<string> string_less;

// This typedef is just for convenience.
typedef map<string,int,string_less> inventory;

// This typedef is necessary to use iterators
typedef inventory::iterator Itor;

void readitems(inventory& m)
{ 
  string word;
  int val=0;

  while(cin >> word >> val)
    m[word] += val;
}

void main()
{
  inventory table;
  Itor p;

  readitems(table);
  int total=0;

  for (p = table.begin(); p!=table.end(); p++) {
    // g++ stdlib does not overload the -> operator
    total += (*p).second;  
    cout << (*p).first << '\t' << (*p).second << endl;
  }

  cout << "---------------\ntotal:\t" << total << endl;
}

