#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
cin >> n;
getline(cin, s);
for (int i = 1; i <= n; ++i) {
getline(cin, s);
if (s.find("print ") != string::npos) {
s.replace(s.find("print "), 6, "print(");
cout << s << ")\n";
} else {
cout << s << "\n";
}
}
return 0;
}