Having stayed home alone, Petya decided to watch forbidden films on the Net in secret. "What ungentlemanly behavior!" — you can say that, of course, but don't be too harsh on the kid. In his country films about the Martians and other extraterrestrial civilizations are forbidden. It was very unfair to Petya as he adored adventure stories that featured lasers and robots. 

Today Petya is watching a shocking blockbuster about the Martians called "R2:D2". What can "R2:D2" possibly mean? It might be the Martian time represented in the Martian numeral system. Petya knows that time on Mars is counted just like on the Earth (that is, there are 24 hours and each hour has 60 minutes). The time is written as "a:b", where the string a stands for the number of hours (from 0 to 23 inclusive), and string b stands for the number of minutes (from 0 to 59 inclusive). The only thing Petya doesn't know is in what numeral system the Martian time is written.

Your task is to print the radixes of all numeral system which can contain the time "a:b".

Input

The first line contains a single string as "a:b" (without the quotes). There a is a non-empty string, consisting of numbers and uppercase Latin letters. String a shows the number of hours. String b is a non-empty string that consists of numbers and uppercase Latin letters. String b shows the number of minutes. The lengths of strings a and b are from 1 to 5 characters, inclusive. Please note that strings a and b can have leading zeroes that do not influence the result in any way (for example, string "008:1" in decimal notation denotes correctly written time).

We consider characters 0, 1, ..., 9 as denoting the corresponding digits of the number's representation in some numeral system, and characters A, B, ..., Z correspond to numbers 10, 11, ..., 35.

Output

Print the radixes of the numeral systems that can represent the time "a:b" in the increasing order. Separate the numbers with spaces or line breaks. If there is no numeral system that can represent time "a:b", print the single integer 0. If there are infinitely many numeral systems that can represent the time "a:b", print the single integer -1.

Note that on Mars any positional numeral systems with positive radix strictly larger than one are possible.

Examples

Input

11:20


Output

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

Input

2A:13


Output

0


Input

000B:00001


Output

-1

Note

Let's consider the first sample. String "11:20" can be perceived, for example, as time 4:6, represented in the ternary numeral system or as time 17:32 in hexadecimal system. 

Let's consider the second sample test. String "2A:13" can't be perceived as correct time in any notation. For example, let's take the base-11 numeral notation. There the given string represents time 32:14 that isn't a correct time.

Let's consider the third sample. String "000B:00001" can be perceived as a correct time in the infinite number of numeral systems. If you need an example, you can take any numeral system with radix no less than 12.

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Implementation


Solutions:
s = input()
a = s[:s.index(':')]
b = s[s.index(':') + 1:]
a2 = ''
b2 = ''
found = False
for i in a:
	if i != '0':
		found = True
	if found:
		a2 += i
found = False
for i in b:
	if i != '0':
		found = True
	if found:
		b2 += i
a = a2
b = b2
apos = []
bpos = []
values = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
for i in a:
	apos.append(values.index(i))
for i in b:
	bpos.append(values.index(i))
if len(apos) == 0:
	apos.append(0)
if len(bpos) == 0:
	bpos.append(0)
minradix = max(max(apos), max(bpos))
results = []
for i in range(minradix + 1, 60):
	aresult = 0
	bresult = 0
	for j in range(len(apos)):
		aresult += apos[j] * i ** (len(apos) - j - 1)
	for j in range(len(bpos)):
		bresult += bpos[j] * i ** (len(bpos) - j - 1)
	if aresult <= 23 and bresult <= 59:
		results.append(i)
if len(a) == 1 and len(b) == 1 and (values.index(a) <= 23) and (values.index(b) <= 59):
	print(-1)
elif len(results) == 0:
	print(0)
elif apos == [0] and bpos == [0]:
	print(-1)
elif len(a) == 0 and len(b) == 1 and (values.index(b) <= 59):
	print(-1)
elif len(b) == 0 and len(a) == 1 and (values.index(a) <= 23):
	print(-1)
else:
	print(' '.join(list(map(str, results))))


def val(c):
	if 'A' <= c <= 'Z':
		return ord(c) - 65 + 10
	else:
		return int(c)

def calc(h, b):
	ans = 0
	i = 0
	for c in h[::-1]:
		v = val(c)
		ans += int(v) * b ** i
		i += 1
	return ans
(h, m) = [x for x in input().split(':')]
min_base = -1
for c in h:
	min_base = max(min_base, val(c) + 1)
