n=int(input()) for i in range(n): str1=input() new=str1.replace('print ','print(') if new!=str1: new=new+')' print(new)