Golorps are mysterious creatures who feed on variables. Golorp's name is a program in some programming language. Some scientists believe that this language is Befunge; golorps are tantalizingly silent.

Variables consumed by golorps can take values from 0 to 9, inclusive. For each golorp its daily diet is defined by its name. Some golorps are so picky that they can't be fed at all. Besides, all golorps are very health-conscious and try to eat as little as possible. Given a choice of several valid sequences of variable values, each golorp will choose lexicographically smallest one.

For the purposes of this problem you can assume that a golorp consists of jaws and a stomach. The number of variables necessary to feed a golorp is defined by the shape of its jaws. Variables can get to the stomach only via the jaws.

A hungry golorp is visiting you. You know its name; feed it or figure out that it's impossible.


-----Input-----

The input is a single string (between 13 and 1024 characters long) — the name of the visiting golorp. All names are similar and will resemble the ones given in the samples. The name is guaranteed to be valid.


-----Output-----

Output lexicographically smallest sequence of variable values fit for feeding this golorp. Values should be listed in the order in which they get into the jaws. If the golorp is impossible to feed, output "false".


-----Examples-----
Input
?(_-_/___*__):-___>__.

Output
0010

Input
?(__-_+_/_____):-__>__,_____<__.

Output
false

Input
?(______________________/____+_______*__-_____*______-___):-__<___,___<____,____<_____,_____<______,______<_______.

Output
0250341

Input
?(__+___+__-___):-___>__.

Output
0101

Source: codeforces | Difficulty: VERY_HARD


Solutions:
import re
line = input()
line = line.rstrip('.')
(a, b, c) = line.partition('):-')
rels = c.split(',')
relations = set()
for rel in rels:
	if '<' in rel:
		(x, _, y) = rel.partition('<')
		relations.add((len(x), len(y)))
	else:
		(x, _, y) = rel.partition('>')
		relations.add((len(y), len(x)))
a = a.lstrip('?(')
args = re.split('(\\+|-|\\*|/)', a)
args = [len(args[i]) for i in range(0, len(args), 2)]
edges = {k: [] for k in args}
for (j, i) in relations:
	edges[i].append(j)
seen = {k: 0 for k in args}
q = []

def topsort(k):
	if seen[k] == 1:
		print('false')
		quit()
	seen[k] = 1
	for other in edges[k]:
		topsort(other)
	q.append(k)
	seen[k] = 2
	return True
for k in args:
	if seen[k] == 0:
		topsort(k)
vals = {}
for k in q:
	others = edges[k]
	maxval = -1
	for other in others:
		maxval = max(maxval, vals.get(other, -1))
	vals[k] = maxval + 1
	if vals[k] > 9:
		print('false')
		quit()
for k in args:
	print(vals[k], end='')
print()


class InputHandlerObject(object):
	inputs = []

	def getInput(self, n=0):
		res = ''
		inputs = self.inputs
		if not inputs:
			inputs.extend(input().split(' '))
		if n == 0:
			res = inputs[:]
			inputs[:] = []
		while n > len(inputs):
			inputs.extend(input().split(' '))
		if n > 0:
			res = inputs[:n]
			inputs[:n] = []
		return res
InputHandler = InputHandlerObject()
g = InputHandler.getInput
golorp = input().split(':-')
golorp[0] = golorp[0][2:]
ct = 0
jaws = []
for x in range(len(golorp[0])):
	if golorp[0][x] == '_':
		ct += 1
	else:
		jaws.append(ct)
		ct = 0
ct = 0
conditionsraw = []
for x in range(len(golorp[1])):
	if golorp[1][x] == '_':
		ct += 1
	else:
		conditionsraw.append(ct)
		conditionsraw.append(golorp[1][x])
		ct = 0
conditions = []
for x in range(0, len(conditionsraw) // 4):
	if conditionsraw[4 * x + 1] == '>':
		conditions.append((conditionsraw[4 * x + 2], conditionsraw[4 * x]))
	else:
		conditions.append((conditionsraw[4 * x], conditionsraw[4 * x + 2]))
inedges = [[-1]] * (max(jaws) + 1)
outedges = [[-1]] * (max(jaws) + 1)
val = [-1] * (max(jaws) + 1)
processed = [False] * (max(jaws) + 1)
for x in jaws:
	inedges[x] = []
	outedges[x] = []
for (x, y) in conditions:
	inedges[y].append(x)
	outedges[x].append(y)
for i in range(10):
	for x in jaws:
		if not inedges[x] and (not processed[x]):
			val[x] += 1
			processed[x] = True
			for y in outedges[x]:
				val[y] = max(val[y], val[x])
				inedges[y].remove(x)
failure = False
for x in jaws:
	if not processed[x] or val[x] > 9:
		failure = True
		break
if failure:
	print('false')
else:
	s = ''
	for x in jaws:
		s += str(val[x])
	print(s)