for c in m:
	min_base = max(min_base, val(c) + 1)
answers = []
while True:
	hour = calc(h, min_base)
	min = calc(m, min_base)
	if hour > 23 or min > 59 or min_base > 60:
		break
	else:
		answers.append(min_base)
	min_base += 1
if len(answers) == 0:
	print(0)
elif min_base > 60:
	print(-1)
else:
	print(*answers)


import string
import re
values = {str(d): d for d in range(10)}
for ch in string.ascii_uppercase:
	values[ch] = ord(ch) - 55

def convert(s, i):
	x = 0
	for ch in s:
		d = values[ch]
		if d >= i:
			return None
		x = i * x + d
	return x
match = re.match('0*(\\w+):0*(\\w+)', input().strip())
(a, b) = match.groups([1, 2])
ans = []
for i in range(2, 60):
	h = convert(a, i)
	m = convert(b, i)
	if h == None or m == None:
		continue
	if h < 24 and m < 60:
		ans.append(i)
if len(ans) == 0:
	print(0)
elif len(a) + len(b) == 2:
	print(-1)
else:
	print(*ans)


a = {}
for x in range(10):
	a[str(x)] = x
for x in range(26):
	a[chr(ord('A') + x)] = 10 + x

def to10(s, n):
	y = 0
	for c in s:
		if a[c] >= n:
			return None
		y = y * n + a[c]
	return y
(h, m) = input().split(':')
ans = []
for i in range(2, 60):
	(h1, m1) = (to10(h, i), to10(m, i))
	if h1 == None or m1 == None:
		continue
	if h1 < 24 and m1 < 60:
		ans.append(i)
if len(ans) == 0:
	print(0)
else:
	(h2, m2) = (to10(h, 100), to10(m, 100))
	if h2 < 24 and m2 < 60:
		print(-1)
	else:
		print(*ans)


numbers = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'A': 10, 'B': 11, 'C': 12, 'D': 13, 'E': 14, 'F': 15, 'G': 16, 'H': 17, 'I': 18, 'J': 19, 'K': 20, 'L': 21, 'M': 22, 'N': 23, 'O': 24, 'P': 25, 'Q': 26, 'R': 27, 'S': 28, 'T': 29, 'U': 30, 'V': 31, 'W': 32, 'X': 33, 'Y': 34, 'Z': 35}

def ConvertToDecimal(number, base):
	newnumber = 0
	for digit in range(-1, 0 - len(number) - 1, -1):
		if numbers[number[digit]] >= int(base):
			return -1
		newnumber += numbers[number[digit]] * int(base) ** (0 - digit - 1)
	return newnumber
(a, b) = [x for x in input().split(':')]
didmake = False
if 0 <= ConvertToDecimal(a, 60) <= 23 and 0 <= ConvertToDecimal(b, 60) <= 59:
	print(-1)
	didmake = True
else:
	for base in range(2, 60):
		if 0 <= ConvertToDecimal(a, base) <= 23 and 0 <= ConvertToDecimal(b, base) <= 59:
			print(base, end=' ')
			didmake = True
if not didmake:
	print(0)


def getValue(c):
	res = ord(c) - ord('0')
	if res > 16:
		res -= 7
	return res

def getNumber(base, a, b):
	(hours, minutes) = (0, 0)
	ii = 0
	for i in range(len(a) - 1, -1, -1):
		hours += getValue(a[i]) * pow(base, ii)
		ii += 1
	if hours > 23:
		return (-1, -1)
	ii = 0
	for i in range(len(b) - 1, -1, -1):
		minutes += getValue(b[i]) * pow(base, ii)
		ii += 1
	if minutes > 59:
		return (-1, -1)
	return (hours, minutes)

def getBase(a, b):
	base = 0
	for i in range(len(a)):
		base = max(base, getValue(a[i]))
	for i in range(len(b)):
		base = max(base, getValue(b[i]))
	return base + 1
(a, b) = input().split(':')
res = []
inf = 0
(lastHours, lastMinutes) = (-1, -1)
base = getBase(a, b)
while True:
	(hours, minutes) = getNumber(base, a, b)
	if hours == -1 and minutes == -1:
		break
	if hours == lastHours and minutes == lastMinutes:
		inf = 1
		break
	res.append(base)
	(lastHours, lastMinutes) = (hours, minutes)
	base += 1
if inf == 1:
	print(-1)
elif len(res) == 0:
	print(0)
