#include<iostream>
#include<string>
using namespace std;
int main() {
int t;
string a;
cin >> t;
cin.ignore();
while (t--) {
getline(cin, a);
int l = a.find("print ",0);
if (l!=-1) {
a.replace(l, 6, "print(");
cout << a << ")\n";
}
else {
cout << a << "\n";
}
}
}