#include<iostream>
#include<stack>
using namespace std;
int main()
{
char s[101];
while (cin >> s)
{
stack<int> stk;
int flag[101] = {0};
char out[101] = {' '};
int i=0;
cout << s << endl;
while (s[i] != ' ')
{
out[i] = ' ';
if (s[i] == '(')
{
stk.push(i);
}
if (s[i] == ')')
{
if (stk.empty())
{
out[i] = '?';
}
else
{
stk.pop();
}
}
i++;
}//end of while(' ')
while (!stk.empty())
{
out[stk.top()] = '$';
stk.pop();
}
cout << out << endl;
}
return 0;
}