#include<bits/stdc++.h>
#define int long long
using namespace std;
string s;
char empty;
struct liyizhou{
int v;
char zf;
}bds[1010];
stack<char> st;
int cnt;
void print(){
for(int i=1;i<=cnt;i++){
if(bds[i].v) cout<<bds[i].v<<' ';
if(bds[i].zf) cout<<bds[i].zf<<' ';
}
cout<<'\n';
}
bool check(){
for(int i=1;i<=cnt;i++)
if(bds[i].zf) return true;
return false;
}
int yxj(char a){
switch(a){
case '+': return 1;
case '-': return 1;
case '*': return 2;
case '/': return 2;
case '^': return 3;
default: return -1e9;
}
return -1e9;
}
int z(int x,int y,char a){
switch(a){
case '+': return y+x;
case '-': return y-x;
case '*': return y*x;
case '/': return y/x;
case '^': return pow(y,x);
default: return -1e9;
}
return -1e9;
}
bool f;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>s;
for(int i=0;i<s.size();i++){
if(isdigit(s[i])){
// cout<<s[i]<<' ';
bds[++cnt].v=s[i]-'0';
}else{
if(s[i]=='('){
st.push(s[i]);
f=true;
continue;
}
if(s[i]==')'){
while(st.size()){
if(st.top()=='('){
st.pop();
f=false;
break;
}
// cout<<st.top()<<' ';
bds[++cnt].zf=st.top();
st.pop();
}
continue;
}
if(st.size()&&!f){
if(s[i]!='^'){
vector<char> v;
while(st.size()){
if(yxj(st.top())>=yxj(s[i])){
// cout<<st.top()<<' ';
bds[++cnt].zf=st.top();
}else{
v.push_back(st.top());
}
st.pop();
}
for(int i=v.size()-1;i>=0;i--) st.push(v[i]);
}
}
st.push(s[i]);
}
}
while(st.size()){
// cout<<st.top()<<' ';
bds[++cnt].zf=st.top();
st.pop();
}
print();
while(check()){
int id=0;
for(int i=1;i<=cnt&&!id;i++)
if(yxj(bds[i].zf)!=-1e9) id=i;
int e=2,id1,id2,i=id;
while(e){
i--;
if(bds[i].v&&e==2){
id1=i;
e--;
}else if(bds[i].v&&e==1){
id2=i;
e--;
}
}
bds[id1].v=z(bds[id1].v,bds[id2].v,bds[id].zf);
bds[id2].v=0;
bds[id].zf=empty;
print();
}
return 0;
}