Malek has recently found a treasure map. While he was looking for a treasure he found a locked door. There was a string s written on the door consisting of characters '(', ')' and '#'. Below there was a manual on how to open the door. After spending a long time Malek managed to decode the manual and found out that the goal is to replace each '#' with one or more ')' characters so that the final string becomes beautiful. 

Below there was also written that a string is called beautiful if for each i (1 ≤ i ≤ |s|) there are no more ')' characters than '(' characters among the first i characters of s and also the total number of '(' characters is equal to the total number of ')' characters. 

Help Malek open the door by telling him for each '#' character how many ')' characters he must replace it with.


-----Input-----

The first line of the input contains a string s (1 ≤ |s| ≤ 10^5). Each character of this string is one of the characters '(', ')' or '#'. It is guaranteed that s contains at least one '#' character.


-----Output-----

If there is no way of replacing '#' characters which leads to a beautiful string print  - 1. Otherwise for each character '#' print a separate line containing a positive integer, the number of ')' characters this character must be replaced with.

If there are several possible answers, you may output any of them.


-----Examples-----
Input
(((#)((#)

Output
1
2

Input
()((#((#(#()

Output
2
2
1
Input
#

Output
-1

Input
(#)

Output
-1



-----Note-----

|s| denotes the length of the string s.

Difficulty: MEDIUM
Tags: Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
txt = input()
hli = txt.rfind('#')
fail = False

def check(s, e):
	return 0
sc1 = 0
for i in range(0, hli):
	if txt[i] == '(':
		sc1 += 1
	else:
		sc1 -= 1
	if sc1 < 0:
		fail = True
		break
sc2 = 0
if not fail:
	for i in range(len(txt) - 1, hli, -1):
		if txt[i] == ')':
			sc2 += 1
		else:
			sc2 -= 1
		if sc2 < 0:
			fail = True
			break
if fail or sc1 - sc2 < 1:
	print(-1)
else:
	for i in range(txt.count('#') - 1):
		print(1)
	print(sc1 - sc2)


s = [*input()]
ans = []
t = h = 0
for i in range(len(s)):
	t += 1 if s[i] == '(' else -1
	if t < 0:
		print(-1)
		exit()
	if s[i] == '#':
		s[i] = ')'
		ans.append(1)
		h = i
ans[-1] += t
s = s[:h] + [')'] * t + s[h:]
t = 0
for i in s:
	t += 1 if i == '(' else -1
	if t < 0:
		print(-1)
		exit()
print(*ans, sep='\n')


s = str(input())
x = b = 0
r = []
for i in range(len(s)):
	if s[i] == '(':
		b += 1
	elif s[i] == ')':
		b -= 1
	else:
		b -= 1
		x = b
		r.append(1)
	if b < 0:
		print(-1)
		quit()
if b <= x:
	r[-1] += b
	x = b = 0
	for i in range(len(s)):
		if s[i] == '(':
			b += 1
		elif s[i] == ')':
			b -= 1
		else:
			b -= r[x]
			x += 1
		if b < 0:
			print(-1)
			quit()
else:
	print(-1)
	quit()
for i in range(len(r)):
	print(r[i])


import sys

def main():
	for ln in sys.stdin:
		s = ln.strip()
		for x in solve(s):
			print(x)

def solve(s):
	ans = []
	n = len(s)
	r = l = h = 0
	for i in range(n):
		if s[i] == '(':
			r += 1
		elif s[i] == ')':
			l += 1
		else:
			h += 1
	if r <= l:
		return [-1]
	b = 0
	for i in range(n - 1, -1, -1):
		if s[i] == ')':
			r -= 1
			l -= 1
			b += 1
		elif s[i] == '#':
			if r == 0:
				return [-1]
			r -= 1
			h -= 1
			x = r - l - h
			if r - x >= 0:
				r -= x
			else:
				x = 0
			ans.append(1 + x)
			b += 1 + x
		else:
			b -= 1
			if b < 0:
				return [-1]
	ans = ans[::-1]
	return ans
main()


s = input().replace('()', '')
t = s.count('(') - s.count(')') - s.count('#')
if t < 0 or s.index('#') < s.index('('):
	print(-1)
	quit()
l = [1] * s.count('#')
l[-1] += t
i = [k for (k, l) in enumerate(s) if l == '#']
(a, b) = (0, 0)
for x in range(len(s)):
	if s[x] == '(':
		a += 1
	elif s[x] == ')':
		b += 1
	elif s[x] == '#' and x != i[-1]:
		b += 1
	elif s[x] == '#':
		b += t + 1
	if a < b:
		print(-1)
		quit()
if a != b:
	print(-1)
else:
	print('\n'.join(map(str, l)))


def f(t):
	n = t.count('#') - 1
	k = t.rfind('#') + 1
	t = t.replace('#', ')')
	t = [2 * ord(i) - 81 for i in t]
	a = b = c = 0
	for i in t[k:]:
		b -= i
		c -= i
		if c < 0:
			c = 0
	if c > 0:
		return -1
	for i in t[:k]:
		a -= i
		if a < 0:
			return -1
	if b + a < 0:
		return -1
	return '1\n' * n + str(b + a + 1)
print(f(input()))


s = input().strip()
if s == '#':
	print(-1)
	exit(0)
b1 = 0
for i in s:
	if i == '(':
		b1 += 1
	else:
		b1 -= 1
b1 += 1
k = s.count('#')
l = 0
b2 = 0
if b1 <= 0:
	print(-1)
	exit(0)
for i in s:
	if i == '(':
		b2 += 1
	elif i == ')':
		b2 -= 1
	else:
		if i == '#':
			l += 1
		if l < k:
			b2 -= 1
		else:
			b2 -= b1
	if b2 < 0:
		print(-1)
		exit(0)
if b2 != 0:
	print(-1)
else:
	print(*[1] * (k - 1) + [b1], sep='\n')


def needs_trailing(segment):
	open_parens = 0
	for i in segment:
		if i == '(':
			open_parens += 1
		elif i == ')' or i == '#':
			open_parens -= 1
		if open_parens < 0:
			return -1
	return open_parens
line = input()
extra_parens = needs_trailing(line)
last_segment_needs = needs_trailing(line.split('#')[-1])
if extra_parens < 0:
	print(-1)
elif last_segment_needs > 0:
	print(-1)
else:
	outputs = [1 for i in range(line.count('#'))]
	outputs[-1] += needs_trailing(line)
	new_str = line.rpartition('#')[0].replace('#', ')') + outputs[-1] * ')' + line.rpartition('#')[-1]
	if needs_trailing(new_str) != 0:
		print(-1)
	else:
		for output in outputs:
			print(output)


import sys
S = input()
N = S.count('#')
D = S.count('(') - S.count(')') - N + 1
if D <= 0:
	print(-1)
	sys.exit()
S = S.split('#')
S = ')'.join(S[:-1]) + ')' * D + S[-1]
Lvl = 0
for C in S:
	if C == '(':
		Lvl += 1
	if C == ')':
		Lvl -= 1
	if Lvl < 0:
		print(-1)
		sys.exit()
for I in range(N - 1):
	print(1)
print(D)


import sys

def main():
	for ln in sys.stdin:
		s = ln.strip()
		for x in solve(s):
			print(x)

def solve(s):
	b = k = 0
	for c in s:
		if c == '(':
			b += 1
		elif c == ')':
			b -= 1
		else:
			k += 1
			b -= 1
		if b < 0:
			return [-1]
	bb = 0
	for c in reversed(s):
		if c == '(':
			bb -= 1
		elif c == ')':
			bb += 1
		else:
			break
		if bb < 0:
			return [-1]
	ans = [1] * k
	ans[-1] += b
	return ans
main()


s = input()
opening = 0
closing = 0
all_symbols = []
last_empty = -1
for i in range(len(s)):
	ch = s[i]
	if ch == '(':
		opening += 1
	elif ch == ')':
		closing += 1
	else:
		last_empty = i
	all_symbols.append(ch)
if len(s) - opening - closing > opening - closing or (last_empty == -1 and opening != closing):
	print(-1)
else:
	ans = []
	k = opening - closing
	cnt = 0
	for i in range(len(s)):
		ch = all_symbols[i]
		if ch == '#':
			if i == last_empty:
				ans.append(k)
				cnt -= k
			else:
				ans.append(1)
				k -= 1
				cnt -= 1
		elif ch == '(':
			cnt += 1
		else:
			cnt -= 1
		if cnt < 0:
			print(-1)
			exit()
	if cnt != 0:
		print(-1)
	else:
		for elem in ans:
			print(elem)


s = input()
result = []
pos = 0
state = 0
for i in range(len(s)):
	if s[i] == '(':
		state += 1
	elif s[i] == ')':
		state -= 1
	elif s[i] == '#':
		x = max(1, state)
		state -= x
		result.append(x)
	if state < 0:
		while pos < len(result) and result[pos] <= 1:
			pos += 1
		if pos >= len(result):
			result = [-1]
			break
		result[pos] -= 1
		state += 1
if state > 0:
	result = [-1]
for r in result:
	print(r)


c = input()
count_l = 0
count_r = 0
h = c.count('#')
ans = [1] * h
n = len(c)
flag = 1
a = [0] * (n + 1)
for i in range(n):
	if c[i] == '(':
		a[i + 1] = a[i] + 1
	else:
		a[i + 1] = a[i] - 1
	if a[i + 1] < 0:
		flag = 0
		break
if flag == 0:
	print(-1)
else:
	ans[h - 1] += a[n]
	pos = 0
	flag = 1
	for i in range(n):
		if c[i] == '(':
			count_l += 1
		elif c[i] == ')':
			count_r += 1
		else:
			count_r += ans[pos]
			pos += 1
		if count_r > count_l:
			flag = 0
			break
	if flag:
		for i in range(h):
			print(ans[i])
	else:
		print(-1)


s = input()
n = len(s)
a = 0
ans = ''
c = 1
c1 = s.count('#')
for i in range(n):
	if s[i] == '#':
		c4 = i
		ans += ')'
	else:
		ans += s[i]
for i in ans:
	if i == '(':
		a += 1
	else:
		a -= 1
	if a < 0:
		c = 0
		break
if c == 0:
	print(-1)
else:
	c2 = ans.count('(')
	c3 = ans.count(')')
	ans = ans[:c4 + 1] + ')' * (c2 - c3) + ans[c4 + 1:]
	a = 0
	for i in ans:
		if i == '(':
			a += 1
		else:
			a -= 1
		if a < 0:
			c = 0
			break
	if c == 0 or a != 0:
		print(-1)
	else:
		for i in range(c1 - 1):
			print(1)
		print(c2 - c3 + 1)


s = input()
x = 0
tf = True
c1 = 0
c2 = 0
for i in range(len(s)):
	if s[i] == '(':
		c1 += 1
		x += 1
	else:
		x -= 1
	if x < 0:
		tf = False
		break
	if s[i] == '#':
		c2 += 1
		ind = i
if tf:
	x = 0
	ls = len(s)
	for i in range(len(s)):
		if s[i] == '(':
			x += 1
		else:
			x -= 1
		if i == ind:
			x -= 2 * c1 - ls
		if x < 0:
			tf = False
			break
	if tf:
		for _ in range(c2 - 1):
			print(1)
		print(1 + 2 * c1 - ls)
	else:
		print(-1)
else:
	print(-1)


s = input()
w = s.rindex('#')
q = 0
for i in range(len(s) - 1, w, -1):
	if s[i] == '(':
		q += 1
	else:
		q -= 1
	if q > 0:
		print(-1)
		exit()
d = 0
zz = []
for i in range(w):
	if s[i] == '(':
		d += 1
	elif s[i] == ')':
		d -= 1
	else:
		d -= 1
		zz.append(1)
	if d < 0:
		print(-1)
		exit()
y = q + d
if y <= 0:
	print(-1)
else:
	zz.append(y)
	print('\n'.join(map(str, zz)))


s = input()
ans = []
(cnt, key, tmp, new) = (0, True, 0, 0)
for e in s:
	if e == '(':
		cnt += 1
		new += 1
	elif e == ')':
		cnt -= 1
		if new > 0:
			new -= 1
		if cnt < 0:
			key = False
			break
	else:
		if cnt == 0:
			key = False
			break
		new = 0
		ans.append(1)
		cnt -= 1
		tmp = cnt
if not key or tmp < cnt or new > 0:
	print(-1)
else:
	ans[-1] += cnt
	for e in ans:
		print(e)


s = input()
ans = []
count = 0
last_pos = s.rfind('#')
for (i, c) in enumerate(s):
	if c == '(':
		count += 1
	elif c == ')':
		count -= 1
	elif c == '#' and i == last_pos:
		num = max(1, s.count('(') * 2 - len(s) + 1)
		count -= num
		ans.append(num)
	else:
		count -= 1
		ans.append(1)
	if count < 0:
		print(-1)
		break
else:
	for t in ans:
		print(t)


import itertools
import math

def main():
	s = input()
	n = s.count('#')
	d = s.count('(') - s.count(')') - n + 1
	if d <= 0:
		print(-1)
		return
	s = s.split('#')
	s = ')'.join(s[:-1]) + ')' * d + s[-1]
	lvl = 0
	for c in s:
		if c == '(':
			lvl += 1
		if c == ')':
			lvl -= 1
		if lvl < 0:
			print(-1)
			return
	for i in range(n - 1):
		print(1)
	print(d)
main()


s = input()
count = 0
res = []
last = s.rfind('#')
for (i, c) in enumerate(s):
	if c == '(':
		count += 1
	elif c == ')':
		count -= 1
	elif i < last:
		res.append(1)
		count -= 1
	else:
		num = max(1, 1 + s.count('(') - s.count('#') - s.count(')'))
		res.append(num)
		count -= num
	if count < 0:
		res = []
		print(-1)
		break
for i in res:
	print(i)


__author__ = 'Rakshak.R.Hegde'
s = input()
lastH = s.rfind('#')
countBr = 0
for i in range(lastH):
	if s[i] == '(':
		countBr += 1
	else:
		countBr -= 1
	if countBr < 0:
		break
else:
	nco = s.count('(', lastH + 1)
	ncc = s.count(')', lastH + 1)
	cntExtraC = countBr + nco - ncc
	countBr -= cntExtraC
	if cntExtraC > 0 and countBr >= 0:
		for i in range(lastH + 1, len(s)):
			if s[i] == '(':
				countBr += 1
			else:
				countBr -= 1
			if countBr < 0:
				break
		else:
			countH = s.count('#')
			print('1\n' * (countH - 1) + str(cntExtraC))
			exit(0)
print('-1')


import sys
a = 0
s = input()
l = []
for i in s:
	if i == '(':
		a = a + 1
	elif i == ')':
		a = a - 1
	else:
		a = a - 1
		l.append(1)
	if a < 0:
		print(-1)
		sys.exit()
l[-1] += a
a = 0
k = 0
for j in s:
	if j == '(':
		a = a + 1
	elif j == ')':
		a = a - 1
	else:
		a = a - l[k]
		k = k + 1
	if a < 0:
		print(-1)
		sys.exit()
if a != 0:
	print(-1)
else:
	for j in l:
		print(j)


import math
import bisect
import itertools
import sys
I = lambda : sys.stdin.readline()
one = lambda : int(I())
more = lambda : map(int, I().split())
linput = lambda : list(more())
mod = 10 ** 9 + 7
inf = 10 ** 18 + 1

def merge(a, b):
	i = 0
	j = 0
	c = 0
	ans = []
	while i < len(a) and j < len(b):
		if a[i] < b[j]:
			ans.append(a[i])
			i += 1
		else:
			ans.append(b[j])
			c += len(a) - i
			j += 1
	ans += a[i:]
	ans += b[j:]
	return (ans, c)

def mergesort(a):
	if len(a) == 1:
		return (a, 0)
	mid = len(a) // 2
	(left, left_inversion) = mergesort(a[:mid])
	(right, right_inversion) = mergesort(a[mid:])
	(m, c) = merge(left, right)
	c += left_inversion + right_inversion
	return (m, c)

def is_prime(num):
	if num == 1:
		return False
	if num == 2:
		return True
	if num == 3:
		return True
	if num % 2 == 0:
		return False
	if num % 3 == 0:
		return False
	t = 5
	a = 2
	while t <= int(math.sqrt(num)):
		if num % t == 0:
			return False
		t += a
		a = 6 - a
	return True

def ceil(a, b):
	return (a + b - 1) // b
s = list(input())
n = len(s)
o = s.count('(')
c = s.count(')')
hash = s.count('#')
if o < c + hash:
	print(-1)
	exit()
for i in range(n - 1, -1, -1):
	if s[i] == '#':
		ind = i
		break
s = s[:ind] + [')'] * (o - c - hash + 1) + s[ind + 1:]
for i in range(len(s)):
	if s[i] == '#':
		s[i] = ')'
open = 0
ans = []
for i in s:
	if i == '(':
		open += 1
	elif i == ')':
		if open == 0:
			print('-1')
			exit()
		open -= 1
for i in range(hash):
	if i != hash - 1:
		print(1)
	else:
		print(o - c - hash + 1)


s = input()
n = len(s)
(p, curr) = (n - 1, 0)
while s[p] != '#':
	if s[p] == ')':
		curr += 1
	else:
		curr -= 1
	p -= 1
	if curr < 0:
		print(-1)
		exit()
(cnt_hash, curr) = (s.count('#'), 0)
for i in range(p):
	if s[i] == '(':
		curr += 1
	else:
		curr -= 1
	if curr < 0:
		print(-1)
		exit()
res = s.count('(') - s.count(')') - (cnt_hash - 1)
if res <= 0:
	print(-1)
	exit()
cnt_hash -= 1
print('\n'.join('1' * cnt_hash))
print(s.count('(') - s.count(')') - cnt_hash)


s = input()
ret = [None] * len(s)
bal = [None] * len(s)
b = 0
last = None
for (i, c) in enumerate(s):
	if c == '(':
		b += 1
	elif c == ')':
		b -= 1
	else:
		ret[i] = 1
		b -= 1
		last = i
	if b < 0:
		print(-1)
		exit()
	bal[i] = b
rem = bal[-1]
ret[last] += rem
for i in range(last, len(bal)):
	bal[i] -= rem
print('\n'.join(map(str, filter(lambda x: x, ret))) if min(bal) >= 0 else -1)


s = input()
last = s.rfind('#')
dif = s.count('(') - s.count(')') - s.count('#')
try:
	assert dif >= 0
	lev = 0
	out = []
	for i in range(len(s)):
		c = s[i]
		if c == '(':
			lev += 1
		elif c == ')':
			lev -= 1
			assert lev >= 0
		elif c == '#':
			lev -= 1
			if i == last:
				out.append(dif + 1)
				lev -= dif
			else:
				out.append(1)
			assert lev >= 0
	assert lev == 0
	for x in out:
		print(x)
except AssertionError:
	print(-1)


s = input()
lis = [0 for i in range(len(s))]
lis1 = []
for i in range(len(s)):
	if s[i] == '(':
		lis[i] = 1
	if s[i] == ')':
		lis[i] = -1
	if s[i] == '#':
		lis[i] = 0
		lis1.append(i)
if sum(lis) <= 0:
	print(-1)
else:
	n = sum(lis)
	if n < len(lis1):
		print(-1)
	else:
		for i in range(len(lis1) - 1):
			lis[lis1[i]] = -1
		lis[lis1[len(lis1) - 1]] = -(n + 1 - len(lis1))
		lis2 = [lis[0]]
		c = 1
		if lis[0] < 0:
			c = 0
		else:
			for i in range(1, len(lis)):
				lis2.append(lis[i] + lis2[i - 1])
				if lis2[i] < 0:
					c = 0
					break
		if c == 0:
			print(-1)
		else:
			for i in range(len(lis1) - 1):
				print(1)
			print(n + 1 - len(lis1))


import sys
st = input()
a = 0
b = 0
last = 0
v = []
for s in st:
	if s == '(':
		a += 1
	elif s == ')':
		a -= 1
	elif s == '#':
		a -= 1
		v.append(1)
	if a < 0:
		print(-1)
		return
v[-1] += a
i = 0
a = 0
for s in st:
	if s == '(':
		a += 1
	elif s == ')':
		a -= 1
	elif s == '#':
		a -= v[i]
		i += 1
	if a < 0:
		print(-1)
		return
if a != 0:
	print(-1)
else:
	for vs in v:
		print(vs)


s = input()
a = 0
b = []
for x in s:
	if x == '(':
		a += 1
	else:
		if x == ')':
			a -= 1
		else:
			a -= 1
			b.append(1)
		if a < 0:
			print(-1)
			exit()
b[-1] += a
a = 0
i = 0
for x in s:
	if x == '(':
		a += 1
	else:
		if x == ')':
			a -= 1
		else:
			a -= b[i]
			i += 1
		if a < 0:
			print(-1)
			exit()
if a != 0:
	print(-1)
else:
	for x in b:
		print(x)


from math import *
m = []
nn = []
for i in range(1):
	m.append(input())
flag = -1
for i in range(1):
	c1 = 0
	c2 = 0
	c3 = 0
	s = m[0]
	ss = []
	l = len(s)
	last = -1
	flag = 0
	s2 = []
	for j in range(l):
		if s[l - 1 - j] == '#':
			last = l - 1 - j
			break
	for j in range(l):
		if c2 + c3 > c1:
			print(-1)
			flag = 1
			exit()
		if s[j] == '(':
			c1 = c1 + 1
		elif s[j] == ')':
			c2 = c2 + 1
		elif s[j] == '#' and j != last:
			c3 = c3 + 1
		elif s[j] == '#' and j == last:
			c3 = c3 + 1
		if c2 + c3 > c1:
			print(-1)
			flag = 1
			exit()
	ccc = c1 - c2 - c3 + 1
	c1 = 0
	c2 = 0
	c3 = 0
	for j in range(l):
		if c2 + c3 > c1:
			print(-1)
			flag = 1
			exit()
		if s[j] == '(':
			c1 = c1 + 1
		elif s[j] == ')':
			c2 = c2 + 1
		elif s[j] == '#' and j != last:
			c3 = c3 + 1
			ss.append(1)
		elif s[j] == '#' and j == last:
			c3 = c3 + ccc
			ss.append(ccc)
		if c2 + c3 > c1:
			print(-1)
			flag = 1
			exit()
print(*ss, sep=' ')


s = list(input())
f = b = c = 0
l = len(s)
ans = []
for i in range(l):
	if s[i] == '(':
		f += 1
	else:
		b += 1
		if s[i] == '#':
			ans.append(1)
	if b > f:
		print(-1)
		exit()
ans[-1] += f - b
b = f
for i in range(l - 1, -1, -1):
	if s[i] == '(':
		f -= 1
	elif s[i] == ')':
		b -= 1
	else:
		if b > f:
			print(-1)
			exit()
		for j in range(i + 1, l):
			if s[j] == '(':
				f += 1
			else:
				b += 1
			if b > f:
				print(-1)
				exit()
		break
for i in ans:
	print(i)


s = list(input())
op = 0
res = [1] * s.count('#')
now = 0
for i in s:
	if i == '(':
		op += 1
	if i == ')' or i == '#':
		op -= 1
	if op < 0:
		print(-1)
		exit(0)
res[-1] += op
op = 0
now = 0
for i in range(len(s)):
	if s[i] == '(':
		op += 1
	elif s[i] == ')':
		op -= 1
	else:
		op -= res[now]
		now += 1
	if op < 0:
		print(-1)
		exit(0)
if op != 0:
	print(-1)
	exit(0)
for i in res:
	print(i)


s = input()
n = s.rfind('#')
error = 0
s1 = 0
s2 = 0
s3 = 0
s4 = s.count('(')
s5 = s.count(')')
s6 = 0
for num in range(n):
	if s[num] == '(':
		s2 += 1
	elif s[num] == ')':
		s3 += 1
	if s[num] == '#':
		s1 += 1
		s3 += 1
	if s3 > s2:
		error = 1
if s1 + s5 < s4:
	s6 = s4 - s5 - s1
	s3 += s6
else:
	error = 1
for num in range(n, len(s)):
	if s[num] == '(':
		s2 += 1
	elif s[num] == ')':
		s3 += 1
	if s3 > s2:
		error = 1
if error == 1:
	print(-1)
else:
	while s1 > 0:
		print(1)
		s1 -= 1
	print(s6)


import collections, itertools, functools, math

def valid(s, r):
	r = iter(r)
	op = 0
	cl = 0
	for c in s:
		if c == '(':
			op += 1
		elif c == ')':
			cl += 1
		elif c == '#':
			cl += next(r)
		if cl > op:
			return False
	return True

def solve(s):
	FAIL = [-1]
	op = s.count('(')
	cl = s.count(')')
	h = s.count('#')
	if cl + h > op:
		return FAIL
	r = [1] * h
	r[-1] += op - cl - h
	if not valid(s, r):
		return FAIL
	return r

def __starting_point():
	for n in solve(input()):
		print(n)
__starting_point()


s = input()
ans = []
count = 0
last_pos = s.rfind('#')
n = len(s)
for i in range(n):
	if s[i] == '(':
		count += 1
	elif s[i] == ')':
		count -= 1
	elif s[i] == '#' and i == last_pos:
		num = max(1, s.count('(') * 2 - len(s) + 1)
		count -= num
		ans.append(num)
	else:
		count -= 1
		ans.append(1)
	if count < 0:
		print(-1)
		exit(0)
for t in ans:
	print(t)


s = input()
l = []
b = False
u = [0] * len(s)
for i in range(len(s) - 2, -1, -1):
	u[i] = u[i + 1] + (s[i + 1] != '(')
	u[i] -= s[i + 1] == '('
	u[i] = max(u[i], 0)
d = 0
for i in range(len(s)):
	if s[i] == '#':
		l += [d - u[i]]
		d -= d - u[i]
		b = True
	elif s[i] == ')':
		d -= 1
		if d < 0 and (not b):
			l += [-1]
			break
	else:
		d += 1
d = 0
b = False
for i in range(len(s) - 1, -1, -1):
	if s[i] == '#':
		b = True
		break
	elif s[i] == '(':
		d -= 1
		if d < 0 and (not b):
			l += [-1]
			break
	else:
		d += 1
if min(l) < 1:
	print(-1)
else:
	for i in l:
		print(i)


works = True
inp = input()
left = len(inp.split('(')) - 1
right = len(inp.split(')')) - 1
symb = len(inp.split('#')) - 1
diff = left - right
if diff <= 0:
	works = False
l = []
for x in range(symb - 1):
	l.append(1)
l.append(diff - symb + 1)
st = inp.split('#')
n = st.pop()
st = ')'.join(st)
for x in range(l[-1]):
	st = st + ')'
st += n
left = 0
right = 0
for x in st:
	if x == '(':
		left += 1
	else:
		right += 1
	if right > left:
		works = False
		break
if works:
	for x in l:
		print(x)
else:
	print(-1)


S = input().rstrip()
(a, b, c) = (S.count('('), S.count(')'), S.count('#'))
d = a - b
if d >= c:
	Res = [1] * (c - 1) + [d - c + 1]
	balans = 0
	flag = True
	for i in S:
		if i == '(':
			balans += 1
		elif i == ')':
			balans -= 1
		else:
			balans -= (d != Res[-1]) + d * (d == Res[-1])
			d -= 1
		if balans < 0:
			flag = False
	if flag:
		for i in Res:
			print(i)
	else:
		print(-1)
else:
	print(-1)


import sys
s = str(input())
cnt = 0
ans = [0] * len(s)
for i in range(len(s)):
	if s[i] == '(':
		cnt += 1
	else:
		cnt -= 1
	if s[i] == '#':
		ans[i] = 1
	if cnt < 0:
		print(-1)
		sys.exit()
i = len(s) - 1
while s[i] != '#':
	i -= 1
ans[i] = cnt + 1
cnt = 0
for i in range(len(s)):
	if s[i] == '(':
		cnt += 1
	elif s[i] == ')':
		cnt -= 1
	else:
		cnt -= ans[i]
	if cnt < 0:
		print(-1)
		sys.exit()
for i in range(len(s)):
	if s[i] == '#':
		print(ans[i])


s = input()
left_paranthesis = sum((i == '(' for i in s))
right_paranthesis = sum((i == ')' for i in s))
hashes = sum((i == '#' for i in s))
if left_paranthesis < right_paranthesis + hashes:
	print(-1)
	exit()
elif left_paranthesis == right_paranthesis + hashes:
	s.replace('#', ')')
	lp = 0
	rp = 0
	for i in s:
		if i == '(':
			lp += 1
		else:
			rp += 1
		if rp > lp:
			print(-1)
			exit()
	for i in range(hashes):
		print(1)
else:
	excess = left_paranthesis - right_paranthesis - hashes + 1
	l = s.rfind('#')
	ans = []
	for (i, j) in enumerate(s):
		if j != '#':
			ans.append(j)
		elif i != l:
			ans.append(')')
		else:
			ans.append(')' * excess)
	ans = ''.join(ans)
	lp = 0
	rp = 0
	for i in ans:
		if i == '(':
			lp += 1
		else:
			rp += 1
		if rp > lp:
			print(-1)
			exit()
	for i in range(hashes - 1):
		print(1)
	print(excess)


s = input()
c = 0
t = s.rfind('#')
ans = []
b = True
for i in range(t):
	if s[i] == '(':
		c += 1
	elif s[i] == ')':
		c -= 1
	else:
		c -= 1
		ans.append(1)
	if c < 0:
		b = False
		break
m = c
for i in range(t + 1, len(s)):
	if s[i] == '(':
		c += 1
	else:
		c -= 1
	m = min(m, c)
if b and m > 0 and (m == c):
	ans.append(m)
	print(*ans, sep='\n')
else:
	print(-1)


from sys import stdin
from sys import exit
live = True
if not live:
	stdin = open('data.in', 'r')
s = stdin.readline()
s = list(s)
limit = len(s)
open = []
ans = []
diez = 0
for it in range(limit):
	if s[it] == '(':
		open += [it]
	if s[it] == ')':
		if len(open) == 0:
			print(-1)
			exit(0)
		s[it] = s[open[-1]] = 0
		open.pop(-1)
	if s[it] == '#':
		diez += 1
pOpen = 0
for it in s:
	if it == '(':
		pOpen += 1
	if it == '#':
		if diez > 1:
			if pOpen > 0:
				pOpen -= 1
				ans += [1]
			else:
				print(-1)
				exit(0)
		if diez == 1:
			if pOpen > 0:
				ans += [pOpen]
				pOpen = 0
			else:
				print(-1)
				exit(0)
		diez -= 1
if pOpen > 0:
	print(-1)
	exit(0)
print('\n'.join(map(str, ans)))
if not live:
	stdin.close()


import sys

def main():
	for ln in sys.stdin:
		s = ln.strip()
		for x in solve(s):
			print(x)

def solve(s):
	ans = []
	b = 0
	for c in reversed(s):
		if c == ')':
			b += 1
		elif c == '(':
			b -= 1
			if b < 0:
				if not ans:
					return [-1]
				else:
					ans[-1] += 1
					b = 0
		else:
			b += 1
			ans.append(1)
	if b != 0:
		return [-1]
	return ans[::-1]
main()


s = input()
(a, b, c) = ('(', ')', '#')
s1 = len(s)
(a1, b1, c1, r) = (0, 0, 0, 1)
if s[-1] == a:
	print(-1)
else:
	for i in range(s1):
		if s[i] == a:
			a1 += 1
		if s[i] == b:
			b1 += 1
		if s[i] == c:
			c1 += 1
		if b1 + c1 > a1:
			r = 0
			break
	if r == 0:
		print(-1)
	else:
		m = 0
		for i in range(s1):
			if s[i] == c:
				break
			if s[i] == a:
				m += 1
			if s[i] == b:
				m -= 1
		k = a1 - b1
		for i in range(c1 - 1):
			print(1)
		if k >= c1:
			if c1 == 1:
				if k - c1 + 1 > m:
					print(-1)
				else:
					print(k - c1 + 1)
			else:
				print(k - c1 + 1)


s = input()
array = []
c = 0
for r in s:
	if r == '(':
		c += 1
	else:
		if r == '#':
			array.append(1)
		c -= 1
		if c < 0:
			print(-1)
			exit(0)
array[-1] += c
i = 0
c = 0
for r in s:
	if r == '(':
		c += 1
	elif r == '#':
		c -= array[i]
		i += 1
	else:
		c -= 1
	if c < 0:
		print(-1)
		exit(0)
print(*array, sep='\n')


s = input()
n = len(s)
ptr = n - 1
balance = 0
while s[ptr] != '#':
	if s[ptr] == ')':
		balance += 1
	else:
		balance -= 1
	ptr -= 1
	if balance < 0:
		print(-1)
		return
sharps = s.count('#')
balance = 0
for i in range(ptr):
	if s[i] == '(':
		balance += 1
	else:
		balance -= 1
	if balance < 0:
		print(-1)
		return
ans = s.count('(') - s.count(')') - (sharps - 1)
if ans <= 0:
	print(-1)
	return
for i in range(sharps - 1):
	print(1)
print(s.count('(') - s.count(')') - (sharps - 1))


s = input()
ans = ''
bal = 0
for i in range(len(s)):
	if s[i] == '(':
		bal += 1
	elif s[i] == ')':
		bal -= 1
	else:
		ans = bal
		bal -= 1
	if bal < 0:
		print(-1)
		exit(0)
bal = 0
i = len(s) - 1
while i >= 0 and s[i] != '#':
	bal += 1 if s[i] == '(' else -1
	i -= 1
	if bal > 0:
		print(-1)
		exit(0)
for i in range(s.count('#') - 1):
	print(1)
print(ans + bal)


import sys
s = input()
leftCount = 0
ansList = []
ansFlag = True
sharpCount = 0
for c in s:
	if c == '(':
		leftCount += 1
	elif c == ')':
		leftCount -= 1
		if leftCount < 0:
			ansFlag = False
	elif c == '#':
		leftCount -= 1
		if leftCount < 0:
			ansFlag = False
		else:
			ansList.append(1)
			sharpCount += 1
	else:
		sys.stderr.write('Unexpected character:%c' % c)
if ansFlag:
	ansList[-1] += leftCount
	leftCount = 0
	sharpCount = 0
	for c in s:
		if c == '(':
			leftCount += 1
		elif c == ')':
			leftCount -= 1
			if leftCount < 0:
				ansFlag = False
		elif c == '#':
			leftCount -= ansList[sharpCount]
			sharpCount += 1
			if leftCount < 0:
				ansFlag = False
		else:
			sys.stderr.write('Unexpected character:%c' % c)
	if ansFlag:
		for i in ansList:
			print(i)
	else:
		print(-1)
else:
	print(-1)


s = input()
c = s.count('#')
mylist = []
result = s.count('(') - s.count(')')
if result > 0:
	for i in range(c):
		if i == c - 1:
			mylist.append(result - c + 1)
		else:
			mylist.append(1)
else:
	mylist.append(-1)
s = list(s)
j = 1
for i in range(len(s)):
	if j < c:
		if s[i] == '#':
			s[i] = ')'
			j = j + 1
	elif s[i] == '#':
		s[i] = ')' * mylist[len(mylist) - 1]
s = ''.join(s)
a = 0
b = 0
for i in range(len(s)):
	if s[i] == '(':
		a = a + 1
	elif s[i] == ')':
		b = b + 1
		if a < b:
			mylist = [-1]
			break
for i in mylist:
	print(i)


def solve():
	l = list(input())
	n = len(l)
	idx = 0
	c = 0
	for i in l:
		if i == '#':
			c += 1
	for t in range(n - 1, -1, -1):
		if l[t] == '#':
			idx = t
			break
	for t in range(n):
		if l[t] == '#':
			l[t] = ')'
	k = [0 for t in range(n)]
	if l[0] == ')':
		return [-1]
	k[0] = 1
	for t in range(1, n):
		if l[t] == ')':
			k[t] = k[t - 1] - 1
		else:
			k[t] = k[t - 1] + 1
		if k[t] < 0:
			return [-1]
	v = [0 for i in range(n)]
	if l[-1] == '(':
		return [-1]
	v[-1] = 1
	for t in range(n - 2, idx - 1, -1):
		if l[t] == ')':
			v[t] = v[t + 1] + 1
		else:
			v[t] = v[t + 1] - 1
	v[idx] -= 1
	k[idx] += 1
	if v[idx] < 0:
		return [-1]
	if v[idx] == k[idx] or k[idx] == 0:
		return [-1]
	if v[idx] >= k[idx]:
		return [-1]
	ans = k[idx] - v[idx]
	x = [1 for i in range(c)]
	x[-1] = ans
	return x
z = solve()
for iu in z:
	print(iu)


__author__ = 'artyom'

def main():
	s = read(0)
	n = len(s)
	ex = 2 * s.count('(') - n
	if ex < 0:
		return -1
	res = []
	l = i = 0
	last = s.rfind('#')
	for i in range(n):
		c = s[i]
		if c == '(':
			l += 1
		elif c == ')':
			l -= 1
		else:
			if l == 0:
				return -1
			k = 1 if i < last else 1 + ex
			res.append(k)
			l -= k
		if l < 0:
			return -1
	return res

def read(mode=1, size=None):
	if mode == 0:
		return input().strip()
	if mode == 1:
		return int(input().strip())
	if mode == 2:
		return input().strip().split()
	if mode == 3:
		return list(map(int, input().strip().split()))
	a = []
	for _ in range(size):
		a.append(read(3))
	return a

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, tuple) or isinstance(s, list):
		s = '\n'.join(map(str, s))
	s = str(s)
	print(s, end='\n')
write(main())


def main():
	s = input()
	(n, o, c) = (s.count(c) for c in '#()')
	o -= c + n - 1
	if o < 1:
		print(-1)
		return
	l = s.split('#')
	(b, a) = (l.pop(), l.pop())
	l.append(''.join((a, ')' * o, b)))
	s = ')'.join(l)
	lvl = 0
	for c in s:
		if c == '(':
			lvl += 1
		elif c == ')':
			lvl -= 1
			if lvl < 0:
				print(-1)
				return
	for i in range(n - 1):
		print(1)
	print(o)
main()


a = input()
need = a.count('(') - a.count(')')
hashs = a.count('#')
last = need - (hashs - 1)
if last <= 0:
	print(-1)
	quit()
hashes = [i for i in range(len(a)) if a[i] == '#']
count = 0
for i in range(len(a)):
	if a[i] == '(':
		count += 1
	if a[i] == ')':
		count -= 1
	if a[i] == '#':
		if i == hashes[-1]:
			count -= last
		else:
			count -= 1
	if count < 0:
		print(-1)
		quit()
for i in range(hashs - 1):
	print(1)
print(last)


from sys import maxsize, stdout, stdin, stderr
mod = int(1000000000.0 + 7)
import sys

def I():
	return int(stdin.readline())

def lint():
	return [int(x) for x in stdin.readline().split()]

def S():
	return list(map(str, input().strip()))

def grid(r, c):
	return [lint() for i in range(r)]
from collections import defaultdict, Counter, deque
import math
import heapq
from heapq import heappop, heappush
import bisect
from itertools import groupby
from itertools import permutations as comb

def gcd(a, b):
	while b:
		a %= b
		tmp = a
		a = b
		b = tmp
	return a

def lcm(a, b):
	return a // gcd(a, b) * b

def check_prime(n):
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def nCr(n, r):
	return fact(n) // (fact(r) * fact(n - r))

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i
	return res

def primefactors(n):
	num = 0
	while n % 2 == 0:
		num += 1
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			num += 1
			n = n // i
	if n > 2:
		num += 1
	return num

def ask(a):
	print('? {}'.format(a), flush=True)
	n = I()
	return n

def dfs(i, p):
	(a, tmp) = (0, 0)
	for j in d[i]:
		if j != p:
			a += 1
			tmp += dfs(j, i)
	if a == 0:
		return 0
	return tmp / a + 1

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n // i
	if n > 2:
		l.append(n)
	return l
s = S()
d = Counter(s)
a = 0
cnt = d['#']
ans = []
for i in range(len(s)):
	if s[i] == '(':
		a += 1
	elif s[i] == ')':
		a -= 1
	else:
		a -= 1
		ans.append(1)
	if a < 0:
		ans.append(-1)
		break
if ans[-1] == -1:
	print(-1)
else:
	ans[-1] += a
	j = 0
	a = 0
	f = True
	for i in range(len(s)):
		if s[i] == '(':
			a += 1
		elif s[i] == ')':
			a -= 1
		else:
			a -= ans[j]
			j += 1
		if a < 0:
			f = False
			break
	if f:
		for i in ans:
			print(i)
	else:
		print(-1)


x = input()
c = 0
d = 0
for i in x:
	if i == '(':
		c += 1
	if i == ')':
		c -= 1
	if i == '#':
		d += 1
if c <= 0 or d > c:
	print(-1)
else:
	y = 0
	flag = True
	dd = d
	cc = c
	for i in x:
		if y < 0:
			flag = False
			break
		if i == '(':
			y += 1
		if i == ')':
			y -= 1
		if i == '#':
			if dd > 1:
				dd -= 1
				cc -= 1
				y -= 1
			else:
				y -= cc
	if flag:
		while d > 1:
			print(1)
			d -= 1
			c -= 1
		print(c)
	else:
		print(-1)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	s = si()
	n = len(s)
	f = 1
	x = 0
	y = 0
	for i in range(n):
		if s[i] == '(':
			x += 1
		else:
			y += 1
		if y > x:
			print(-1)
			return
	pos = -1
	for i in range(n - 1, -1, -1):
		if s[i] == '#':
			pos = i
			break
	add = x - y
	x = 0
	y = 0
	for i in range(n):
		if s[i] == '(':
			x += 1
		elif pos == i:
			y += 1 + add
		else:
			y += 1
		if y > x:
			print(-1)
			return
	for i in range(n):
		if s[i] == '#':
			if i == pos:
				print(1 + add)
			else:
				print(1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()