else:
	print(' '.join((str(x) for x in res)))


def s():
	a = [[ord(i) - 48 if ord(i) < 60 else ord(i) - 55 for i in i] for i in input().split(':')]
	r = [i for i in range(max(max(a[0]), max(a[1])) + 1, 61) if sum(list((i ** l[0] * l[1] for l in enumerate(reversed(a[0]))))) < 24 and sum(list((i ** l[0] * l[1] for l in enumerate(reversed(a[1]))))) < 60]
	if len(r) == 0:
		print(0)
	elif r[-1] == 60:
		print(-1)
	else:
		print(*r)
s()


def conv(s, base):
	ans = 0
	for (index, i) in enumerate(reversed(s)):
		val = int(i, 36)
		ans += base ** index * val
	return ans

def valid(base, h, m):
	hours = conv(h, base)
	mint = conv(m, base)
	if 0 <= hours < 24 and 0 <= mint < 60:
		return True
	else:
		return False
(h, m) = input().split(':')
hl = sorted(list(h))
ml = sorted(list(m))
hm = hl[-1]
mm = ml[-1]
if ord(hm) < ord('A'):
	minbaseh = ord(hm) - ord('0') + 1
else:
	minbaseh = 11 + ord(hm) - ord('A')
if ord(mm) < ord('A'):
	minbasem = ord(mm) - ord('0') + 1
else:
	minbasem = 11 + ord(mm) - ord('A')
minbase = max(minbasem, minbaseh)
firstInval = 0
found = False
lo = minbase
hi = 60
while lo <= hi:
	mid = lo + (hi - lo) // 2
	if not valid(mid, h, m):
		firstInval = mid
		hi = mid - 1
		found = True
	else:
		lo = mid + 1
if not found:
	print(-1)
elif firstInval == minbase:
	print(0)
else:
	for i in range(minbase, firstInval):
		print(i, end=' ')


def toi(t, b):
	res = 0
	for i in t:
		if i >= b:
			return -1
		res = b * res + i
	return res

def valid(h, m, b):
	return toi(h, b) in range(24) and toi(m, b) in range(60)
(h, m) = input().split(':')
h = [int(ch, 36) for ch in h]
m = [int(ch, 36) for ch in m]
if valid(h, m, 61):
	print('-1')
	exit()
res = [str(i) for i in range(2, 61) if valid(h, m, i)]
if res:
	print(*res)
else:
	print(0)


chns = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
mp = {}
for (ind, i) in enumerate(chns):
	mp[i] = nums[ind]
ans = []
(h, m) = input().split(':')
minsys = max([mp[i] for i in h + m]) + 1
for sys in range(minsys, 101):
	h10 = 0
	for (pw, i) in enumerate(reversed(h)):
		h10 += sys ** pw * mp[i]
	m10 = 0
	for (pw, i) in enumerate(reversed(m)):
		m10 += sys ** pw * mp[i]
	if h10 <= 23 and h10 >= 0 and (m10 <= 59) and (m10 >= 0):
		ans.append(sys)
if 100 in ans:
	print(-1)
	quit()
if len(ans) == 0:
	print(0)
	quit()
for i in ans:
	print(i, end=' ')


def toi(t, b):
	v = 0
	for ti in t:
		if ti >= b:
			return -1
		v = b * v + ti
	return v

def t(h, m, b):
	return toi(h, b) in range(24) and toi(m, b) in range(60)
(h, m) = ([int(ch, 36) for ch in x] for x in input().split(':'))
if t(h, m, 61):
	print('-1')
else:
	v = [str(i) for i in range(2, 61) if t(h, m, i)]
	print(' '.join(v) if v else '0')


def f(x, k):
	if 1 < k < 37:
		return int(x, k)
	s = 0
	for i in x:
		s = s * k
		s += int(i, 36)
	return s
(hours, minutes) = input().split(':')
i = j = k = max(int(max(hours), 36), int(max(minutes), 36)) + 1
(x, y) = (f(hours, k) == f(hours, k + 1), f(minutes, k) == f(minutes, k + 1))
if x and y:
	print(-1 if hours[-1] < 'O' else 0)
else:
	if x:
		i = 61
	else:
		while f(hours, i) < 24:
			i += 1
	if y:
		j = i
	else:
		while j < i and f(minutes, j) < 60:
			j += 1
	print(' '.join(map(str, range(k, j))) if k < j else 0)


