#include <iostream>
#include <string>
#include <stdexcept>
#include <ginac/ginac.h>
using namespace std;
using namespace GiNaC;

int main()
{
	parser reader;
	try {
		string line;
		while (getline(cin, line)) {
			ex e = reader(line);
			e = expand(normal(e));
			cout << e << endl;
		}
	} catch (exception &p) {
		cerr << p.what() << endl;
		return EXIT_FAILURE;
	}
	return EXIT_SUCCESS;
}
