// Arup Guha
// 3/21/2017
// Solution to 1991 UCF HS Contest Problem: Parenthesis Numbering

import java.util.*;

public class parens {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);

		// Read till eof
		while (stdin.hasNext()) {

			// Get input.
			String line = stdin.next();

			// Store numbers here.
			int[] nums = new int[line.length()];

			// This will be used to match parentheses.
			Stack<Integer> st = new Stack<Integer>();
			boolean ok = true;
			int cur = 1;

			// Go through each parenthesis.
			for (int i=0; i<line.length(); i++) {

				// Too many closes.
				if (st.size() == 0 && line.charAt(i) == ')') {
					ok = false;
					break;
				}

				// If it's an open, just push it onto the stack.
				if (line.charAt(i) == '(') {
					nums[i] = cur;
					st.push(cur++);
				}

				// If it's a close, jut pop the stack to get the matching number.
				if (line.charAt(i) == ')') {
					nums[i] = st.pop();
				}
			}

			// Last way we can fail.
			if (st.size() > 0) ok = false;

			// Print out the matching numbers.
			if (ok) {

				// Output using field width of 3 per item.
				for (int i=0; i<line.length(); i++)
					System.out.printf("%3c",line.charAt(i));
				System.out.println();
				for (int i=0; i<nums.length; i++)
					System.out.printf("%3d", nums[i]);
				System.out.println();
			}

			// Error message for this case.
			else
				System.out.println("Parentheses do not match!");

			// Blank line after each case.
			System.out.println();
		}
	}
}