import os
import sys
import math
from io import BytesIO, IOBase
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')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(a, b) = input().split(':')
a = list(a)
b = list(b)
c = 10
for i in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
	for j in range(len(a)):
		if a[j] == i:
			a[j] = c
	for j in range(len(b)):
		if b[j] == i:
			b[j] = c
	c += 1
a = list(map(int, a))
b = list(map(int, b))
ans = []
for c in range(2, 200):
	x1 = 0
	x2 = 0
	for p in range(len(a)):
		x1 += a[p] * c ** (len(a) - p - 1)
	for p in range(len(b)):
		x2 += b[p] * c ** (len(b) - p - 1)
	if 0 <= x1 <= 23 and 0 <= x2 <= 59 and (max(a) < c) and (max(b) < c):
		ans.append(c)
if len(ans) > 100:
	print(-1)
elif ans:
	print(*ans)
else:
	print(0)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log, pi, sin
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
s = data()
(a, b) = s.split(':')
start = 1
for i in a:
	if i.isalpha():
		temp = ord(i) - 65 + 10
	else:
		temp = int(i)
	start = max(temp, start)
for i in b:
	if i.isalpha():
		temp = ord(i) - 65 + 10
	else:
		temp = int(i)
	start = max(temp, start)
time = set()
answer = []
for base in range(start + 1, 1001):
	hour = 0
	for i in range(len(a) - 1, -1, -1):
		if a[i].isalpha():
			temp = ord(a[i]) - 65 + 10
		else:
			temp = int(a[i])
		hour += temp * pow(base, len(a) - i - 1)
	if hour > 23:
		continue
	minute = 0
	for i in range(len(b) - 1, -1, -1):
		if b[i].isalpha():
			temp = ord(b[i]) - 65 + 10
		else:
			temp = int(b[i])
		minute += temp * pow(base, len(b) - i - 1)
	if minute > 59:
		continue
	temp = str(hour) + ':' + str(minute)
	if temp in time:
		out(-1)
		exit()
	answer.append(base)
	time.add(temp)
if not answer:
	out(0)
	exit()
out(*answer)


import sys
(s1, s2) = input().split(':')

def convert(n, base):
	ans = 0
	for i in range(len(n)):
		x = 0
		if n[i].isalpha():
			x = int(ord(n[i]) - ord('A') + 10)
		else:
			x = int(n[i])
		ans += x * pow(base, len(n) - i - 1)
	return ans
work = []
minm = 0
for c in s1 + s2:
	if c.isalpha():
		minm = max(minm, ord(c) - ord('A') + 10)
	else:
		minm = max(minm, int(c))
for base in range(max(minm + 1, 2), 60):
	if convert(s1, base) < 24 and convert(s2, base) < 60:
		work.append(base)
	else:
		break
if len(work) == 0:
	print(0)
elif (len(s1) == 1 or s1[:len(s1) - 1] == '0' * (len(s1) - 1)) and (len(s2) == 1 or s2[:len(s2) - 1] == '0' * (len(s2) - 1)):
	print(-1)
else:
	print(' '.join(map(str, work)))


(a, b) = input().split(':')
z = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
c = [z.find(i) for i in a]
d = [z.find(i) for i in b]
for i in range(len(c)):
	if c[i] > 0:
		break
c = c[i:]
for i in range(len(d)):
	if d[i] > 0:
		break
d = d[i:]
if int(a, base=max(*c + [1]) + 1) > 23 or int(b, base=max(*d + [1]) + 1) > 59:
	print(0)
elif len(c) == len(d) == 1:
	print(-1)
else:
	for i in range(max(*d + c) + 1, 61):
		e = 0
		for j in range(len(c)):
			e += i ** j * c[-1 - j]
		f = 0
		for j in range(len(d)):
			f += i ** j * d[-1 - j]
		if 0 <= e <= 23 and 0 <= f <= 59:
			print(i, end=' ')


(a, b) = input().split(':')
a = list(a)
b = list(b)
c = 10
for i in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
	for j in range(len(a)):
		if a[j] == i:
			a[j] = c
	for j in range(len(b)):
		if b[j] == i:
			b[j] = c
	c += 1
a = list(map(int, a))
b = list(map(int, b))
ans = []
for c in range(2, 200):
	x1 = 0
	x2 = 0
	for p in range(len(a)):
		x1 += a[p] * c ** (len(a) - p - 1)
	for p in range(len(b)):
		x2 += b[p] * c ** (len(b) - p - 1)
	if 0 <= x1 <= 23 and 0 <= x2 <= 59 and (max(a) < c) and (max(b) < c):
		ans.append(c)
