#include "iostream.h"
#include "fstream.h"
#include "string.h"

main(int argc, char *argv[])
{
  ifstream in(argv[1]);
  ofstream out(argv[2]);
  if (!in) {
    cout << "Cannot open input file.\n";
    return 1;
  }
  if (!out) {
    cout << "Cannot open output file.\n";
    return 1;
  }
  
  char temp[256];
  char ch;
  double b,d,e=0;
out<<0<<"    "<<0<<endl;
  do {
    //    in>>temp;
    in>>temp;
    if (strcmp(temp,argv[2])==0) {
      //      in>>temp;
      //      in>>temp;
      in>>b;
      //      in>>temp;
      in>>d;
      //cout<<b<<"    "<<d<<endl;
      out<<b<<"    "<<e<<endl;
e+=d;
      out<<b+d<<"    "<<e<<endl;
      in.getline(temp,256);
    }
    else in.getline(temp,256);
    ch=in.peek();
  }while (ch!=EOF);
  in.close();
  out.close();
}

