/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		        String regex = "\\(\\[(Modulus\\(\\d+\\)(?:\\s*,\\s*Modulus\\(\\d+\\))*)\\]\\):(\\(\\d+(?:,\\d+)*\\)x\\^\\d+(?:\\s*\\+\\s*\\(\\d+(?:,\\d+)*\\)x\\^\\d+)*)";
        String string = "RNS Polynomial ([Modulus(68719403009), Modulus(68719230977), Modulus(137438822401)]):(67699591241,42814670386,92925202514)x^0 + (42539574637,55054036653,135659663247)x^1 + (52858091297,11618896202,6855552742)x^2 + (45970532823,20845087073,91272562929)x^3 + (11148839321,55275439733,5401722690)x^4 + (31959765643,40620395732,93052536121)x^5 + (57030732406,66026147059,6304524013)x^6 + (27778918692,11276356856,61606736382)x^7\n";

        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(string);

        while (matcher.find()) {
            if (matcher.group(1) != null) {
                for (String elm1 : matcher.group(1).split(",\\s*"))
                    System.out.println(elm1);
            }
            if (matcher.group(2) != null) {
                for (String elm2 : matcher.group(2).split("\\s*\\+\\s*"))
                    System.out.println(elm2);
            }
        }
	}
}