#!/usr/bin/python
# Author: Ivan Kazmenko (gassa@mail.ru)
# Solution using regular expressions substitution
# Prints steps of solving
import re
PROBLEM_NAME = 'bracket-expression'

fin  = open (PROBLEM_NAME + '.in',  'rt')
fout = open (PROBLEM_NAME + '.out', 'wt')
for s in fin:
	s = s.strip ()
	if s == '':
		s = '1'
	fout.write ('{0}\n'.format (s))
	s = re.sub ('\(\)', '(1)', s)
	fout.write ('{0}\n'.format (s))
	s = re.sub ('\)\(', ')*(', s)
	fout.write ('{0}\n'.format (s))
	while True:
		t = re.sub ('\(([0-9]+)\)', \
		  lambda x: str (int (x.group (1)) + 1), s)
		fout.write ('{0}\n'.format (t))
		r = re.sub ('([0-9]+)\*([0-9]+)', \
		  lambda x: str (int (x.group (1)) * int (x.group (2))), t)
		fout.write ('{0}\n'.format (r))
		if s == r:
			break
		s = r	
	fout.write ('{0}\n'.format (s))
