#include <fstream>
#include <sstream>
#include <string>
#include <algorithm>
using namespace std;

string strrev(const string& str)
{
  string rev_str;
  for (int i=str.size()-1; i>=0; i--)
    rev_str += str[i];
  return rev_str;
}

int main(int argc, char* argv[])
{
  if (argc != 3)
    return 0;

  ifstream ifs(argv[1]);
  ofstream ofs(argv[2]);
  string line;
  while (getline(ifs, line)) {
    line.erase(remove_if(line.begin(), line.end(),
               [](char c) { return c == '\r' || c == '\n'; }),
               line.end());
    ofs << strrev(line) << endl;
  }
}
