#include "stdafx.h"
#include <stack>
#include <stdio.h>
#include<iostream>
using namespace std;
stack<int> s;
char str[100];
char ans[110];
int _tmain(int argc, _TCHAR* argv[])
{
while (cin >> str)
{
int i;
for (i = 0; str[i] != 0; i++){
if (str[i] == '('){
s.push(i);
ans[i] = ' ';
}
else if (str[i] == ')'){
if (s.empty() == false){
s.pop();
ans[i] = ' ';
}
else ans[i] = '?';
}
else ans[i] = ' ';
}
while (!s.empty()){
ans[s.top()] = '$';
s.pop();
}
ans[i] = 0;
puts(str);
puts(ans);
}
return 0;
}
#include <stack>
#include <stdio.h>
#include<iostream>
using namespace std;
stack<int> s;
char str[100];
char ans[110];
int _tmain(int argc, _TCHAR* argv[])
{
while (cin >> str)
{
int i;
for (i = 0; str[i] != 0; i++){
if (str[i] == '('){
s.push(i);
ans[i] = ' ';
}
else if (str[i] == ')'){
if (s.empty() == false){
s.pop();
ans[i] = ' ';
}
else ans[i] = '?';
}
else ans[i] = ' ';
}
while (!s.empty()){
ans[s.top()] = '$';
s.pop();
}
ans[i] = 0;
puts(str);
puts(ans);
}
return 0;
}