// 本题为考试单行多行输入输出规范示例,无需提交,不计分。
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
for (int i=0;i<=n;i++) {// 注意,如果输入是多个测试用例,请通过while循环处理多个测试用例
String line = in.nextLine();
System.out.println(parse(line));
}
}
private static String parse(String str) {
StringBuilder sb = new StringBuilder();
LinkedList len = new LinkedList();
String temp="";
for(int i=0;i
if(str.charAt(i) == '('){
len.add(sb.length());
continue;
}
if (str.charAt(i) == ')') {
int leftIndexNew = len.remove(len.size()-1);
temp = sb.substring(leftIndexNew);
i++;
}
int start = i;
while(i='0'){
i++;
}
if( i-start >= 1){
int count = Integer.valueOf(str.substring(start,i));
for(int j=0;j
if(temp == "")
sb.append(str.charAt(start-1));
else
sb.append(temp);
}
temp = "";
i--;
}
else {
sb.append(str.charAt(i));
}
}
return sb.toString();
}
}