import java.io.*; import java.util.*; /* * * @author David Alvarez Lopez * @email sly.dekar@gmail.com * @date 29-Oct-05 * */ public class instantComplexity { private static PrintWriter stdOut = new PrintWriter(System.out, true); private static LinkedList loops, ops; private static int arr[] = new int[11]; public static void main(String args[]) throws IOException { try { BufferedReader fileIn = new BufferedReader(new FileReader("C:/input.txt")); if (fileIn.ready()) { int nCases = Integer.parseInt(fileIn.readLine()); String thread = new String(); while (fileIn.ready()) { thread += fileIn.readLine() + " "; } StringTokenizer stk = new StringTokenizer(thread," "); for (int i = 0; i0; i--) { if (arr[i] != 0) { if (arr[i] != 1 && i != 1) { stdOut.print(arr[i] + "*n^" + i); } else { if (arr[i] != 1) { stdOut.print(arr[i] + "*n"); } else { if (i != 1) { stdOut.print("n^" + i); } } } stdOut.print("+"); } } stdOut.print(arr[0]); } }