if len(ans) > 100:
	print(-1)
elif ans:
	print(*ans)
else:
	print(0)


time = input()
hour = time.split(':')[0]
minute = time.split(':')[1]
minBase = 0

def charToVal(x):
	if ord(x) < 58:
		return ord(x) - 48
	else:
		return ord(x) - 55
for x in hour:
	if ord(x) < 58:
		minBase = max(minBase, ord(x) - 47)
	else:
		minBase = max(minBase, ord(x) - 54)
for x in minute:
	if ord(x) < 58:
		minBase = max(minBase, ord(x) - 47)
	else:
		minBase = max(minBase, ord(x) - 54)
solutions = []
for base in range(minBase, 62):
	multiple = 1
	converted_hour = 0
	for x in range(len(hour) - 1, -1, -1):
		converted_hour += multiple * charToVal(hour[x])
		multiple *= base
	if converted_hour >= 24:
		break
	multiple = 1
	converted_minute = 0
	for x in range(len(minute) - 1, -1, -1):
		converted_minute += multiple * charToVal(minute[x])
		multiple *= base
	if converted_minute >= 60:
		break
	solutions.append(base)
if 61 in solutions:
	print(-1)
elif len(solutions) == 0:
	print(0)
else:
	for x in solutions:
		print(x, end=' ')


from sys import setrecursionlimit, exit, stdin
from math import ceil, floor, acos, pi
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from functools import reduce
import itertools
setrecursionlimit(10 ** 7)
RI = lambda x=' ': list(map(int, input().split(x)))
RS = lambda x=' ': input().rstrip().split(x)
dX = [-1, 1, 0, 0, -1, 1, -1, 1]
dY = [0, 0, -1, 1, 1, -1, -1, 1]
mod = int(1000000000.0 + 7)
eps = 1e-06
MAX = 1000

def to_base(s, b):
	if not s:
		return 0
	v = int(s[-1], 36)
	if v >= b:
		return MAX
	return v + to_base(s[:-1], b) * b
(h, m) = RS(':')
ans = []
for b in range(100):
	if to_base(h, b) < 24 and to_base(m, b) < 60:
		ans.append(b)
if not ans:
	print(0)
elif ans[-1] == 99:
	print(-1)
else:
	print(*ans)


def base(t, b):
	num = 0
	p = 1
	i = len(t) - 1
	v = 0
	while i >= 0:
		if t[i].isdigit():
			v = int(t[i])
		else:
			v = ord(t[i]) - 55
		if v >= b:
			return -1
		num = num + v * p
		p = p * b
		i = i - 1
	return num

def remove_zeros(s):
	i = 0
	res = ''
	while i < len(s) and s[i] == '0':
		i = i + 1
	while i < len(s):
		res = res + s[i]
		i = i + 1
	if res == '':
		res = '0'
	return res
s = input().split(':')
num = []
for i in range(2):
	s[i] = remove_zeros(s[i])
for i in range(2, 61):
	a = base(s[0], i)
	b = base(s[1], i)
	if a >= 0 and a <= 23 and (b >= 0) and (b <= 59):
		num.append(i)
if len(num) == 0:
	print(0)
elif 60 in num:
	print(-1)
else:
	for x in num:
		print(x)


s = input()
s = s.split(':')
h = s[0]
m = s[1]
h = h[::-1]
m = m[::-1]
mi = 0

def eval(s, x):
	su = 0
	j = 0
	for i in s:
		if ord(i) >= ord('0') and ord(i) <= ord('9'):
			su = su + x ** j * (ord(i) - 48)
		else:
			su = su + x ** j * (ord(i) - 55)
		j += 1
	return su
for i in h + m:
	if ord(i) >= ord('0') and ord(i) <= ord('9'):
		mi = max(mi, ord(i) - 48)
	else:
		mi = max(mi, ord(i) - 55)
mi += 1
mi = max(2, mi)
x = mi
if eval(h, x) > 23 or eval(m, x) > 59:
	print(0)
elif eval(h, x) == eval(h, x + 1) and eval(m, x) == eval(m, x + 1):
	print(-1)
else:
	while 1:
		if eval(h, x) <= 23 and eval(m, x) <= 59:
			x += 1
		else:
			break
	if mi == x:
		print(0)
	for i in range(mi, x):
		print(i, end=' ')
	print('')