Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.

Reliable sources have informed the financier Anton of some information about the exchange rate of currency you all know against the burle for tomorrow. Now Anton knows that tomorrow the exchange rate will be an even number, which can be obtained from the present rate by swapping exactly two distinct digits in it. Of all the possible values that meet these conditions, the exchange rate for tomorrow will be the maximum possible. It is guaranteed that today the exchange rate is an odd positive integer n. Help Anton to determine the exchange rate of currency you all know for tomorrow!


-----Input-----

The first line contains an odd positive integer n — the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 10^5, inclusive. The representation of n doesn't contain any leading zeroes.


-----Output-----

If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1.

Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from today's exchange rate by swapping exactly two digits. Exchange rate representation should not contain leading zeroes.


-----Examples-----
Input
527

Output
572

Input
4573

Output
3574

Input
1357997531

Output
-1

Source: codeforces | Difficulty: EASY
Tags: String algorithms

Mathematics

Greedy algorithms


Solutions:
n = str(input())
maxium = -1
lastInArr = int(n[-1])
for (x, y) in enumerate(n):
	if int(y) % 2 == 0:
		maxium = x
		if int(y) < lastInArr:
			break
if maxium == -1:
	print(-1)
else:
	print(n[:maxium] + n[-1] + n[maxium + 1:-1] + n[maxium])


R1 = lambda : list(map(int, input().split()))
R2 = lambda : int(input())
R3 = lambda : list(input())
R4 = lambda : list(map(int, input()))
A = R3()
n = len(A)
c = int(A[n - 1])
m = -1
for i in range(n):
	e = int(A[i])
	if e % 2 == 0:
		if e <= c:
			(A[i], A[n - 1]) = (A[n - 1], A[i])
			print(''.join(A))
			break
		m = i
else:
	if m == -1:
		print(-1)
	else:
		(A[m], A[n - 1]) = (A[n - 1], A[m])
		print(''.join(A))


import sys
import math
s = input()
s = list(s)
for i in range(len(s)):
	if int(s[i]) % 2 == 0 and s[i] < s[-1]:
		(s[i], s[-1]) = (s[-1], s[i])
		print(''.join(s))
		exit()
for i in range(len(s) - 1, -1, -1):
	if int(s[i]) % 2 == 0:
		(s[i], s[-1]) = (s[-1], s[i])
		print(''.join(s))
		exit()
print(-1)


from functools import reduce
l = list(input())
yo = -10
for (i, d) in enumerate(l):
	if int(d) % 2 == 0 and int(l[-1]) > int(d):
		yo = i
		break
	elif int(d) % 2 == 0 and int(l[-1]) < int(d):
		yo = i
if yo >= 0:
	(l[-1], l[yo]) = (l[yo], l[-1])
	print(''.join(l))
else:
	print(-1)


def main():
	n = input()
	l = len(n)
	ans = -1
	m = -1
	for i in range(l):
		if int(n[i]) % 2 == 0:
			ans = i
			if int(n[l - 1]) > int(n[i]):
				m = i
				break
	if ans == -1:
		print(-1)
	else:
		if m != -1:
			ans = m
		k = list(n)
		(k[l - 1], k[ans]) = (k[ans], k[l - 1])
		print(''.join(k))
main()


l = list(input())
n = len(l)
r = int(l[-1])
flag = 0
m = -1
for i in range(n):
	if int(l[i]) % 2 == 0:
		m = i
		if r > int(l[i]):
			(l[-1], l[i]) = (l[i], l[-1])
			flag = 1
			break
if flag:
	k = ''
	for i in range(n):
		k += l[i]
	print(k)
elif m != -1:
	(l[-1], l[m]) = (l[m], l[-1])
	k = ''
	for i in range(n):
		k += l[i]
	print(k)
else:
	print(-1)


s = input().strip()
s = list(s)
found = False
for i in range(len(s) - 1):
	if int(s[i]) % 2 == 0 and int(s[i]) < int(s[-1]):
		found = True
		(s[i], s[-1]) = (s[-1], s[i])
		break
if found:
	print(''.join(s))
else:
	for i in range(len(s) - 2, -1, -1):
		if int(s[i]) % 2 == 0:
			found = True
			(s[i], s[-1]) = (s[-1], s[i])
			break
	if found:
		print(''.join(s))
	else:
		print(-1)


n = list(input())
k = [int(x) for x in n]
prev = -1
odd = k[-1]
flag = 1
for i in range(len(k)):
	if k[i] % 2 == 0:
		if k[i] < odd:
			(k[i], k[-1]) = (odd, k[i])
			flag = 0
			break
		else:
			prev = i
if prev != -1 and flag:
	(k[prev], k[-1]) = (odd, k[prev])
	flag = 0
if flag:
	print(-1)
else:
	for i in k:
		print(i, end='')


n = input()
last = int(n[-1])
for i in range(len(n) - 1):
	curr = int(n[i])
	if curr % 2 == 0 and curr < last:
		print(n[:i] + n[-1] + n[i + 1:-1] + n[i])
		exit()
for i in range(len(n) - 2, -1, -1):
	curr = int(n[i])
	if curr % 2 == 0 and curr > last:
		print(n[:i] + n[-1] + n[i + 1:-1] + n[i])
		exit()
print(-1)


import os
import sys
from io import BytesIO, IOBase
from functools import cmp_to_key

def main():
	a = list(map(int, list(input())))
	eves = []
	ans = -1
	l = -1
	chk = 0
	for x in range(len(a)):
		if a[x] % 2 == 0:
			if a[-1] > a[x]:
				(a[-1], a[x]) = (a[x], a[-1])
				ans = ''.join(list(map(str, a)))
				chk = 1
				break
			else:
				l = x
	if chk == 1:
		print(ans)
	elif chk == 0 and l == -1:
		print(-1)
	else:
		(a[-1], a[l]) = (a[l], a[-1])
		ans = ''.join(list(map(str, a)))
		print(ans)
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')
main()


s = input()
last = int(s[-1])
changed = False
s = list(s)
for i in range(len(s) - 1):
	if int(s[i]) < last and int(s[i]) % 2 == 0:
		temp = s[i]
		s[i] = s[-1]
		s[-1] = temp
		changed = True
		break
if not changed:
	j = len(s) - 1
	while j >= 0:
		if int(s[j]) % 2 == 0:
			temp = s[j]
			s[j] = s[-1]
			s[-1] = temp
			changed = True
			break
		j -= 1
if changed:
	print(''.join(s))
else:
	print('-1')


s = list(input())
n = len(s)
c = -1
c1 = -1
m = 0
for i in range(n):
	m1 = m
	if int(s[i]) % 2 == 0:
		c = 1
		break
if c == -1:
	print(-1)
else:
	for i in range(n):
		if int(s[i]) < int(s[n - 1]) and int(s[i]) % 2 == 0:
			c1 = 1
			(s[n - 1], s[i]) = (s[i], s[n - 1])
			break
	if c1 == -1:
		for i in range(n - 2, -1, -1):
			if int(s[i]) > int(s[n - 1]) and int(s[i]) % 2 == 0:
				(s[n - 1], s[i]) = (s[i], s[n - 1])
				break
	print(''.join(s))


n = list(input())
last = n[-1]
tmp = None
for i in range(len(n)):
	if int(n[i]) % 2 == 0:
		if int(n[i]) < int(last):
			n[-1] = n[i]
			n[i] = last
			print(''.join(n))
			break
		else:
			tmp = i
else:
	if tmp is not None:
		n[-1] = n[tmp]
		n[tmp] = last
		print(''.join(n))
	else:
		print(-1)


n = list(input())
k = int(n[len(n) - 1])
m = 0
for i in range(len(n)):
	z = int(n[i])
	if z % 2 == 0:
		temp = i
		m = 1
		if z < k:
			break
if m == 0:
	print('-1')
else:
	(n[-1], n[temp]) = (n[temp], n[-1])
	print(''.join(n))


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def factorial(n):
	if n == 0:
		return 1
	return n * factorial(n - 1)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return len(set(factors))

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

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))
MOD = 10 ** 9 + 9
T = 1
for _ in range(T):
	s = str(stdin.readline().strip('\n'))
	n = len(s)
	pos = -1
	for i in range(n):
		if int(s[i]) % 2 == 0:
			pos = i
			if int(s[i]) < int(s[-1]):
				break
	if pos == -1:
		print(-1)
	else:
		print(s[:pos] + s[-1] + s[pos + 1:-1] + s[pos])


def f(a):
	found = False
	for i in range(len(a) - 1):
		if int(a[i]) % 2 == 0 and int(a[i]) < int(a[-1]):
			found = True
			(a[i], a[-1]) = (a[-1], a[i])
			break
	if found:
		return ''.join(a)
	for i in range(len(a) - 1, -1, -1):
		if int(a[i]) % 2 == 0:
			(a[i], a[-1]) = (a[-1], a[i])
			found = True
			break
	if found:
		return ''.join(a)
	else:
		return -1
s = input()
a = list(s)
print(f(a))


import math, sys
from collections import defaultdict, Counter, deque
INF = float('inf')

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

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

def primeFactors(n):
	factors = []
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors.append(i)
			n //= i
		i += 1
	if n > 1:
		factors.append(n)
	return factors

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))

def c(n, r):
	return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

def main():
	s = list(input())
	n = len(s)
	l = s[-1]
	prev = -1
	for i in range(n):
		if int(s[i]) % 2 == 0 and int(s[i]) < int(l):
			(s[i], s[-1]) = (s[-1], s[i])
			print(''.join(s))
			return
		elif int(s[i]) % 2 == 0:
			prev = i
	if prev == -1:
		print(-1)
	else:
		(s[prev], s[-1]) = (s[-1], s[prev])
		print(''.join(s))
t = 1
for _ in range(t):
	main()


s = input()
i = -1
for j in range(len(s)):
	if int(s[j]) % 2 == 0:
		if int(s[j]) > int(s[len(s) - 1]):
			i = j
		else:
			i = j
			break
if i == -1:
	print(-1)
else:
	print('{}{}{}{}'.format(s[:i], s[len(s) - 1], s[i + 1:len(s) - 1], s[i]))


def main():
	a = list(input())
	index = 0
	even = []
	for i in a:
		if int(i) % 2 == 0:
			even.append(index)
		index += 1
	k = -1
	for i in even:
		if a[-1] > a[i]:
			k = i
			break
		k = i
	if k == -1:
		print(-1)
	else:
		(a[-1], a[k]) = (a[k], a[-1])
		print(''.join(a))
main()


s = list(input())
d = int(s[-1])
last_pos = None
for (i, x) in enumerate(s[:-1]):
	if int(x) % 2 == 0:
		if int(x) < d:
			s[i] = str(d)
			s[-1] = x
			last_pos = None
			print(''.join(s))
			break
		elif int(x) != d:
			last_pos = i
else:
	if last_pos is None:
		print('-1')
	else:
		t = s[last_pos]
		s[last_pos] = s[-1]
		s[-1] = t
		print(''.join(s))


from itertools import permutations
n = list(input())
end = n[-1]
val = None
for i in range(len(n) - 1):
	if int(n[i]) % 2 == 0:
		if val is None:
			val = i
			if n[val] < end:
				break
		val = i
		if n[val] < end:
			break
if val is None:
	print(-1)
else:
	n[-1] = n[val]
	n[val] = end
	print(''.join(n))


n = input()
l = [int(i) for i in n]
count = 0
d = {'even': []}
for i in range(len(l)):
	if l[i] % 2 == 0:
		d['even'].append(i)
		count += 1
if count == 0:
	print(-1)
else:
	k = 0
	for i in d['even']:
		if l[i] < l[-1]:
			(l[i], l[-1]) = (l[-1], l[i])
			k += 1
			break
	if k == 0:
		(l[d['even'][-1]], l[-1]) = (l[-1], l[d['even'][-1]])
	for i in l:
		print(i, end='')


s = str(input())
k = 0
a = []
b = []
c = []
for i in range(len(s)):
	if int(s[i]) % 2 == 0:
		a += [i]
		b += [s[i]]
if len(a) == 0:
	print(-1)
else:
	j = s[len(s) - 1]
	for i in range(len(a)):
		if i == len(b) - 1:
			s1 = s[:a[i]] + j + s[a[i] + 1:]
			s1 = s1[:len(s1) - 1] + b[i]
			break
		elif int(b[i]) < int(j):
			s1 = s[:a[i]] + j + s[a[i] + 1:]
			s1 = s1[:len(s1) - 1] + b[i]
			break
	print(s1)


import sys
import math
import collections

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(1):
	n = list(input())
	even = 0
	for i in n:
		if int(i) % 2 == 0:
			even += 1
	if even == 0:
		print(-1)
		continue
	last = int(n[-1])
	c = 0
	for j in range(len(n)):
		i = n[j]
		if int(i) % 2 == 0:
			c += 1
			if int(i) < last:
				(n[j], n[-1]) = (n[-1], n[j])
				break
			elif c == even:
				(n[j], n[-1]) = (n[-1], n[j])
				break
			else:
				continue
	print(*n, sep='')


n = list(map(int, list(input())))
m = list(map(lambda x: int(x) % 2, n))
a = m.count(0)
if a == 0:
	print(-1)
else:
	f = 10000
	for i in range(len(n) - 1, -1, -1):
		if m[i] == 0:
			if n[i] < n[len(n) - 1] or f == 10000:
				f = i
	(n[len(n) - 1], n[f]) = (n[f], n[len(n) - 1])
	print(*n, sep='')


(n, pos) = (input(), -1)
for i in range(len(n) - 1):
	if n[i] in '02468':
		pos = i
		if n[i] < n[-1]:
			break
print(-1 if pos < 0 else n[:pos] + n[-1] + n[pos + 1:-1] + n[pos])


s = input()
last = s[len(s) - 1]
flag_find_odd = False
give_ans = False
if int(last) % 2 == 1:
	for i in range(len(s)):
		if int(s[i]) % 2 == 0:
			ans_else_1 = i
			flag_find_odd = True
		if (s[i] < last) & (int(s[i]) % 2 == 0):
			s = s[0:i] + last + s[i + 1:len(s) - 1] + s[i]
			give_ans = True
			break
	if flag_find_odd == False:
		s = -1
	elif give_ans == False:
		s = s[0:ans_else_1] + last + s[ans_else_1 + 1:len(s) - 1] + s[ans_else_1]
else:
	d = [dig for dig in s]
	d.sort()
	d.reverse()
	r = 0
	for i in range(len(s)):
		if s[i] != d[r]:
			ans_num = -1
			for j in range(i + 1, len(s)):
				if (s[j] == d[r]) & ((j != len(s) - 1) | (int(s[i]) % 2 == 0)):
					ans_num = j
			if not ans_num == -1:
				s = s[0:i] + s[ans_num] + s[i + 1:ans_num] + s[i] + s[ans_num + 1:]
				break
				break
		else:
			r += 1
print(s)


x = input()
x = list(x)
f = 1
for i in range(len(x)):
	if int(x[i]) % 2 == 0:
		a = i
		f = 0
		if int(x[i]) < int(x[len(x) - 1]):
			a = i
			f = 0
			break
if f == 0:
	(x[a], x[len(x) - 1]) = (x[len(x) - 1], x[a])
	print(''.join(x))
else:
	print('-1')


s = list(input())
even = 0
evenl = []
for i in range(len(s)):
	if int(s[i]) % 2 == 0:
		even += 1
		evenl.append(i)
if even == 0:
	print('-1')
	exit(0)
elif int(s[0]) % 2 == 0 and int(s[0]) < int(s[-1]):
	(s[0], s[-1]) = (s[-1], s[0])
	print(''.join(s))
	exit(0)
else:
	f = False
	for i in range(len(s)):
		if int(s[i]) % 2 == 0 and int(s[i]) < int(s[-1]):
			(s[i], s[-1]) = (s[-1], s[i])
			f = True
			break
	if f:
		print(''.join(s))
	else:
		k = evenl[-1]
		(s[k], s[-1]) = (s[-1], s[k])
		print(''.join(s))


n = str(input())
v = [int(i) for i in n]
y = 1
for i in v:
	if i % 2 == 0:
		y = 0
if y:
	print(-1)
	exit()
for i in range(len(v)):
	if v[i] % 2 == 0 and v[i] < v[-1]:
		a = v[i]
		v[i] = v[-1]
		v[-1] = a
		print(''.join(map(str, v)))
		exit()
for i in range(len(v)):
	if v[-i - 1] % 2 == 0:
		a = v[-i - 1]
		v[-i - 1] = v[-1]
		v[-1] = a
		print(''.join(map(str, v)))
		exit()


n = input()
last_index = -1
for i in range(len(n)):
	if int(n[i]) % 2 == 0:
		if int(n[i]) < int(n[-1]):
			last_index = i
			break
		else:
			last_index = i
if last_index == -1:
	print(-1)
else:
	san = list(n)
	(san[last_index], san[-1]) = (san[-1], san[last_index])
	print(''.join(san))


import sys
n = list(map(int, input()))
lastResort = -1
lastDigit = n[-1]
for x in range(0, len(n)):
	if n[x] % 2 == 0:
		if n[x] < lastDigit:
			n[-1] = n[x]
			n[x] = lastDigit
			print(''.join([str(elm) for elm in n]))
			sys.exit(0)
		else:
			lastResort = x
if lastResort == -1:
	print(-1)
else:
	n[-1] = n[lastResort]
	n[lastResort] = lastDigit
	print(''.join([str(elm) for elm in n]))


str1 = input()
even = 0
epos = list()
for x in range(len(str1)):
	if int(str1[x]) % 2 == 0:
		even += 1
		epos.append(x)
odd = len(str1) - even
if even == 0:
	print('-1')
elif even == 1:
	ans = list()
	for x in range(len(str1) - 1):
		if x == epos[0]:
			ans.append(str1[len(str1) - 1])
		else:
			ans.append(str1[x])
	ans.append(str1[epos[0]])
	print(''.join(ans))
else:
	ans = list()
	spos = -1
	last = str1[len(str1) - 1]
	for x in epos:
		if last > str1[x]:
			spos = x
			break
	if spos == -1:
		spos = epos[len(epos) - 1]
	for x in range(len(str1) - 1):
		if x == spos:
			ans.append(last)
		else:
			ans.append(str1[x])
	ans.append(str1[spos])
	print(''.join(ans))


def solve(s):
	n = len(s)
	even = 0
	for x in s:
		if int(x) % 2 == 0:
			even += 1
	if even == 0:
		return -1
	last = int(s[-1])
	ind = -1
	res = ''
	for i in range(n):
		t = int(s[i])
		if t % 2 == 0:
			ind = i
			if t < last:
				res = s[:ind] + str(last) + s[ind + 1:n - 1] + s[ind]
				return res
	if ind == n - 1:
		return s
	res = s[:ind] + str(last) + s[ind + 1:n - 1] + s[ind]
	return res
s = input()
print(solve(s))


strs = str(input())
arr = []
detail = []
dicts = {}
last = int(strs[-1])
flag = 0
for (i, j) in enumerate(strs):
	v = int(j)
	if v & 1 == 0:
		if v not in dicts and v < last and (flag == 0):
			arr = []
			arr.append(i)
			flag = 1
		if flag != 1:
			dicts[v] = 1
			arr.append(i)
	detail.append(str(j))
nt = len(arr)
if len(arr) > 0:
	arr = arr[nt - 1:]
nlen = len(arr)
maxs = 0
if nlen == 0:
	print(-1)
elif nlen == 1:
	v = strs
	index = arr[0]
	lastdigit = v[-1]
	v = strs[:-1]
	v = v + detail[index]
	v = v[:index] + lastdigit + v[index + 1:]
	print(v)
else:
	for i in arr:
		v = strs
		index = i
		lastdigit = v[-1]
		v = strs[:-1]
		v = v + detail[index]
		v = v[:index] + lastdigit + v[index + 1:]
		kt = int(v)
		if kt > maxs:
			maxs = kt
	print(maxs)


def solve(num_str):
	arr = [int(x) for x in num_str]
	even_indices = [i for (i, x) in enumerate(arr) if x % 2 == 0]
	if len(even_indices) == 0:
		return '-1'
	for i in even_indices:
		if arr[i] < arr[-1]:
			(arr[i], arr[-1]) = (arr[-1], arr[i])
			return ''.join(map(str, arr))
	(arr[i], arr[-1]) = (arr[-1], arr[i])
	return ''.join(map(str, arr))

def test():
	assert solve('527') == '572'
	assert solve('4573') == '3574'
	assert solve('1357997531') == '-1'
test()
res = solve(input())
print(res)


n = input()
k = n[::-1]
otv = [None, None]
pr = int(k[0])
b = True
for (i, el) in enumerate(k):
	if int(el) % 2 == 0:
		if int(el) < pr:
			otv[0] = i
		elif b:
			b = False
			otv[1] = i
if otv[0] == None and otv[1] == None:
	print(-1)
elif otv[0] == None:
	k = list(k)
	(k[otv[1]], k[0]) = (k[0], k[otv[1]])
	k = ''.join(k)[::-1]
	print(k)
else:
	k = list(k)
	(k[otv[0]], k[0]) = (k[0], k[otv[0]])
	k = ''.join(k)[::-1]
	print(k)


n = input()
n = list(n)
ind = -1
ok = False
swapped = False
k = len(n)
for i in range(len(n)):
	if int(n[i]) % 2 == 0:
		ok = True
		if n[i] > n[k - 1]:
			ind = i
		if n[i] < n[k - 1]:
			(n[i], n[-1]) = (n[-1], n[i])
			swapped = True
			break
if ok:
	if not swapped:
		(n[ind], n[-1]) = (n[-1], n[ind])
	print(''.join(n))
else:
	print('-1')


l1 = list(input())
flag = 0
ans = 0
for i in range(len(l1) - 1):
	if int(l1[i]) % 2 == 0:
		if int(l1[i]) < int(l1[-1]):
			print(''.join(l1[:i]) + l1[-1] + ''.join(l1[i + 1:len(l1) - 1]) + l1[i])
			flag = 1
			break
if flag == 0:
	for i in range(len(l1) - 2, -1, -1):
		if int(l1[i]) % 2 == 0:
			print(''.join(l1[:i]) + l1[-1] + ''.join(l1[i + 1:len(l1) - 1]) + l1[i])
			flag = 1
			break
	if flag == 0:
		print(-1)


today = input()
todayLength = len(today) - 1
bestIndex = -1
for i in range(0, todayLength):
	calculableDigit = int(today[i])
	if calculableDigit % 2:
		continue
	if today[-1] > today[i]:
		bestIndex = i
		break
	else:
		bestIndex = i
if bestIndex > -1:
	todayList = list(today)
	(todayList[-1], todayList[bestIndex]) = (todayList[bestIndex], todayList[-1])
	print(''.join(todayList))
else:
	print(-1)


s = input()
n = len(s)
l = int(s[n - 1])
li = -1
ii = -1
for i in range(n - 1):
	if int(s[i]) % 2 == 0:
		li = i
		if int(s[i]) < int(s[n - 1]):
			ii = i
			break
if li == -1:
	print(li)
elif ii == -1:
	print(s[:li], s[n - 1], s[li + 1:n - 1], s[li], sep='')
else:
	print(s[:li], s[n - 1], s[li + 1:n - 1], s[ii], sep='')


n = list(map(str, input()))
a = int(n[-1])
aux = []
for i in range(len(n)):
	b = int(n[i])
	if b % 2 == 0:
		if a > b:
			n[i] = str(a)
			n[-1] = str(b)
			print(''.join(map(str, n)))
			exit(0)
		else:
			aux.append(i)
if len(aux) > 0:
	n[-1] = n[aux[-1]]
	n[aux[-1]] = str(a)
	print(''.join(map(str, n)))
	exit(0)
else:
	print(-1)


n = input()
n = [i for i in n]
f = -1
for i in range(len(n)):
	if int(n[i]) % 2 == 0:
		f = i
		if n[i] < n[-1]:
			break
if f == -1:
	print('-1')
else:
	y = n[f]
	n[f] = n[len(n) - 1]
	n[len(n) - 1] = y
	for i in n:
		print(i, end='')


l = list(input())
last = -1
odd = int(l[-1])
for i in range(len(l) - 1):
	x = int(l[i])
	if x % 2 == 0:
		last = i
		if x < odd:
			break
if last == -1:
	print(-1)
	exit()
(l[last], l[-1]) = (str(odd), l[last])
ans = ''.join(l)
print(ans)


x = list(input())
c = 0
f = 0
d = ''
for i in range(len(x)):
	if int(x[i]) % 2 == 0:
		c = 1
		f = i
		if int(x[i]) < int(x[-1]):
			z = x[i]
			x[i] = x[-1]
			x[-1] = z
			print(*x, sep='')
			break
else:
	if c == 0:
		print(-1)
	else:
		z = x[f]
		x[f] = x[-1]
		x[-1] = z
		print(*x, sep='')


n = input()
c = 0
d = []
for i in range(len(n)):
	if int(n[i]) % 2 == 0:
		d.append(int(n[i]))
		c += 1
if c == 0:
	print(-1)
else:
	b = 0
	a = int(n[-1])
	n = n[0:len(n) - 1]
	if min(d) < a:
		b = 1
	if b == 1:
		for i in range(len(n)):
			if int(n[i]) % 2 == 0 and int(n[i]) < a:
				e = n[i]
				n = n[0:i] + str(a) + n[i + 1:]
				break
	else:
		for i in range(len(n) - 1, -1, -1):
			if int(n[i]) % 2 == 0:
				e = n[i]
				n = n[0:i] + str(a) + n[i + 1:]
				break
	n += e
	print(n)


n = list(input())
f = -1
for (i, d) in enumerate(n):
	if int(d) % 2 == 0:
		f = i
		if int(d) < int(n[-1]):
			break
if f < 0:
	print(-1)
else:
	(n[-1], n[f]) = (n[f], n[-1])
	print(''.join(n))


n = input()
flag = 0
for i in range(len(n)):
	if int(n[i]) % 2 == 0 and int(n[i]) < int(n[-1]):
		flag = 1
		n = n[:i] + n[-1] + n[i + 1:len(n) - 1] + n[i]
		break
if flag == 1:
	print(n)
	exit()
for i in range(len(n) - 1, -1, -1):
	if int(n[i]) % 2 == 0:
		flag = 1
		n = n[:i] + n[-1] + n[i + 1:len(n) - 1] + n[i]
		break
if flag == 0:
	print(-1)
	exit()
print(n)


from sys import exit
num = input()
num = [int(i) for i in str(num)]
mineven = -1
flag = 0
min = 0
even = list()
for i in range(0, len(num)):
	if num[i] % 2 == 0:
		even.append(i)
	if num[i] % 2 == 0 and mineven == -1:
		mineven = i
		min = num[i]
		continue
	if num[i] <= num[mineven] and num[i] % 2 == 0:
		mineven = i
		min = num[i]
if mineven == -1:
	print('-1')
	exit(0)
even_places = list()
for i in range(0, len(num)):
	if num[i] % 2 == 0 and num[i] < num[len(num) - 1]:
		even_places.append(i)
if len(even_places) > 0:
	temp = num[len(num) - 1]
	num[len(num) - 1] = num[even_places[0]]
	num[even_places[0]] = temp
	num = ''.join((str(i) for i in num))
	print(num)
else:
	mineven = even[len(even) - 1]
	temp = num[len(num) - 1]
	temp1 = num[mineven]
	num[mineven] = temp
	num[len(num) - 1] = temp1
	num = ''.join((str(i) for i in num))
	print(num)


def main():
	l = list(input())
	a = l[-1]
	l.append('8')
	mask = {'9': ('0', '2', '4', '6', '8'), '7': ('0', '2', '4', '6'), '5': ('0', '2', '4'), '3': ('0', '2'), '1': '0'}[a]
	for (i, b) in enumerate(l):
		if b in mask:
			if i < len(l) - 1:
				del l[-1]
				(l[i], l[-1]) = (a, b)
				print(''.join(l))
				return
	for i in range(len(l) - 2, -2, -1):
		b = l[i]
		if b in ('0', '2', '4', '6', '8'):
			if i != -1:
				del l[-1]
				(l[i], l[-1]) = (a, b)
				print(''.join(l))
				return
	print(-1)
main()


n = list(input())
a = n.copy()
even = 0
for i in n:
	if int(i) % 2 == 0:
		even += 1
if even < 1:
	print(-1)
	exit(0)
for i in range(len(n)):
	if int(n[i]) % 2 == 0 and n[i] < n[len(n) - 1]:
		(n[i], n[len(n) - 1]) = (n[len(n) - 1], n[i])
		break
if a == n:
	for i in range(len(n) - 2, -1, -1):
		if int(n[i]) % 2 == 0 and n[i] > n[len(n) - 1]:
			(n[i], n[len(n) - 1]) = (n[len(n) - 1], n[i])
			break
	print(''.join(n))
else:
	print(''.join(n))


import os
import sys
from math import *
from io import BytesIO, IOBase

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

def array():
	return [int(i) for i in input().split()]
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')
s = [int(i) for i in input()]
mine = 10
ind = -1
last = s[-1]
for i in range(len(s)):
	if s[i] % 2 == 0:
		mine = s[i]
		ind = i
		if last >= mine:
			break
if ind == -1:
	print(-1)
	exit()
(s[ind], s[-1]) = (s[-1], s[ind])
for i in s:
	print(i, end='')


n_n = input()
n = [int(i) for i in n_n]
pos = -1
for i in range(len(n) - 2, -1, -1):
	if n[i] & 1 == 0 and (pos == -1 or n[i] <= n[-1]):
		pos = i
if pos == -1:
	print(-1)
else:
	(n[pos], n[-1]) = (n[-1], n[pos])
	for i in n:
		print(i, end='')


import sys
n = input()
n = list(n)
total = 0
for i in n:
	if int(i) % 2 == 0:
		total += 1
res = -1
if total == 0:
	print(-1)
	sys.exit()
for i in range(len(n)):
	if total == 1 and int(n[i]) % 2 == 0:
		(n[i], n[len(n) - 1]) = (n[len(n) - 1], n[i])
		res = 1
		break
	if int(n[i]) % 2 == 0 and int(n[len(n) - 1]) > int(n[i]):
		(n[len(n) - 1], n[i]) = (n[i], n[len(n) - 1])
		res = 1
		break
	elif int(n[i]) % 2 == 0 and int(n[len(n) - 1]) < int(n[i]):
		total -= 1
if res:
	print(''.join(n))
else:
	print(-1)


S = list(input())
n = len(S)
if int(S[n - 1]) % 2 == 0:
	for i in range(n - 1):
		if int(S[n - 1]) > int(S[i]) and int(S[i]) % 2 == 0:
			(S[n - 1], S[i]) = (S[i], S[n - 1])
			break
	print(''.join(S))
else:
	c = 1
	r = -1
	for i in range(n - 1):
		if int(S[n - 1]) > int(S[i]) and int(S[i]) % 2 == 0:
			(S[n - 1], S[i]) = (S[i], S[n - 1])
			c = 0
			print(''.join(S))
			exit()
		if int(S[i]) % 2 == 0:
			r = i
	if c == 1 and r == -1:
		print(-1)
	else:
		(S[n - 1], S[r]) = (S[r], S[n - 1])
		print(''.join(S))


q = [int(x) for x in input()]
if all((x & 1 for x in q)):
	print(-1)
else:
	n = len(q)
	for i in range(n - 1):
		t = q[i]
		if not t & 1 and t < q[n - 1]:
			q[i] = q[n - 1]
			q[n - 1] = t
			break
	else:
		for i in range(n - 1, -1, -1):
			t = q[i]
			if not t & 1 and t > q[n - 1]:
				q[i] = q[n - 1]
				q[n - 1] = t
				break
	print(''.join(map(str, q)))


s = list(input())
n = len(s)
for i in range(0, n - 1):
	if int(s[i]) % 2 == 0 and s[i] < s[n - 1]:
		(s[i], s[n - 1]) = (s[n - 1], s[i])
		print(''.join(s))
		exit(0)
for i in range(n - 2, -1, -1):
	if int(s[i]) % 2 == 0:
		(s[i], s[n - 1]) = (s[n - 1], s[i])
		print(''.join(s))
		exit(0)
print(-1)


s = list(input())
even = 0
flag = 0
for i in range(len(s)):
	if int(s[i]) % 2 == 0:
		even = 1
		if int(s[i]) < int(s[-1]):
			(s[i], s[-1]) = (s[-1], s[i])
			flag = 1
			break
if flag == 0:
	if even == 0:
		print(-1)
	else:
		for i in range(len(s) - 1, -1, -1):
			if int(s[i]) % 2 == 0:
				(s[i], s[-1]) = (s[-1], s[i])
				break
		for i in s:
			print(i, end='')
else:
	for i in s:
		print(i, end='')


num = input().strip()
ev = []
i = 0
for c in num:
	if int(c) % 2 == 0:
		ev.append(i)
	i += 1
last = num[-1]
rnum = num[::-1]
from bisect import bisect_left
if len(ev) > 0:
	ind_ = ev[0]
	for ind in ev:
		if num[ind] < last:
			ind_ = ind
			break
		else:
			ind_ = ind
	out = num[:ind_] + num[-1] + num[ind_ + 1:-1] + num[ind_]
	print(out)
else:
	print(-1)


s = input()
even = ''
for i in range(len(s)):
	if int(s[i]) % 2 == 0:
		even = s[i]
		index = i
		if s[-1] > even:
			print(s[:i] + s[-1] + s[i + 1:-1] + s[i])
			break
else:
	print(s[:index] + s[-1] + s[index + 1:-1] + s[index]) if even else print(-1)


n = input()
l = []
for i in n:
	l.append(int(i))
c = l[len(l) - 1]
flag = True
flag1 = True
pos = 0
for i in range(len(l)):
	if l[i] % 2 == 0:
		pos = i
		flag1 = False
		if c > l[i]:
			(l[i], l[len(l) - 1]) = (l[len(l) - 1], l[i])
			flag = False
			break
if flag and flag1:
	print(-1)
elif flag:
	(l[pos], l[len(l) - 1]) = (l[len(l) - 1], l[pos])
	m = ''
	for i in l:
		m += str(i)
	print(m)
else:
	m = ''
	for i in l:
		m += str(i)
	print(m)


a = list(input())
z = -1
for i in range(len(a)):
	if int(a[i]) % 2 == 0:
		if int(a[i]) < int(a[-1]):
			z = -2
			(a[i], a[-1]) = (a[-1], a[i])
			break
		else:
			z = i
if z == -2:
	print(''.join(a))
elif z >= 0:
	(a[z], a[-1]) = (a[-1], a[z])
	print(''.join(a))
else:
	print(-1)


s = input()
i = len(s)
ind = -1
l = []
l = list(s)
for i in range(len(s)):
	if int(l[i]) & 1 == 0:
		ind = i
		if int(l[i]) < int(l[-1]):
			break
if ind == -1:
	print(-1)
else:
	p = l[-1]
	l[-1] = l[ind]
	l[ind] = p
	print(''.join(l))


n = input()
max_n = -1
last_n = int(n[-1])
for (i, el) in enumerate(n):
	int_el = int(el)
	if int_el % 2 == 0:
		max_n = i
		if int_el < last_n:
			break
print(-1 if max_n == -1 else n[:max_n] + n[-1] + n[max_n + 1:-1] + n[max_n])


n = list(input())
j = -1
for i in range(len(n) - 1, -1, -1):
	if int(n[i]) % 2 == 0:
		if j == -1 or n[i] <= n[-1]:
			j = i
if j == -1:
	print(-1)
else:
	temp = n[j]
	n[j] = n[-1]
	n[-1] = temp
	print(''.join(n))


l = list(map(int, input()))
n = l.pop(len(l) - 1)
m = -1
for i in range(len(l)):
	if l[i] % 2 == 0:
		m = max(m, i)
if m == -1:
	print(-1)
else:
	for i in range(len(l)):
		if l[i] % 2 == 0 and l[i] < n:
			s = l.pop(i)
			l.insert(i, n)
			l.append(s)
			break
		elif l[i] % 2 == 0 and i == m:
			s = l.pop(i)
			l.insert(i, n)
			l.append(s)
			break
	print(''.join(map(str, l)))


n = input()
a = list(map(int, list(n)))
l = a[-1]
ans_idx = -1
first_idx = -1
for i in range(len(a) - 1):
	if a[i] != l and a[i] % 2 == 0:
		ans_idx = i
		if a[i] < l:
			break
if ans_idx == -1:
	print(-1)
	exit()
a[-1] = a[ans_idx]
a[ans_idx] = l
print(''.join(list(map(str, a))))


l = list(input())
n = len(l)
la = int(l[-1])
r = False
for i in range(n):
	if not int(l[i]) % 2 and int(l[i]) < la:
		(l[i], l[-1]) = (l[-1], l[i])
		r = True
		break
if r:
	print(''.join(l))
else:
	for i in range(n - 2, -1, -1):
		if not int(l[i]) % 2:
			(l[i], l[-1]) = (l[-1], l[i])
			r = True
			break
	if r:
		print(''.join(l))
	else:
		print(-1)


def main():
	li = list(input())
	found = 0
	cnt = 0
	mini = 10
	for i in range(len(li) - 2, -1, -1):
		num = int(li[i])
		if num % 2 == 0:
			cnt = cnt + 1
			if num < int(li[-1]):
				min_ind = i
				found = 1
	if cnt == 0:
		print('-1')
	elif found == 1:
		(li[-1], li[min_ind]) = (li[min_ind], li[-1])
		for i in li:
			print(i, end='')
		print()
	else:
		for i in range(len(li) - 2, -1, -1):
			num = int(li[i])
			if num % 2 == 0:
				(li[-1], li[i]) = (li[i], li[-1])
				break
		for i in li:
			print(i, end='')
		print()
main()


__author__ = 'artyom'
s = input()
(odd, last) = (int(s[-1]), None)
for i in range(len(s) - 1):
	v = int(s[i])
	if v % 2 == 0:
		last = i
		if v < odd:
			break
if last is None:
	print(-1)
else:
	s = list(s)
	(s[last], s[-1]) = (odd, s[last])
	print(''.join(map(str, s)))


auxPar = -1
valorPar = 0
x = list(input())
for i in range(len(x)):
	if int(x[i]) % 2 == 0:
		auxPar = i
		if x[i] <= x[-1]:
			break
valor = x[auxPar]
x[auxPar] = x[-1]
x[-1] = valor
if auxPar == -1:
	print('-1')
else:
	print(''.join(x))


s = input()
num = -1
for i in range(len(s)):
	if ord(s[i]) < ord(s[len(s) - 1]) and ord(s[i]) % 2 == 0:
		num = i
		break
if num == -1:
	for i in range(1, len(s) + 1):
		if ord(s[len(s) - i]) % 2 == 0:
			num = len(s) - i
			break
if num == -1:
	print(-1)
else:
	print(s[:num], s[len(s) - 1], s[num + 1:len(s) - 1], s[num], sep='')


ll = lambda : map(int, input().split())
t = lambda : int(input())
ss = lambda : input()
lx = lambda x: map(int, input().split(x))
from math import log10, log2, ceil, factorial as fac, gcd

def f():
	l = list(ss())
	x = -1
	for i in range(len(l)):
		if int(l[i]) % 2 == 0:
			if int(l[i]) < int(l[-1]):
				x = i
				break
			else:
				x = i
	if x != -1:
		(l[x], l[-1]) = (l[-1], l[x])
		print(''.join(l))
	else:
		print(x)
f()


n = list(input())
f = True
z = -1
for i in range(len(n)):
	if int(n[i]) % 2 == 0:
		if int(n[i]) < int(n[-1]):
			(n[i], n[-1]) = (n[-1], n[i])
			an = ''.join(n)
			f = False
			z = 0
			break
		else:
			z = i
if z == -1:
	an = -1
elif f:
	(n[-1], n[z]) = (n[z], n[-1])
	an = ''.join(n)
elif z == -1:
	an = -1
print(an)


n = input()
R = lambda n, i: n[:i] + n[-1] + n[i + 1:-1] + n[i]
for i in range(len(n)):
	if int(n[i]) % 2 == 0 and n[-1] > n[i]:
		print(R(n, i))
		exit()
for i in range(len(n) - 1, -1, -1):
	if int(n[i]) % 2 == 0:
		print(R(n, i))
		exit()
print(-1)


s = list(input())
ind = -1
l = len(s)
t = s[l - 1]
for i in range(l):
	if int(s[i]) % 2 == 0:
		if int(s[i]) < int(s[l - 1]):
			ind = i
			break
		ind = i
if ind == -1:
	print(-1)
else:
	(s[ind], s[l - 1]) = (s[l - 1], s[ind])
	print(*s, sep='')


import sys
s = input()
p = list(s)
count = 0
l = [int(s[i]) for i in range(len(s) - 1)]
l.sort(reverse=True)
l.append(int(s[len(s) - 1]))
for i in range(len(s)):
	if int(s[i]) % 2 != 0:
		count += 1
if count == len(s):
	print('-1')
	sys.exit()
if int(p[len(p) - 1]) % 2 != 0:
	i = 0
	flag = 0
	tar = l[len(l) - 1]
	while i <= len(s) - 2:
		if int(p[i]) < tar and int(p[i]) % 2 == 0:
			temp = tar
			p[len(s) - 1] = p[i]
			p[i] = str(tar)
			flag = 1
			break
		i += 1
	if flag == 0:
		i = len(s) - 2
		while i >= 0:
			if int(p[i]) % 2 == 0:
				p[len(s) - 1] = p[i]
				p[i] = str(tar)
				break
			i -= 1
else:
	i = 0
	j = 0
	flag = 0
	print(s, l)
	while i <= len(s) - 2 and j <= len(s) - 2:
		if int(s[i]) != l[j]:
			_exp = i
			_exq = j
			flag = 1
			break
		j += 1
		i += 1
	if flag == 1:
		_exq = p.index(str(l[_exp]))
		temp = p[_exp]
		p[_exp] = p[_exq]
		p[_exq] = temp
st = ''.join(p)
print(st)


s = list(input())
index = len(s) - 1
for i in range(len(s) - 1, -1, -1):
	if int(s[i]) % 2 == 0:
		if int(s[i]) < int(s[len(s) - 1]):
			index = i
		elif index == len(s) - 1:
			index = i
(s[len(s) - 1], s[index]) = (s[index], s[len(s) - 1])
if index == len(s) - 1:
	print(-1)
else:
	print(''.join(s))


n = list(input())
l = len(n)
q = n[l - 1]
d = r = 0
for i in range(l):
	if int(n[i]) % 2 == 0:
		r = 1
		id = i
		if q > n[i]:
			d = 1
			n[l - 1] = n[i]
			n[i] = q
			break
if r == 0:
	n = [-1]
elif d == 0:
	n[l - 1] = n[id]
	n[id] = q
for i in n:
	print(i, end='')


def solve(num_str):
	num_str = list(num_str)
	even_indices = [i for (i, x) in enumerate(num_str) if x in '02468']
	if len(even_indices) == 0:
		return '-1'
	for i in even_indices:
		if num_str[i] < num_str[-1]:
			(num_str[i], num_str[-1]) = (num_str[-1], num_str[i])
			return ''.join(map(str, num_str))
	(num_str[i], num_str[-1]) = (num_str[-1], num_str[i])
	return ''.join(map(str, num_str))

def test():
	assert solve('527') == '572'
	assert solve('4573') == '3574'
	assert solve('1357997531') == '-1'
test()
res = solve(input())
print(res)


n = input()
n = list(n)
c = 0
k = -1
for i in range(len(n)):
	if int(n[i]) % 2 == 0:
		c += 1
		k = i
if c == 0:
	print(-1)
elif c == 1:
	(n[k], n[-1]) = (n[-1], n[k])
	print(''.join(n))
else:
	k = -1
	s = 0
	for i in range(len(n)):
		if int(n[i]) % 2 == 0 and int(n[i]) < int(n[-1]):
			(n[i], n[-1]) = (n[-1], n[i])
			s = 1
			break
		if int(n[i]) % 2 == 0 and int(n[i]) > int(n[-1]):
			k = i
	if s == 0:
		(n[k], n[-1]) = (n[-1], n[k])
	print(''.join(n))


n = input()
k = str(n)
k = list(map(int, k))
ev = []
for j in k:
	if j % 2 == 0:
		ev.append(j)
if len(ev) == 0:
	print(-1)
else:
	if len(ev) == 1:
		i = k.index(ev[0])
		temp = ev[0]
		k[i] = k[len(k) - 1]
		k[len(k) - 1] = temp
	else:
		flag = 0
		for j in ev:
			if j < k[len(k) - 1]:
				i = k.index(j)
				temp = j
				k[i] = k[len(k) - 1]
				k[len(k) - 1] = temp
				flag = 1
				break
		if flag == 0:
			i = len(k) - 1 - k[::-1].index(ev[len(ev) - 1])
			temp = ev[len(ev) - 1]
			k[i] = k[len(k) - 1]
			k[len(k) - 1] = temp
	k = list(map(str, k))
	print(''.join(k))


a = list(input())
m = -1
for (i, d) in enumerate(a):
	if int(d) % 2 == 0:
		m = i
		if int(d) < int(a[-1]):
			break
if m < 0:
	print(-1)
else:
	(a[-1], a[m]) = (a[m], a[-1])
	print(''.join(a))


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
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
import copy
import time
starttime = time.time()
mod = int(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)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass
n = list(input())
s = []
first = -1
last = -1
for i in range(len(n)):
	if int(n[i]) % 2 == 0:
		if int(n[i]) < int(n[-1]) and first == -1:
			first = i
		if int(n[i]) > int(n[-1]):
			last = i
if first == -1 and last == -1:
	print(-1)
	exit()
if first != -1:
	(n[first], n[-1]) = (n[-1], n[first])
else:
	(n[last], n[-1]) = (n[-1], n[last])
print(''.join(n))
endtime = time.time()


a = input()
b = int(a[-1])
evens = []
nums = []
for i in range(len(a)):
	x = int(a[i])
	if x % 2 == 0:
		evens.append(i)
		nums.append(x)
if nums == []:
	print(-1)
elif max(nums) < b:
	print(a[:min(evens)] + a[-1] + a[min(evens) + 1:-1] + a[min(evens)])
else:
	for i in range(len(evens)):
		if nums[i] < b:
			print(a[:evens[i]] + a[-1] + a[evens[i] + 1:-1] + a[evens[i]])
			quit()
	print(a[:max(evens)] + a[-1] + a[max(evens) + 1:-1] + a[max(evens)])


def sol(arr):
	swap = False
	for i in range(len(arr) - 1):
		if arr[i] % 2 == 0 and arr[i] < arr[-1]:
			temp = arr[-1]
			arr[-1] = arr[i]
			arr[i] = temp
			swap = True
			break
	if not swap:
		for i in range(len(arr) - 2, -1, -1):
			if arr[i] % 2 == 0:
				temp = arr[-1]
				arr[-1] = arr[i]
				arr[i] = temp
				swap = True
				break
	if not swap:
		print(-1)
		return
	for i in arr:
		print(i, end='')
	return
n = input()
arr = []
for t in range(len(n)):
	arr.append(int(n[t]))
sol(arr)


s = list(input())
n = len(s)
last = int(s[-1])
even_i = -1
for i in range(n - 1):
	t = int(s[i])
	if t % 2 == 0:
		even_i = i
		if last > t:
			(s[-1], s[i]) = (s[i], s[-1])
			even_i = -2
			break
if even_i == -1:
	print(-1)
elif even_i == -2:
	print(''.join(s))
else:
	(s[-1], s[even_i]) = (s[even_i], s[-1])
	print(''.join(s))


s = str(input())
n = len(s)
ok = 0
for i in range(n):
	if int(s[i]) % 2 == 0 and int(s[n - 1]) > int(s[i]):
		print(s[:i] + s[n - 1] + s[i + 1:n - 1] + s[i])
		ok = 1
		break
if ok == 0:
	i = n - 2
	while i >= 0:
		if int(s[i]) % 2 == 0:
			print(s[:i] + s[n - 1] + s[i + 1:n - 1] + s[i])
			ok = 1
			break
		i -= 1
if ok == 0:
	print(-1)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	a = [int(c) for c in S()]
	if all((c % 2 == 1 for c in a)):
		return -1
	l = len(a)
	li = a[-1]
	mi = -1
	for i in range(l):
		if a[i] % 2 == 0:
			mi = i
			if a[i] < li:
				break
	(a[mi], a[-1]) = (a[-1], a[mi])
	return ''.join(map(str, a))
print(main())


def run():
	import sys
	sys.stdin = open('/home/punit/Documents/Cpp Programs/input.txt', 'r')
	sys.stdout = open('/home/punit/Documents/Cpp Programs/output.txt', 'w')
	from math import ceil, sqrt, floor
s = input()
ans1 = ''
ans2 = ''
for i in range(len(s) - 1):
	if int(s[i]) % 2 == 0 and int(s[i]) < int(s[len(s) - 1]):
		ans1 = s[0:i] + s[len(s) - 1] + s[i + 1:len(s) - 1] + s[i]
		break
for i in range(len(s) - 2, -1, -1):
	if int(s[i]) % 2 == 0 and int(s[i]) > int(s[len(s) - 1]):
		ans2 = s[0:i] + s[len(s) - 1] + s[i + 1:len(s) - 1] + s[i]
		break
if len(ans1) == 0 and len(ans2) == 0:
	print(-1)
else:
	print(max(ans1, ans2))


from collections import *

def main():
	(n, ix) = (deque(input()), -1)
	for i in range(len(n)):
		if int(n[i]) % 2 == 0:
			ix = i
			if n[-1] > n[i]:
				(n[i], n[-1]) = (n[-1], n[i])
				exit(print(''.join(n)))
		if i == len(n) - 1 and ix != -1:
			(n[i], n[ix]) = (n[ix], n[i])
			exit(print(''.join(n)))
	print(-1)
main()


a = input()
a = list(a)
ind = -1
s = -1
flag = 0
e = a[len(a) - 1]
temp = 0
for i in range(len(a) - 1, -1, -1):
	if int(a[i]) % 2 == 0:
		flag = flag + 1
		if flag == 1:
			ind = i
			temp = a[i]
		elif e > a[i]:
			ind = i
			temp = a[i]
if flag == 0:
	print('-1')
else:
	a[len(a) - 1] = str(temp)
	a[ind] = str(e)
	a = ''.join(a)
	print(a)


n = str(input())
nlist = [int(d) for d in str(n)]
length = len(nlist)
currpos = 0
currval = 0
check = False
for x in range(len(nlist)):
	if nlist[x] % 2 == 0 and nlist[x] < nlist[len(nlist) - 1]:
		(nlist[x], nlist[len(nlist) - 1]) = (nlist[len(nlist) - 1], nlist[x])
		for i in nlist:
			print(i, end='')
		check = True
		break
if not check:
	rev = nlist[::-1]
	for x in range(length):
		if rev[x] % 2 == 0 and rev[x] > rev[0]:
			(rev[x], rev[0]) = (rev[0], rev[x])
			for i in rev[::-1]:
				print(i, end='')
			check = True
			break
if not check:
	print('-1')


import sys
inf = float('inf')
(mod, MOD) = (1000000007, 998244353)
from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd, log10, atan, tan

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_strs():
	return map(str, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
n = input()
count = 0
mydict = dict()
for i in range(len(n)):
	if int(n[i]) % 2 == 0:
		count += 1
if count == 0:
	print(-1)
else:
	myArr = list(n)
	last = 0
	flag = 0
	for i in range(len(myArr) - 1):
		if int(myArr[i]) % 2 == 0:
			last = i
			if int(myArr[i]) < int(myArr[-1]):
				(myArr[i], myArr[-1]) = (myArr[-1], myArr[i])
				flag = 1
				break
		if flag == 1:
			break
	if flag == 1:
		print(''.join(myArr))
	else:
		(myArr[last], myArr[-1]) = (myArr[-1], myArr[last])
		print(''.join(myArr))


n = input()
temp = index = -1
for i in range(len(n)):
	digit = n[i]
	if int(digit) % 2 == 0:
		temp = i
		if digit < n[-1]:
			index = i
			break
if index == -1:
	if temp == -1:
		print(-1)
		exit()
	index = temp
print(n[0:index] + n[-1] + n[index + 1:-1] + n[index])


s = input()
ans = s[-1]
d = {}
se = 0
case = False
for i in range(len(s)):
	if int(s[i]) % 2 == 0:
		if int(s[i]) < int(ans):
			case = True
			l = i
			break
		else:
			op = i
	else:
		se += 1
if se == len(s):
	print(-1)
elif case:
	p = ''
	oop = s[l]
	for j in range(len(s)):
		if j == l:
			p += str(ans)
		elif j == len(s) - 1:
			p += oop
		else:
			p += s[j]
	print(p)
else:
	p = ''
	oop = s[op]
	for j in range(len(s)):
		if j == op:
			p += str(ans)
		elif j == len(s) - 1:
			p += oop
		else:
			p += s[j]
	print(p)


import math
n = input()
arr = list(map(int, n))
l = len(n)
f = 0
if int(n[l - 1]) % 2 != 0:
	index = -1
	for i in range(0, l - 1):
		if arr[i] % 2 == 0 and arr[l - 1] > arr[i]:
			index = i
			break
	if index == -1:
		for i in range(l - 2, -1, -1):
			if arr[i] % 2 == 0:
				index = i
				break
	if index == -1:
		f = 1
	else:
		temp = arr[l - 1]
		arr[l - 1] = arr[index]
		arr[index] = temp
else:
	for i in range(0, l):
		num = arr[i]
		if num % 2 == 0:
			current = i
			m = -1
			index = -1
			for i in range(0, l):
				if arr[i] >= m and i != current:
					m = arr[i]
					index = i
			if m == -1:
				f = 1
			else:
				temp = arr[current]
				arr[current] = m
				arr[index] = temp
if f == 1:
	print(-1)
else:
	k = []
	for i in arr:
		k.append(str(i))
	print(''.join(k))


t = input()
last = int(t[-1])
even = [int(x) for x in t if int(x) % 2]
last_even = None
for (i, c) in enumerate(t):
	as_int = int(c)
	if as_int % 2:
		continue
	last_even = i
	if as_int > last:
		continue
	print(t[:i] + t[-1] + t[i + 1:-1] + t[i])
	break
else:
	if last_even is None:
		print(-1)
	else:
		print(t[:last_even] + t[-1] + t[last_even + 1:-1] + t[last_even])


n = input()
max = -1
temp = '-1'
for i in range(len(n)):
	if int(n[i]) % 2 == 0 and int(n[i]) < int(n[-1]):
		temp = n[0:i] + n[-1] + n[i + 1:len(n) - 1] + n[i]
		break
if temp == '-1':
	for i in range(len(n) - 2, -1, -1):
		if int(n[i]) % 2 == 0:
			temp = n[0:i] + n[-1] + n[i + 1:len(n) - 1] + n[i]
			break
print(temp)


digits = list(input())
l = len(digits)
pos = l - 1
for i in range(l):
	if int(digits[i]) % 2 == 0:
		pos = i
		if digits[l - 1] > digits[i]:
			break
if pos == l - 1:
	print(-1)
else:
	tmp = digits[pos]
	digits[pos] = digits[l - 1]
	digits[l - 1] = tmp
	print(''.join(digits))


k = input()
n = len(k)
x = -1
c = 0
diff = 9999999
p = k[n - 1]
for i in range(n - 2, -1, -1):
	if ord(k[i]) % 2 == 0:
		if c == 0 or (ord(p) - ord(k[i]) > 0 and ord(p) - ord(k[i]) > diff):
			diff = ord(p) - ord(k[i])
			x = i
			c += 1
		if diff > 0 and diff >= ord(p) - ord(k[i]) and (ord(p) - ord(k[i]) > 0):
			diff = ord(p) - ord(k[i])
			x = i
if x == -1:
	print(-1)
else:
	print(k[:x] + p + k[x + 1:n - 1] + k[x])


num = list(input())

def test():
	flag = False
	best = 0
	for i in range(len(num)):
		if int(num[i]) % 2 == 0:
			flag = True
			best = i
			if int(num[i]) < int(num[len(num) - 1]):
				break
	if flag:
		(num[best], num[len(num) - 1]) = (num[len(num) - 1], num[best])
		return True
	else:
		return False
if test():
	for n in num:
		print(int(n), end='')
else:
	print('-1')


s = list(map(int, input()))
tm = -1

def pr(s):
	for n in s:
		print(n, end='')
p = s[-1]
for n in range(len(s)):
	if s[n] % 2 == 0 and s[n] < p:
		s[-1] = s[n]
		s[n] = p
		pr(s)
		exit(0)
	elif s[n] % 2 == 0:
		tm = n
if tm == -1:
	print(-1)
else:
	s[-1] = s[tm]
	s[tm] = p
	pr(s)


s = input()
counter = 0
for i in range(len(s)):
	if int(s[i]) % 2 == 0:
		counter = counter + 1
if counter == 0:
	print(-1)
elif counter == 1:
	for i in range(len(s)):
		if int(s[i]) % 2 == 0:
			lst = list(s)
			(lst[i], lst[len(s) - 1]) = (lst[len(s) - 1], lst[i])
	print(''.join(lst))
else:
	ok = False
	for i in range(len(s)):
		if int(s[i]) % 2 == 0 and int(s[i]) < int(s[len(s) - 1]):
			lst2 = list(s)
			(lst2[i], lst2[len(s) - 1]) = (lst2[len(s) - 1], lst2[i])
			ok = True
			break
	if ok == False:
		for i in range(len(s) - 1, -1, -1):
			if int(s[i]) % 2 == 0:
				lst3 = list(s)
				(lst3[i], lst3[len(s) - 1]) = (lst3[len(s) - 1], lst3[i])
				break
		print(''.join(lst3))
	else:
		print(''.join(lst2))


k = input()
t = -1
for i in range(len(k)):
	if int(k[i]) & 1 == 0:
		t = i
		if k[i] < k[-1]:
			break
if t == -1:
	print(-1)
else:
	l = list(k)
	(l[t], l[-1]) = (k[-1], k[t])
	print(''.join(l))


def judge(ss):
	n = len(ss)
	for i in range(n):
		if int(ss[i]) % 2 == 0:
			return i
	return -1
s = input()
p = judge(s)
if p == -1:
	print('-1')
else:
	n = len(s)
	flag = 0
	las = n - 1
	cmp = int(s[las])
	for i in range(n):
		if int(s[i]) % 2 == 0:
			p = i
			if int(s[i]) < cmp:
				temp = s[0:i] + s[las] + s[i + 1:n - 1] + s[i]
				print(temp)
				flag = 1
				break
	if not flag:
		temp = s[0:p] + s[las] + s[p + 1:n - 1] + s[p]
		print(temp)


s1 = input()
L = []
s2 = list(s1)
ind = -1
num = int(s2[-1])
(ind1, ind2) = (-1, -1)
for i in range(len(s2)):
	if int(s2[i]) % 2 == 0:
		if int(s2[i]) < int(s2[-1]):
			ind1 = i
			break
for i in range(len(s2) - 2, -1, -1):
	if int(s2[i]) % 2 == 0:
		if int(s2[i]) > int(s2[-1]):
			ind2 = i
			break
ans1 = ''
ans2 = ''
if ind1 != -1:
	(s2[-1], s2[ind1]) = (s2[ind1], s2[-1])
	ans1 = ''.join(s2)
	(s2[-1], s2[ind1]) = (s2[ind1], s2[-1])
if ind2 != -1:
	(s2[-1], s2[ind2]) = (s2[ind2], s2[-1])
	ans2 = ''.join(s2)
	(s2[-1], s2[ind1]) = (s2[ind1], s2[-1])
if ind1 == -1 and ind2 == -1:
	print('-1')
elif ans1 != '' and ans2 != '':
	if int(ans1) > int(ans2):
		print(ans1)
	else:
		print(ans2)
elif ans1 == '':
	print(ans2)
else:
	print(ans1)


def solve(s):
	n = len(s)
	s = list(s)
	for i in range(n - 1):
		if int(s[i]) < int(s[-1]) and int(s[i]) % 2 == 0:
			(s[i], s[-1]) = (s[-1], s[i])
			return ''.join(s)
	for i in range(n - 2, -1, -1):
		if int(s[i]) % 2 == 0:
			(s[i], s[-1]) = (s[-1], s[i])
			return ''.join(s)
	return '-1'
n = input()
print(solve(n))


def swap(a, b):
	return (b, a)
n = list(input())
if set(n).issubset({'1', '3', '5', '7', '9'}):
	print(-1)
else:
	done = False
	for i in range(len(n)):
		if int(n[i]) % 2 == 0 and int(n[i]) < int(n[-1]):
			(n[i], n[-1]) = swap(n[i], n[-1])
			done = True
			break
	if not done:
		for i in range(len(n) - 1, -1, -1):
			if int(n[i]) % 2 == 0:
				(n[i], n[-1]) = swap(n[i], n[-1])
				break
	print(''.join(n))


n = input()
digit = [int(x) for x in n]
loc = 0
val = 9
flag = 0
for i in range(len(digit)):
	if digit[i] % 2 == 0:
		if digit[i] < digit[-1]:
			(digit[i], digit[-1]) = (digit[-1], digit[i])
			flag = 1
			break
		else:
			loc = i
if flag == 1:
	print(''.join(map(str, digit)))
elif digit[loc] % 2 == 0:
	(digit[loc], digit[-1]) = (digit[-1], digit[loc])
	print(''.join(map(str, digit)))
else:
	print(-1)


n = list(input())
c = len(n)
count = 0
for i in range(c):
	if int(n[i]) % 2 == 0 and int(n[i]) < int(n[-1]):
		(n[i], n[-1]) = (n[-1], n[i])
		break
	count += 1
if count < c:
	for i in n:
		print(i, end='')
else:
	count = 0
	for i in range(c):
		if int(n[c - i - 1]) % 2 == 0:
			(n[c - i - 1], n[-1]) = (n[-1], n[c - i - 1])
			break
		count += 1
	if count < c:
		for i in n:
			print(i, end='')
	else:
		print('-1')


def solve(n):
	pos = [i for (i, c) in enumerate(n) if c in '02468']
	num_even = len(pos)
	if num_even == 0:
		return -1
	ans = list(n)
	for (i, p) in enumerate(pos):
		if n[p] < n[-1] or i == num_even - 1:
			(ans[p], ans[-1]) = (ans[-1], ans[p])
			return ''.join(ans)

def main():
	n = input()
	ans = solve(n)
	print(ans)
main()


n = list(str(input()))
x = -1
for i in range(len(n)):
	if int(n[i]) % 2 == 0:
		if n[i] > n[-1]:
			x = i
		else:
			x = i
			break
if x != -1:
	(n[x], n[-1]) = (n[-1], n[x])
	print(''.join(n))
else:
	print('-1')


n = input()
last = -1
last_even_idx = None
i = len(n) - 1
while i >= 0:
	if int(n[i]) % 2 == 0:
		if not last_even_idx:
			last_even_idx = i
		elif n[last] > n[i]:
			last_even_idx = i
	i -= 1
if last_even_idx == None:
	print(-1)
else:
	result = n[:last_even_idx] + n[last] + n[last_even_idx + 1:len(n) - 1] + n[last_even_idx]
	print(result)


num_ = input()
last = num_[-1]
odd_max = -1
ans = [-1, -1]
max_ = -1
for (index, num) in enumerate(num_):
	if int(num) % 2 == 0:
		if int(num) < int(last):
			ans = [num, index]
			break
		else:
			ans = [num, index]
if ans[0] != -1:
	max_ = num_[:ans[1]] + last + num_[ans[1] + 1:-1] + ans[0]
print(max_)


num = input()
length = len(num)
last = ord(num[length - 1]) - ord('0')
even = -1
for i in range(length):
	digit = ord(num[i]) - ord('0')
	if digit % 2 == 0:
		if digit < last:
			even = i
			break
		else:
			even = i
if even is -1:
	print(-1)
else:
	ans = list(num)
	(ans[even], ans[length - 1]) = (ans[length - 1], ans[even])
	print(''.join(ans))


n = input()
flag = 1
for j in range(len(n) - 1):
	if int(n[j]) % 2 == 0:
		i = j
		flag = 0
		if int(n[j]) < int(n[len(n) - 1]):
			break
if flag == 1:
	print(-1)
else:
	q = n[i]
	strr = ''
	if i != 0:
		strr = strr + n[0:i]
	strr = strr + n[len(n) - 1]
	if i != len(n) - 2:
		strr = strr + n[i + 1:len(n) - 1]
	strr = strr + q
	print(strr)


s = list(input())
(res, lst) = (-1, -1)
for i in range(len(s)):
	if (ord(s[i]) - ord('0')) % 2 == 0:
		lst = i
		if s[i] < s[-1]:
			(s[i], s[-1]) = (s[-1], s[i])
			print(''.join(s))
			exit()
if lst == -1:
	print(lst)
	exit()
(s[lst], s[-1]) = (s[-1], s[lst])
print(''.join(s))


inp = input()
ln = len(inp)
ls = int(inp[-1])
s = -1
for i in range(ln):
	if int(inp[i]) % 2 == 0:
		if int(inp[i]) < ls:
			inp = inp[:i] + inp[-1] + inp[i + 1:-1] + inp[i]
			s = -2
			break
		s = i
if s >= 0:
	inp = inp[:s] + inp[-1] + inp[s + 1:-1] + inp[s]
print(s if s == -1 else inp)


s = input()
flag = 0
f = 0
l = list(s)
m = list(s)
i = 0
while i < len(s) - 1:
	if int(s[i]) % 2 == 0 and int(s[i]) < int(s[len(s) - 1]):
		t = l[i]
		l[i] = l[len(l) - 1]
		l[len(l) - 1] = t
		flag = 1
		break
	i = i + 1
i = len(s) - 2
while i >= 0:
	if int(s[i]) % 2 == 0 and int(s[i]) > int(s[len(s) - 1]):
		t = m[i]
		m[i] = m[len(m) - 1]
		m[len(m) - 1] = t
		f = 1
		break
	i = i - 1
str = ''
if flag == 1 and f == 1:
	if l > m:
		print(str.join(l))
	else:
		print(str.join(m))
elif flag == 1:
	print(str.join(l))
elif f == 1:
	print(str.join(m))
else:
	print(-1)


t = input()
digits = [int(i) for i in t]
flag = 0
length = len(digits)
lastDigit = digits[length - 1]
for i in range(length - 1):
	if digits[i] % 2 == 0 and digits[i] < lastDigit:
		(digits[length - 1], digits[i]) = (digits[i], digits[length - 1])
		flag = 1
		break
j = length - 2
while j >= 0 and flag == 0:
	if digits[j] % 2 == 0 and digits[j] > lastDigit:
		(digits[length - 1], digits[j]) = (digits[j], digits[length - 1])
		flag = 1
		break
	j -= 1
if flag == 0:
	print(-1)
else:
	for digit in digits:
		print(digit, end='')


given = [x for x in input()]
last = -1
for i in range(len(given) - 1):
	if given[i] in '02468':
		last = i
		if given[i] < given[-1]:
			break
if last == -1:
	print(-1)
else:
	(given[last], given[-1]) = (given[-1], given[last])
	print(''.join(given))


def main():
	n = list(input())
	if '2' not in n and '4' not in n and ('6' not in n) and ('8' not in n) and ('0' not in n):
		print(-1)
	else:
		p = []
		for j in range(len(n) - 1, -1, -1):
			if int(n[j]) % 2 == 0 and int(n[j]) > int(n[-1]):
				(n[j], n[-1]) = (n[-1], n[j])
				p.append(''.join(n))
				(n[j], n[-1]) = (n[-1], n[j])
				break
		for j in range(0, len(n)):
			if int(n[j]) % 2 == 0 and int(n[j]) < int(n[-1]):
				(n[j], n[-1]) = (n[-1], n[j])
				p.append(''.join(n))
				(n[j], n[-1]) = (n[-1], n[j])
				break
		p.sort()
		print(p[-1])
		return
main()


s = input()
l = []
for i in s:
	l.append(int(i))
n = len(l)
odd = l[n - 1]
index = -1
for i in range(len(l)):
	if l[i] % 2 == 0 and l[i] < odd:
		index = i
		break
if index == -1:
	lastindex = -1
	for i in range(len(l)):
		if l[i] % 2 == 0:
			lastindex = i
	if lastindex == -1:
		print(-1)
	else:
		(l[lastindex], l[n - 1]) = (l[n - 1], l[lastindex])
		for i in l:
			print(i, end='')
else:
	(l[index], l[n - 1]) = (l[n - 1], l[index])
	for i in l:
		print(i, end='')


n = input()
lastDigit = int(n[-1])
i = len(n) - 2
firstEvenIdx = -1
while i >= 0:
	if int(n[i]) % 2 == 0:
		firstEvenIdx = i
		break
	i -= 1
if firstEvenIdx == -1:
	print(-1)
else:
	while i >= 0:
		if int(n[i]) % 2 == 0 and int(n[i]) < lastDigit:
			firstEvenIdx = i
		i -= 1
	print(n[:firstEvenIdx] + str(lastDigit) + n[firstEvenIdx + 1:len(n) - 1] + n[firstEvenIdx])


n = input()
x = 0
y = len(n)
c = 'a'
for i in range(0, y):
	if int(n[i]) % 2 == 0 and n[i] < n[y - 1]:
		c = n[i]
		x = i
		break
if c == 'a':
	for i in range(1, y):
		if int(n[y - i - 1]) % 2 == 0:
			c = n[y - i - 1]
			x = y - i - 1
			break
if c == 'a':
	print(-1)
else:
	for i in range(0, y):
		if i == x:
			print(n[y - 1], end='')
		elif i == y - 1:
			print(c, end='')
		else:
			print(n[i], end='')


import re
from sys import stderr
from typing import Union, Generator, List, Tuple
import string
INF = 2e+18 + 3
EPS = 1e-10

def main():
	old_rate = input()
	size = len(old_rate)
	last_digit = old_rate[-1]
	for (i, ch) in enumerate(old_rate):
		if int(ch) % 2 == 0 and ch < last_digit:
			res = old_rate[:i] + last_digit + old_rate[i + 1:-1] + ch
			break
	else:
		for (i, ch) in enumerate(old_rate[::-1]):
			i = size - i - 1
			if int(ch) % 2 == 0:
				res = old_rate[:i] + last_digit + old_rate[i + 1:-1] + ch
				break
		else:
			res = -1
	print(res)
main()


n = list(map(int, input()))
a = []
p = []
flag = 0
for i in range(len(n)):
	if n[i] % 2 == 0 and n[-1] > n[i]:
		(n[i], n[-1]) = (n[-1], n[i])
		flag = 1
		break
	elif n[i] % 2 == 0:
		p = [[n[i], i]]
		flag = 1
if flag == 0:
	print(-1)
	exit()
if n[-1] % 2 == 0:
	n = list(map(str, n))
	print(''.join(n))
else:
	(n[-1], n[p[0][1]]) = (p[0][0], n[-1])
	n = list(map(str, n))
	print(''.join(n))


n = input()
l = list(n)
e = 0
for i in range(len(n)):
	if int(l[i]) % 2 == 0:
		e = 1
		ans = int(l[i])
		pos = i
ch = int(l[len(n) - 1])
if e == 0:
	print('-1')
else:
	for i in range(i - 1, -1, -1):
		if int(l[i]) % 2 == 0:
			if int(l[i]) < ch:
				ans = int(l[i])
				pos = i
	for i in range(len(n) - 1):
		if i != pos:
			print(l[i], end='')
		else:
			print(ch, end='')
	print(ans)


a = input().replace('', ' ').split()
(_t, _i) = (-1, -1)
for i in range(len(a) - 1, -1, -1):
	if int(a[i]) % 2 == 0:
		if _i == -1:
			_i = i
		elif int(a[i]) < int(a[-1]):
			_i = i
if _i == -1:
	print(_t)
else:
	(a[_i], a[-1]) = (a[-1], a[_i])
	print(''.join(a))


import sys
from math import log2, ceil
input = sys.stdin.readline

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a > 0:
		return gcd(b % a, a)
	return b

def primefs(n):
	if n == 1:
		return 1
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	while x != link[x]:
		x = link[x]
	return x

def union(x, y, size, link):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def int_array():
	return list(map(int, input().split()))
string = input().strip()
num = int(string)
n = len(string)
ind = -1
for i in range(n - 1):
	if int(string[i]) % 2 == 0:
		if int(string[-1]) > int(string[i]):
			ind = i
			break
if ind != -1:
	ans = list(string)
	swaparr(ans, ind, n - 1)
	ans = ''.join(ans)
	print(ans)
	exit()
ind = -1
for i in range(n - 2, -1, -1):
	if int(string[i]) % 2 == 0:
		ind = i
		break
if ind == -1:
	print(-1)
else:
	ans = list(string)
	swaparr(ans, ind, n - 1)
	ans = ''.join(ans)
	print(ans)


def main():
	strnum = input()
	odd = int(strnum[-1])
	maxpos = -1
	minpos = -1
	l = len(strnum)
	for i in range(l):
		d = int(strnum[i])
		if d % 2 == 0:
			if d < odd:
				maxpos = i
				break
			else:
				minpos = i
	if maxpos > -1:
		for i in range(l):
			if i == maxpos:
				print(odd, end='')
			elif i == l - 1:
				print(strnum[maxpos])
			else:
				print(strnum[i], end='')
	elif minpos > -1:
		for i in range(l):
			if i == minpos:
				print(odd, end='')
			elif i == l - 1:
				print(strnum[minpos])
			else:
				print(strnum[i], end='')
	else:
		print(-1)
main()


lens = 0

def find_2(array):
	global lens
	iterr = -1
	for i in range(lens - 2, -1, -1):
		if int(array[i]) % 2 == 0 and int(array[i]) <= int(array[-1]):
			iterr = i
	return iterr

def find_1(array):
	global lens
	iterr = -1
	for i in range(lens - 2, -1, -1):
		if int(array[i]) % 2 == 0:
			iterr = i
			break
	return iterr
num = input()
num2 = list(num)
first = 0
temp = 0
lens = len(num2)
temp = find_2(num2)
if temp == -1:
	temp = find_1(num2)
	if temp == -1:
		print(-1)
	else:
		temp2 = num2[-1]
		num2[-1] = num2[temp]
		num2[temp] = temp2
		for i in range(lens):
			print(num2[i], end='')
else:
	temp2 = num2[-1]
	num2[-1] = num2[temp]
	num2[temp] = temp2
	for i in range(lens):
		print(num2[i], end='')


s = list(input())
f = True
z = float('inf')
i1 = -1
for i in range(len(s)):
	if int(s[i]) % 2 == 0:
		f = False
		break
if f:
	print(-1)
else:
	a = -1
	for i in range(len(s)):
		if int(s[i]) % 2 == 0 and int(s[i]) < int(s[-1]):
			a = s[i]
			s[i] = s[-1]
			s[-1] = a
			print(''.join(map(str, s)))
			exit()
	for i in range(len(s) - 1, -1, -1):
		if int(s[i]) % 2 == 0 and int(s[i]) > int(s[-1]):
			a = s[i]
			s[i] = s[-1]
			s[-1] = a
			print(''.join(map(str, s)))
			exit()


x = input()
u = x[-1]
key = True
r = -1
for i in range(len(x) - 1):
	if not int(x[i]) % 2:
		key = False
		r = i
		if x[i] < u:
			break
if key:
	print(-1)
else:
	x = ''.join([x[0:r], x[-1], x[r + 1:len(x) - 1], x[r]])
	print(x)


s = input()
if not any([x in s for x in '02468']):
	print(-1)
	exit()
n = len(s) - 1
for i in range(n):
	if s[i] not in '02468':
		continue
	if s[i] < s[n]:
		print(s[:i], s[n], s[i + 1:n], s[i], s[n + 1:], sep='')
		exit()
for i in range(n - 1, -1, -1):
	if s[i] in '02468':
		print(s[:i], s[n], s[i + 1:n], s[i], s[n + 1:], sep='')
		exit()


N = input()
arr = []
for i in range(0, len(N) - 1):
	if int(N[i]) % 2 == 0:
		arr.append({'index': i, 'num': N[i]})
if len(arr) == 0:
	print('-1')
else:
	lastIndex = len(N) - 1
	lastNum = N[len(N) - 1]
	resIndex = -1
	resNum = -1
	for numDict in arr:
		if int(numDict['num']) < int(lastNum):
			resIndex = numDict['index']
			resNum = numDict['num']
			break
	if resIndex == -1:
		resIndex = arr[len(arr) - 1]['index']
		resNum = arr[len(arr) - 1]['num']
	print(N[0:resIndex] + lastNum + N[resIndex + 1:lastIndex] + resNum)


n = input()
nOdd = 0
for i in range(len(n)):
	if int(n[i]) % 2 == 1:
		nOdd += 1
if nOdd == len(n):
	print(-1)
else:
	lastDigit = int(n[-1])
	changedLoc = 0
	isSmall = 0
	even_val = []
	even_loc = []
	for i in range(len(n)):
		if int(n[i]) % 2 == 0:
			even_val.append(n[i])
			even_loc.append(i)
	for i in range(len(even_val)):
		if int(even_val[i]) < lastDigit:
			changedLoc = even_loc[i]
			isSmall = 1
			break
	if isSmall == 0:
		changedLoc = even_loc[-1]
	ans = ''
	for i in range(len(n) - 1):
		if i != changedLoc:
			ans += n[i]
		else:
			ans += n[-1]
	ans += n[changedLoc]
	print(ans)


str1 = input()
for i in range(len(str1)):
	if not int(str1[i]) % 2 and str1[-1] > str1[i]:
		print(str1[:i] + str1[-1] + str1[i + 1:-1] + str1[i])
		exit()
for i in range(len(str1) - 1, -1, -1):
	if not int(str1[i]) % 2:
		print(str1[:i] + str1[-1] + str1[i + 1:-1] + str1[i])
		exit()
print(-1)


def currency(s):
	if s is None:
		return None
	ls = list(s)
	n = ind = len(ls) - 1
	for i in range(len(ls)):
		if int(ls[i]) % 2 == 0:
			ind = i
			if int(ls[-1]) > int(ls[i]):
				break
	if n == ind:
		return -1
	else:
		(ls[ind], ls[-1]) = (ls[-1], ls[ind])
		return ''.join(ls)
mystr = str(input())
print(currency(mystr))


n = str(input())
op = []
l = len(n)
count = 0
count2 = 0
for i in range(l):
	if int(n[i]) % 2 == 0:
		count2 += 1
		if int(n[i]) < int(n[-1]):
			newstr = n[0:i] + n[-1] + n[i + 1:len(n) - 1] + n[i]
			print(newstr)
			break
		else:
			op.append(i)
	else:
		count += 1
if count == l:
	print(-1)
if count2 == len(op) and op != []:
	i = max(op)
	newstr = n[0:i] + n[-1] + n[i + 1:len(n) - 1] + n[i]
	print(newstr)


s = input()
s = list(s)
c = 0
flag = 0
for i in range(len(s)):
	if int(s[i]) % 2 == 0:
		c = i
		flag = 1
		if int(s[-1]) > int(s[i]):
			break
if flag == 0:
	print('-1')
else:
	temp = s[c]
	s[c] = s[-1]
	s[-1] = temp
	print(''.join(s))


n = list(map(int, input()))
first = True
tmp = len(n) - 1
for i in range(len(n) - 2, -1, -1):
	if first and n[i] % 2 == 0:
		tmp = i
		first = False
	elif n[i] % 2 == 0 and n[i] < n[-1]:
		tmp = i
(n[tmp], n[-1]) = (n[-1], n[tmp])
if n[-1] % 2 != 0:
	print(-1)
else:
	print(''.join(map(str, n)))


s = input()
mp = -1
f = 0
l = 0
n = len(s)
r = n - 1
ind = -1
while l <= r:
	if int(s[l]) % 2 == 0 or int(s[r]) % 2 == 0:
		f = 1
		break
	l += 1
	r -= 1
if f == 0:
	print(-1)
else:
	e = 0
	f = 0
	a = []
	ln = int(s[n - 1])
	for i in range(l, n):
		cn = int(s[i])
		if cn % 2 == 0:
			if cn < ln:
				mp = cn
				ind = i
				f = 1
				break
			elif cn >= ln:
				mp = cn
				ind = i
	ans = s[0:ind] + str(ln) + s[ind + 1:n - 1] + str(mp)
	print(ans)


s = input()
l = [int(i) for i in s]
n = len(l)
flag = 0
for i in range(n - 1):
	if l[i] < l[-1] and l[i] % 2 == 0:
		(l[i], l[-1]) = (l[-1], l[i])
		flag = 1
		break
if flag == 0:
	for i in range(n - 2, -1, -1):
		if l[i] % 2 == 0:
			(l[i], l[-1]) = (l[-1], l[i])
			flag = 1
			break
if flag == 0:
	print(-1)
else:
	s = ''
	for i in l:
		s += str(i)
	print(s)


n = list(input())
minn = -1
l = len(n)
j = l - 1
last = int(n[j])
flag = 0
index = None
for i in range(l):
	num = int(n[i])
	if num % 2 == 0:
		index = i
		if num < last:
			flag = 1
			(n[i], n[j]) = (n[j], n[i])
			print(''.join(n))
			break
if flag == 0 and index != None:
	(n[index], n[j]) = (n[j], n[index])
	print(''.join(n))
if index == None:
	print(-1)


import operator
import os, sys
from collections import defaultdict, Counter, deque
from functools import lru_cache
from io import BytesIO, IOBase
from itertools import accumulate
from math import gcd, ceil, inf, sqrt, floor
import math

def main():
	arr = [int(i) for i in input()]
	print
	end = len(arr) - 1
	last = arr[end]
	flag = False
	flag1 = False
	for i in range(0, len(arr)):
		if arr[i] % 2 == 0:
			idx = i
			flag1 = True
		if arr[i] % 2 == 0 and arr[i] < last:
			temp = arr[i]
			arr[i] = arr[end]
			arr[end] = temp
			flag = True
			break
	if flag1 == False:
		print(-1)
		return
	if flag == True:
		print(*arr, sep='')
		return
	else:
		temp = arr[idx]
		arr[idx] = arr[end]
		arr[end] = temp
		print(*arr, sep='')
		return
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')
main()


num_str = input()
numbers = list(map(int, list(num_str)))
unit = numbers[-1]
inds = []
for even in range(unit - 1, -1, -2):
	if str(even) in num_str:
		inds.append(num_str.index(str(even)))
	else:
		pass
if len(inds) != 0:
	found = min(inds)
	temp = numbers[found]
	numbers[found] = numbers[-1]
	numbers[-1] = temp
	print(''.join(list(map(str, numbers))))
else:
	inds = []
	for even in range(unit + 1, 9, 2):
		if str(even) in num_str:
			inds.append(num_str.rindex(str(even)))
		else:
			pass
	if len(inds) != 0:
		found = max(inds)
		temp = numbers[found]
		numbers[found] = numbers[-1]
		numbers[-1] = temp
		print(''.join(list(map(str, numbers))))
	else:
		print(-1)


from collections import deque, Counter, OrderedDict
from heapq import nsmallest, nlargest
from math import ceil, floor, log, log2, sqrt, gcd, factorial, pow, pi

def binNumber(n, size=4):
	return bin(n)[2:].zfill(size)

def iar():
	return list(map(int, input().split()))

def ini():
	return int(input())

def isp():
	return map(int, input().split())

def sti():
	return str(input())

def par(a):
	print(' '.join(list(map(str, a))))

def tdl(outerListSize, innerListSize, defaultValue=0):
	return [[defaultValue] * innerListSize for i in range(outerListSize)]

def sts(s):
	s = list(s)
	s.sort()
	return ''.join(s)

class pair:

	def __init__(self, f, s):
		self.fi = f
		self.se = s

	def __lt__(self, other):
		return (self.fi, self.se) < (other.fi, other.se)
a = list(map(int, list(sti())))
ev = 0
x = -1
for i in range(len(a)):
	if a[i] % 2 == 0:
		ev = 1
		x = i
		if a[len(a) - 1] > a[i]:
			break
if ev == 0:
	print(-1)
	quit()
(a[x], a[len(a) - 1]) = (a[len(a) - 1], a[x])
print(''.join(list(map(str, a))))


n = input()
l = list(n)
k = int(l[-1])
flag = False
ind = -1
for i in range(len(l) - 1):
	a = int(l[i])
	if a % 2 == 0:
		ind = i
		if k > a:
			(l[i], l[-1]) = (l[-1], l[i])
			flag = True
			break
		else:
			ind = i
if flag == True:
	print(''.join(l))
elif ind != -1:
	(l[ind], l[-1]) = (l[-1], l[ind])
	print(''.join(l))
else:
	print(-1)


from sys import stdin, stdout
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
n = list(is1())
p1 = None
for i in range(len(n) - 1)[::-1]:
	if int(n[i]) % 2 == 0:
		if not p1:
			p1 = i
		elif n[-1] > n[i]:
			p1 = i
if p1 != None:
	(n[-1], n[p1]) = (n[p1], n[-1])
	print(''.join(n))
else:
	print(-1)


num = list(input())
id = -1
for i in range(len(num)):
	if int(num[i]) % 2 == 0:
		id = i
		if int(num[i]) < int(num[len(num) - 1]):
			break
if id < 0:
	print(-1)
else:
	(num[-1], num[id]) = (num[id], num[-1])
	print(''.join(num))


line = str(input())
tail = int(line[-1])
mask = 0
flag = False
for idx in range(len(line)):
	curr = int(line[idx])
	if int(line[idx]) % 2 == 0:
		flag = True
		mask = idx
		if curr < tail:
			break
if flag:
	print(line[:mask] + str(tail) + line[mask + 1:-1] + line[mask])
else:
	print(-1)


n = input()
l = len(n)
odd = True
first = 0
last = 0
for i in range(l):
	if not int(n[i]) % 2:
		odd = False
		break
if odd:
	print(-1)
	exit(0)
for i in range(l):
	if not int(n[i]) % 2 and int(n[i]) < int(n[-1]):
		first = i
		print(n[:i] + n[-1] + n[i + 1:-1] + n[i])
		exit(0)
for i in range(l - 1, -1, -1):
	if not int(n[i]) % 2 and int(n[i]) > int(n[-1]):
		print(n[:i] + n[-1] + n[i + 1:-1] + n[i])
		exit(0)


def n_to_list(n):
	lst = []
	while n > 0:
		lst.append(n % 10)
		n //= 10
	lst.reverse()
	return lst

def answer(lst):
	last_digit = int(lst[-1])
	recent_even_index = 10 ** 10
	for i in range(len(lst)):
		if int(lst[i]) % 2 == 0:
			recent_even_index = i
			if int(lst[i]) < last_digit:
				(lst[i], lst[-1]) = (lst[-1], lst[i])
				return ''.join(lst)
	if recent_even_index == 10 ** 10:
		return -1
	(lst[recent_even_index], lst[-1]) = (lst[-1], lst[recent_even_index])
	return ''.join(lst)

def main():
	n = list(input())
	print(answer(n))
	return
main()


n = input()
curr = int(n)
dig = list(n)
dig = list(map(int, dig))
last = -1
for i in range(len(dig) - 2, -1, -1):
	if dig[i] % 2 == 0:
		if last == -1:
			last = i
		elif dig[i] < dig[-1]:
			last = i
if last == -1:
	print(-1)
else:
	(dig[-1], dig[last]) = (dig[last], dig[-1])
	print(''.join(map(str, dig)))


def tr(n1):
	r = ''
	for i in n1:
		r += ''.join(i)
	return r
n = list(map(int, input().rstrip()))
p = len(n)
j = -1
for i in range(p):
	if int(n[i]) % 2 != 0:
		continue
	j = i
	if n[i] < n[p - 1]:
		break
if j != -1:
	(n[p - 1], n[j]) = (n[j], n[p - 1])
	print(*n, sep='')
else:
	print(-1)


n = input()
ans = -1
l = len(n)
last = n[l - 1]
m = -1
for x in range(l - 1):
	if int(n[x]) % 2 == 0:
		m = x
		if int(n[x]) < int(n[-1]):
			break
if m == -1:
	print(-1)
else:
	print(n[0:m] + last + n[m + 1:-1] + n[m])


n = input()
x = len(n)
l = list(n)
m = -1
for i in range(x):
	if int(l[i]) % 2 == 0:
		m = i
		if int(l[i]) < int(l[-1]):
			(l[i], l[-1]) = (l[-1], l[i])
			print(''.join(l))
			exit(0)
if m >= 0:
	(l[m], l[-1]) = (l[-1], l[m])
	print(''.join(l))
	exit(0)
print(-1)


s = input()
a = int(s[-1])
A = []
d = -1
e = -1
for i in s:
	A.append(int(i))
c = 0
for j in range(0, len(A) - 1):
	if A[j] % 2 == 0 and A[-1] > A[j]:
		b = A[j]
		A[j] = A[-1]
		A[-1] = b
		c = 1
		break
	elif A[j] % 2 == 0 and A[-1] < A[j]:
		d = A[j]
		e = j
if c == 0 and e == -1:
	print(-1)
elif c == 0 and e != -1:
	A[e] = A[-1]
	A[-1] = d
	p = ''
	for k in range(0, len(A)):
		p = p + str(A[k])
	print(p)
elif c == 1:
	p = ''
	for k in range(0, len(A)):
		p = p + str(A[k])
	print(p)


num = list(input())
index = -1
n = int(num[len(num) - 1])
for i in range(len(num) - 2, -1, -1):
	n1 = int(num[i])
	if n1 % 2 == 0:
		if index == -1:
			index = i
		elif n1 < n:
			index = i
if index != -1:
	(num[index], num[len(num) - 1]) = (num[len(num) - 1], num[index])
else:
	print(-1)
if index != -1:
	print(''.join(num))


import sys
import math
import bisect

def solve(A):
	n = len(A)
	for i in range(n - 1):
		if A[i] % 2 == 0 and A[i] < A[-1]:
			(A[i], A[-1]) = (A[-1], A[i])
			return ''.join(list((str(a) for a in A)))
	for i in range(n - 1, -1, -1):
		if A[i] % 2 == 0:
			(A[i], A[-1]) = (A[-1], A[i])
			return ''.join(list((str(a) for a in A)))
	return '-1'

def main():
	s = input()
	A = []
	for c in s:
		A.append(ord(c) - ord('0'))
	print(solve(A))
main()


import sys
n = str(sys.stdin.readline())[:-1]
ans = -1
lastPos = len(n) - 1
i = lastPos
last = int(n[i])
if last % 2 == 0:
	ans = n
else:
	i = 0
	mn = 10
	mnPos = -1
	lastFounded = -1
	while i < lastPos:
		digit = int(n[i])
		if digit % 2 == 0:
			if last > digit:
				ans = n[0:i] + n[lastPos] + n[i + 1:len(n) - 1] + n[i]
				break
			else:
				lastFounded = i
		i = i + 1
	if lastFounded != -1 and ans == -1:
		i = lastFounded
		ans = n[0:i] + n[lastPos] + n[i + 1:len(n) - 1] + n[i]
print(ans)


import os
import sys
from io import BytesIO, IOBase

def solution(num):
	if not any((int(x) & 1 == 0 for x in set(num))):
		write(-1)
		return
	n = len(num)
	found = False
	for i in range(n):
		if int(num[i]) & 1 == 0 and int(num[i]) < int(num[-1]):
			write(num[:i] + num[-1] + num[i + 1:n - 1] + num[i])
			found = True
			return
		if not found and int(num[i]) & 1 == 0:
			last = i
	write(num[:last] + num[-1] + num[last + 1:n - 1] + num[last])

def main():
	num = input()
	solution(num)
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))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


def f(ind1, ind2):
	global s
	s = s[:ind1] + s[ind2] + s[ind1 + 1:ind2] + s[ind1]
	print(s)
s = input()
n = len(s)
x = int(s[-1])
for i in range(n - 1):
	if int(s[i]) % 2 == 0 and int(s[i]) < x:
		f(i, -1)
		break
else:
	for i in range(2, n + 1):
		if int(s[-i]) % 2 == 0:
			f(-i, -1)
			break
	else:
		print(-1)


s = input()
m = -1
for i in range(len(s)):
	if int(s[i]) & 1 == 0:
		m = i
		if int(s[i]) < int(s[-1]):
			break
if m == -1:
	print('-1')
	exit()
else:
	temp = list(s)
	(temp[m], temp[-1]) = (s[-1], s[m])
	for i in temp:
		print(i, end='')


l = list(input())
for i in range(len(l)):
	if l[i] < l[-1] and int(l[i]) % 2 != 1:
		(l[i], l[-1]) = (l[-1], l[i])
		exit(print(''.join(l)))
for i in range(len(l) - 1, -1, -1):
	if int(l[i]) % 2 != 1:
		(l[i], l[-1]) = (l[-1], l[i])
		exit(print(''.join(l)))
print(-1)


num = input()
if int(num[len(num) - 1]) % 2 == 0:
	print('-1')
else:
	units = int(num[len(num) - 1])
i = len(num) - 1
dgt = []
while i >= 0:
	temp = int(num[i])
	dgt.append(temp)
	i -= 1
temp1 = 10
index = 0
for x in range(1, len(num)):
	if dgt[x] % 2 == 0 and dgt[x] < units:
		temp1 = dgt[x]
		index = x
if temp1 == 10:
	for x in range(1, len(num)):
		if dgt[x] % 2 == 0 and dgt[x] > units:
			temp1 = dgt[x]
			index = x
			break
number = ''
if temp1 == 10:
	print('-1')
else:
	dgt[index] = units
	dgt[0] = temp1
	for y in range(0, len(num)):
		number = number + str(dgt[len(num) - 1 - y])
	print(number)


n = input()
sl = []
fuckanton = 0
for i in n:
	sl += [int(i)]
	if int(i) % 2 == 0:
		fuckanton = 1
if fuckanton == 0:
	print('-1')
	exit()
sl = sl[::-1]
away = 0
for i in range(1, len(sl)):
	if sl[i] % 2 == 0 and sl[0] > sl[i]:
		away = i
near = 0
for i in range(1, len(sl)):
	if sl[i] % 2 == 0:
		near = i
		break
if away != 0:
	tmp = sl[0]
	sl[0] = sl[away]
	sl[away] = tmp
	sl = sl[::-1]
	ans = ''
	for i in sl:
		ans += str(i)
	print(ans)
else:
	tmp = sl[0]
	sl[0] = sl[near]
	sl[near] = tmp
	sl = sl[::-1]
	ans = ''
	for i in sl:
		ans += str(i)
	print(ans)


def cin():
	return map(int, input().split())
import collections
n = input()
a = [int(i) for i in n]
even = []
for i in range(len(a)):
	if not a[i] % 2:
		even.append(i)
if not even:
	exit(print(-1))
ans = even[-1]
for i in range(len(even) - 1, -1, -1):
	if a[-1] > a[even[i]]:
		ans = even[i]
(a[ans], a[-1]) = (a[-1], a[ans])
print(''.join((str(i) for i in a)))


n = list(input())
n = list(map(int, n))
ans = n.copy()
for i in range(len(n)):
	if n[i] % 2 == 0:
		if n[i] < n[-1]:
			(n[i], n[-1]) = (n[-1], n[i])
			break
if n != ans:
	print(''.join(map(str, n)))
else:
	for j in range(len(n) - 1, -1, -1):
		if n[j] % 2 == 0:
			(n[j], n[-1]) = (n[-1], n[j])
			break
	if n != ans:
		print(''.join(map(str, n)))
	else:
		print(-1)


n = input()
temp = int(n[len(n) - 1])
index = -1
for i in range(len(n)):
	num = int(n[i])
	if num % 2 == 0 and num < temp:
		index = i
		break
if index == -1:
	for i in range(len(n)):
		num = int(n[i])
		if num % 2 == 0:
			index = i
	if index == -1:
		print(-1)
	else:
		for i in range(len(n)):
			if i == index:
				print(temp, end='')
			elif i == len(n) - 1:
				print(n[index], end='')
			else:
				print(n[i], end='')
else:
	for i in range(len(n)):
		if i == index:
			print(temp, end='')
		elif i == len(n) - 1:
			print(n[index], end='')
		else:
			print(n[i], end='')


string1 = list(input())
answer = -1
answer1 = 0
for (i, value) in enumerate(string1):
	if int(value) % 2 == 0:
		answer = i
		if int(string1[i]) < int(string1[-1]):
			break
answer1 = string1[answer]
string1[answer] = string1[-1]
string1[-1] = answer1
if answer < 0:
	print(answer)
else:
	print(''.join(string1))


n = input()
lst = list(n)
leng = len(lst)
lst[leng - 1] = int(lst[leng - 1])
changeup = leng - 1
flag = 0
for i in range(leng - 2, -1, -1):
	lst[i] = int(lst[i])
	if lst[i] % 2 == 0:
		if flag == 0:
			changeup = i
			flag = 1
		elif lst[i] < lst[leng - 1]:
			changeup = i
		else:
			continue
stri = ''
(lst[changeup], lst[leng - 1]) = (lst[leng - 1], lst[changeup])
for i in range(0, leng):
	stri = stri + str(lst[i])
if changeup == leng - 1:
	print(-1)
else:
	print(stri)


s = list(input())
f1 = f2 = 0
l = len(s)
for i in range(l - 1):
	if ord(s[i]) % 2 == 0 and s[i] < s[-1]:
		f1 = 1
		(s[i], s[-1]) = (s[-1], s[i])
		break
if not f1:
	for i in range(l - 1, -1, -1):
		if ord(s[i]) % 2 == 0 and s[i] > s[-1]:
			f2 = 1
			(s[i], s[-1]) = (s[-1], s[i])
			break
if f1 or f2:
	print(''.join(s))
else:
	print(-1)


s = input()
c = s[len(s) - 1]
val = -1
for i in range(len(s)):
	if int(s[i]) % 2 == 0:
		val = i
		if int(s[i]) < int(c):
			break
if val == -1:
	print(val)
else:
	temp = s[val]
	s = s[:val] + c + s[val + 1:len(s) - 1]
	s += temp
	print(s)


s = list(input())
even = -1
ind = -1
for i in range(len(s)):
	if int(s[i]) % 2 == 0 and int(s[i]) < int(s[-1]):
		even = int(s[i])
		ind = i
		break
	elif int(s[i]) % 2 == 0:
		even = int(s[i])
		ind = i
if even == -1:
	print(-1)
else:
	(s[-1], s[ind]) = (s[ind], s[-1])
	print(''.join(s))


l = list(map(int, input()))[::-1]
z = [2, 4, 6, 8, 0]
if 2 in l or 4 in l or 6 in l or (8 in l) or (0 in l):
	for i in range(len(l) - 1, 0, -1):
		if l[i] in z and l[i] < l[0]:
			l = list(map(str, l))
			print(''.join([l[i], ''.join(l[1:i]), l[0], ''.join(l[i + 1:])])[::-1])
			break
	else:
		for i in range(1, len(l)):
			if l[i] in z:
				l = list(map(str, l))
				print(''.join([l[i], ''.join(l[1:i]), l[0], ''.join(l[i + 1:])])[::-1])
				break
else:
	print(-1)


n = [int(x) for x in list(input())]
l = len(n)
d = -1
z = -1
for i in range(l):
	if n[i] % 2 == 0:
		d = i
		if n[i] < n[-1]:
			z = 0
			x = n[-1]
			n[-1] = n[i]
			n[i] = x
			break
n = [str(i) for i in n]
if z == 0:
	print(''.join(n))
elif d == -1:
	print(-1)
else:
	x = n[d]
	n[d] = n[-1]
	n[-1] = x
	print(''.join(n))


x = input()
pos = -1
last = ord(x[-1]) - 48
for (i, c) in enumerate(x):
	cur = ord(c) - 48
	if not cur & 1:
		pos = i
		if last > cur:
			print(x[:i] + x[-1] + x[i + 1:-1] + x[i])
			break
else:
	if pos != -1:
		print(x[:pos] + x[-1] + x[pos + 1:-1] + x[pos])
	else:
		print(-1)


raw = input()
raw = list(raw)
raw = [int(x) for x in raw]
flag = 0
lst = []
for x in raw:
	if x % 2 == 0:
		flag = 1
		lst.append(x)
if flag == 1:
	lst = sorted(lst)
	l = raw[-1]
	if lst[0] > l:
		for x in reversed(raw):
			if x % 2 == 0:
				s = x
				break
		i = [i for (i, x) in enumerate(raw) if x == s]
		raw[i[-1]] = l
		raw[-1] = s
		raw = [str(x) for x in raw]
		print(''.join(raw))
	else:
		for x in raw:
			if x % 2 == 0:
				if x < l:
					s = x
					break
		raw[-1] = s
		raw[raw.index(s)] = l
		raw = [str(x) for x in raw]
		print(''.join(raw))
else:
	print(-1)


x = list(input())
ind = -1
for i in range(len(x)):
	if int(x[i]) % 2 == 0 and int(x[i]) < int(x[-1]):
		ind = i
		break
if ind == -1:
	for i in range(len(x)):
		if int(x[i]) % 2 == 0 and int(x[i]) > int(x[-1]):
			ind = i
if ind == -1:
	print(-1)
else:
	(x[ind], x[-1]) = (x[-1], x[ind])
	print(''.join(x))


n = input()
l1 = list(n)
k = l1.copy()
f = 0
maxi = 0
for i in range(len(l1)):
	if int(l1[i]) % 2 == 0 and int(l1[i]) < int(l1[len(l1) - 1]):
		f = 1
		c = l1[len(l1) - 1]
		l1[len(l1) - 1] = l1[i]
		l1[i] = c
		break
if f == 0:
	for i in range(len(l1)):
		if int(l1[len(l1) - i - 1]) % 2 == 0:
			f = 2
			c = l1[len(l1) - i - 1]
			l1[len(l1) - i - 1] = l1[len(l1) - 1]
			l1[len(l1) - 1] = c
			break
if f == 1 or f == 2:
	for i in l1:
		print(i, end='')
else:
	print(-1)


s = input()
a = [int(x) for x in s]
pos = -1
for i in range(len(a) - 1):
	if a[i] % 2 == 0:
		pos = i
		if a[i] < a[-1]:
			tmp = a[i]
			a[i] = a[-1]
			a[-1] = tmp
			for ele in a:
				print(ele, end='')
			exit()
if pos == -1:
	print('-1')
else:
	tmp = a[pos]
	a[pos] = a[-1]
	a[-1] = tmp
	for ele in a:
		print(ele, end='')


n = input()
(k, m) = (0, -1)
for i in n:
	if int(i) % 2 == 0:
		if int(n[len(n) - 1]) > int(i):
			m = 0
			k = n.index(i)
			break
		else:
			m = 0
			if n.count(i) > 1:
				k = len(n) - 1 - n[::-1].index(i)
				if k == len(n) - 2:
					break
			else:
				k = n.index(i)
		m = int(i)
		if int(n[len(n) - 1]) > m and n[k + 1:].count(str(m)) == 0:
			break
if m == -1:
	print('-1')
else:
	print(n[:k] + n[len(n) - 1] + n[k + 1:len(n) - 1] + n[k])


b = str(input())
maxval = str(-1)
lol = int(b[-1])
for i in range(len(b)):
	if (b[i] == '0' or b[i] == '2' or b[i] == '4' or (b[i] == '6') or (b[i] == '8')) and int(b[i]) < lol:
		c = b[:i] + b[len(b) - 1] + b[i + 1:len(b) - 1] + b[i]
		maxval = max(maxval, c)
		break
for i in range(len(b) - 1, -1, -1):
	if (b[i] == '0' or b[i] == '2' or b[i] == '4' or (b[i] == '6') or (b[i] == '8')) and int(b[i]) > lol:
		d = b[:i] + b[len(b) - 1] + b[i + 1:len(b) - 1] + b[i]
		maxval = max(maxval, d)
		break
print(maxval)


s = input()
mx_idx = None
last_even_idx = None
last = int(s[-1])
for (i, digit) in enumerate(s):
	digit = int(digit)
	if digit % 2 == 0:
		last_even_idx = i
		if digit < last:
			mx_idx = i
			break
if mx_idx == None and last_even_idx != None:
	front = s[:last_even_idx]
	back = s[last_even_idx + 1:-1]
	print(front + str(last) + back + str(s[last_even_idx]))
elif mx_idx != None:
	front = s[:mx_idx]
	back = s[mx_idx + 1:-1]
	print(front + str(last) + back + str(s[mx_idx]))
else:
	print(-1)


n = input()
max_n = -1
for i in range(len(n) - 1):
	if int(n[i]) % 2 == 0:
		max_n = i
		if int(n[i]) < int(n[-1]):
			break
print(-1 if max_n == -1 else n[:max_n] + n[-1] + n[max_n + 1:-1] + n[max_n])


n = input()
t = -1
if '0' in n or '2' in n or '4' in n or ('6' in n) or ('8' in n):
	l = len(n)
	a = int(n[l - 1])
	t = n[0:l - 1]
	f = True
	for i in range(0, l - 1):
		b = int(n[i])
		if b % 2 == 0 and a > b:
			t = t.replace(str(b), str(a), 1)
			t += str(b)
			f = False
			break
	if f:
		ss = ''
		ff = True
		for i in range(l - 2, -1, -1):
			if ff and int(n[i]) % 2 == 0:
				b = n[i]
				ss += str(a)
				ff = False
			else:
				ss += n[i]
		strr = ''
		for i in range(l - 2, -1, -1):
			strr += ss[i]
		strr += b
		t = strr
print(t)


s = input()
n = len(s)
ans = 0
id = -1
c = ord(s[n - 1]) - 48
for i in range(n - 1, -1, -1):
	x = ord(s[i]) - 48
	if x % 2 == 0:
		ans += 1
		if ans == 1:
			id = i
		if c > x:
			id = i
if ans == 0:
	print(-1)
else:
	i = id
	j = n - 1
	s = ''.join((s[:i], s[j], s[i + 1:j], s[i], s[j + 1:]))
	print(s)


a = list(input())
reach = False
lastnum = -1
last = int(a[-1])
for x in range(len(a)):
	if int(a[x]) % 2 == 0 and int(a[x]) < last:
		reach = True
		b = a[:]
		b[-1] = a[x]
		b[x] = a[-1]
		print(''.join(b))
		break
	elif int(a[x]) % 2 == 0:
		lastnum = x
if not reach:
	if lastnum == -1:
		print(-1)
	else:
		x = lastnum
		b = a[:]
		b[-1] = a[x]
		b[x] = a[-1]
		print(''.join(b))


n = input()
cnt = n.count('0') + n.count('2') + n.count('4') + n.count('6') + n.count('8')
b = list()
c = len(n)
for i in range(c):
	b.append(n[i])
if cnt != 0:
	j = -1
	m = 10
	for i in range(c):
		if int(n[i]) % 2 == 0 and int(n[i]) < int(n[-1]):
			j = i
			break
	if j == -1:
		m = 0
		for i in range(c):
			if int(n[i]) % 2 == 0 and int(n[i]) > int(n[-1]):
				j = i
				m = int(n[i])
	(b[j], b[c - 1]) = (b[c - 1], b[j])
	print(*b, sep='')
else:
	print(-1)


def swap(index, i, str1):
	temp = str1[index]
	str1[index] = str1[i]
	str1[i] = temp
	return str1
str1 = input()
index = -1
for i in range(len(str1)):
	if int(str1[i]) & 1 == 0:
		index = i
		if str1[i] < str1[-1]:
			break
if index == -1:
	print(-1)
else:
	temp = swap(index, len(str1) - 1, list(str1))
	for i in range(len(temp)):
		print(temp[i], end='')
	print('')


import re
n = input()
match = re.findall('[02468]', n)
if len(match) == 0:
	print(-1)
	quit()
for i in match:
	if i < n[-1]:
		position = re.search(i, n).span()[0]
		print(n[:position], end='')
		print(n[-1], end='')
		print(n[position + 1:-1], end='')
		print(i)
		quit()
match = re.findall('[02468]', ''.join(list(reversed(list(n)))))
for i in match:
	if i > n[-1]:
		position = -1 * re.search(i, ''.join(list(reversed(list(n))))).span()[0] - 1
		print(n[:position], end='')
		print(n[-1], end='')
		print(n[position + 1:-1], end='')
		print(i)
		quit()


import sys

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

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
A = list(input())
last = int(A[-1])
last_even = -1
flag = False
for i in range(len(A) - 1):
	m = int(A[i])
	if m % 2 == 0:
		if m < last:
			(A[i], A[-1]) = (A[-1], A[i])
			flag = True
			break
		else:
			last_even = i
if flag:
	print(''.join(A))
elif last_even == -1:
	print(-1)
else:
	(A[last_even], A[-1]) = (A[-1], A[last_even])
	print(''.join(A))


def solve():
	string = input()
	n = len(string)
	indx = -1
	isdone = 0
	for i in range(n - 1):
		if int(string[i]) % 2 == 0:
			indx = i
			if int(string[i]) < int(string[-1]):
				isdone = 1
				print(string[:i] + string[-1] + string[i + 1:-1] + string[i])
				break
	if isdone == 0:
		if indx == -1:
			print(-1)
		else:
			print(string[:indx] + string[-1] + string[indx + 1:-1] + string[indx])
	return
t = 1
while t != 0:
	solve()
	t -= 1


s = input()
new = []
even = 0
for x in s:
	new.append(int(x))
	if int(x) % 2 == 0:
		even += 1
n = len(s)
odd = new[n - 1]
flag = False
for i in range(n - 1):
	if new[i] % 2 == 0 and new[i] < new[n - 1]:
		temp = new[i]
		new[i] = new[n - 1]
		new[n - 1] = temp
		flag = True
		break
if not flag:
	for i in range(n - 2, -1, -1):
		if new[i] % 2 == 0:
			temp = new[i]
			new[i] = new[n - 1]
			new[n - 1] = temp
			break
if even == 0:
	print('-1')
else:
	for x in new:
		print(x, end='')


list1 = list(map(int, input()))
f = 0
n = len(list1)
for i in range(n):
	if list1[i] % 2 == 0 and list1[i] < list1[-1]:
		(list1[i], list1[-1]) = (list1[-1], list1[i])
		f = 1
		break
if f == 0:
	for i in range(n - 1, -1, -1):
		if list1[i] % 2 == 0 and list1[i] > list1[-1]:
			(list1[i], list1[-1]) = (list1[-1], list1[i])
			f = 1
			break
if f == 1:
	for i in range(n):
		print(list1[i], end='')
else:
	print(-1)


s = list(input())
ans = -1
n = len(s)
last = -1
for i in range(n):
	if ord(s[i]) - ord('0') & 1 == 0:
		last = i
		if s[i] < s[-1]:
			(s[i], s[-1]) = (s[-1], s[i])
			print(''.join(s))
			exit(0)
if last == -1:
	print(last)
	exit(0)
(s[last], s[-1]) = (s[-1], s[last])
print(''.join(s))


a = [int(x) for x in list(input())]
ok = False
for i in a:
	if i % 2 == 0:
		ok = True
		break
if not ok:
	print(-1)
else:
	ok = False
	for i in range(len(a) - 1):
		if a[i] % 2 == 0 and a[i] < a[-1]:
			ok = True
			(a[i], a[-1]) = (a[-1], a[i])
			break
	if ok:
		print(''.join([str(x) for x in a]))
	else:
		for i in range(len(a) - 2, -1, -1):
			if a[i] % 2 == 0 and a[i] > a[-1]:
				ok = True
				(a[i], a[-1]) = (a[-1], a[i])
				break
		print(''.join([str(x) for x in a]))


a = list(str(input()))
p = [0] * (len(a) - 1)
flag = 0
swap = -1
index = 0
for i in range(len(a) - 1):
	p[i] = int(a[i])
for i in range(len(p)):
	if p[i] % 2 == 0:
		swap = p[i]
		index = i
		if int(a[len(a) - 1]) > swap or swap > p[i]:
			break
if swap == -1:
	print(-1)
else:
	for i in range(len(a)):
		if int(a[i]) == swap and index == i:
			print(int(a[len(a) - 1]), end='')
		elif len(a) - 1 == i:
			print(swap, end='')
		else:
			print(int(a[i]), end='')


N = input()
if not ('0' in N or '2' in N or '4' in N or ('6' in N) or ('8' in N)):
	print(-1)
	exit()
smalls = [i for i in '02468'[:(int(N[-1]) + 1) // 2]]
bigs = [i for i in '02468'[(int(N[-1]) + 1) // 2:]]
for i in range(len(N)):
	if N[i] in smalls:
		N = N[:i] + N[-1] + N[i + 1:-1] + N[i]
		print(N)
		exit()
for i in range(len(N))[::-1]:
	if N[i] in bigs:
		N = N[:i] + N[-1] + N[i + 1:-1] + N[i]
		print(N)
		exit()


import sys

def fn(s):
	s = list(s)
	i = 0
	k = []
	while i < len(s):
		if int(s[i]) % 2 == 0:
			if int(s[i]) < int(s[len(s) - 1]):
				t = s[i]
				s[i] = s[len(s) - 1]
				s[len(s) - 1] = t
				return s
			if int(s[i]) > int(s[len(s) - 1]):
				k.append(i)
		i = i + 1
	if len(k) != 0:
		i = k[len(k) - 1]
		t = s[i]
		s[i] = s[len(s) - 1]
		s[len(s) - 1] = t
		return s
	return ['-1']
input = sys.stdin.read()
data = list(map(str, input.split()))
s = data[0]
print(''.join(fn(s)))


n = input()
p = '-1'
s = 0
for i in range(0, len(n) - 1):
	if int(n[i]) % 2 == 0 and int(n[i]) < int(n[len(n) - 1]):
		k = n[i]
		s = 1
		p = n[0:i] + n[len(n) - 1] + n[i + 1:len(n) - 1] + k
		break
if s != 1:
	for i in range(len(n) - 1, -1, -1):
		if int(n[i]) % 2 == 0:
			k = n[i]
			p = n[0:i] + n[len(n) - 1] + n[i + 1:len(n) - 1] + k
			break
print(p)


n = input()
p = -1
m = 100
for i in range(len(n) - 1):
	if int(n[i]) % 2 == 0 and int(n[i]) < int(n[-1]):
		new = n[:i] + n[-1] + n[i + 1:-1] + n[i]
		p = 1
		break
if p == -1:
	for i in range(len(n) - 1, -1, -1):
		if int(n[i]) % 2 == 0:
			new = n[:i] + n[-1] + n[i + 1:-1] + n[i]
			p = 1
			break
if p == 1:
	print(new)
else:
	print(p)


from sys import stdin, stdout
input = stdin.readline
n = input()[:-1]
sw = -1
for i in range(len(n) - 1):
	if int(n[i]) % 2 == 0:
		if n[i] < n[-1]:
			stdout.write(n[:i] + n[-1] + n[i + 1:-1])
			stdout.write(n[i])
			exit(0)
		else:
			sw = i
if sw != -1:
	stdout.write(n[:sw] + n[-1] + n[sw + 1:-1] + n[sw])
else:
	stdout.write('-1')


num = input()
res = '-1'
l = len(num)
a = int(num[l - 1])
n = []
for i in range(l):
	n.append(num[i])
flag = 1
i = 0
while flag and i < l:
	if int(num[i]) % 2 == 0 and int(num[i]) < a:
		n[l - 1] = n[i]
		n[i] = str(a)
		flag = 0
		s = ''.join(n)
		res = s
	i += 1
i = l - 1
while flag and i >= 0:
	if int(num[i]) % 2 == 0:
		n[l - 1] = n[i]
		n[i] = str(a)
		flag = 0
		s = ''.join(n)
		res = s
	i -= 1
print(res)


n = input()
k = -1
k2 = -1
for i in range(len(n)):
	if int(n[i]) % 2 == 0:
		if n[i] < n[-1]:
			k = i
			break
		else:
			k2 = i
if k == -1 and k2 == -1:
	print(-1)
elif k != -1:
	print(n[:k] + n[-1] + n[k + 1:-1] + n[k])
else:
	print(n[:k2] + n[-1] + n[k2 + 1:-1] + n[k2])


n = input()
ar = []
ln = len(n)
for x in range(ln):
	if int(n[x]) % 2 == 0:
		if n[x] < n[-1]:
			ar.append('+')
		else:
			ar.append('-')
	else:
		ar.append('.')
q = -1
for x in range(ln):
	if ar[x] == '+':
		q = x
		break
z = -1
for x in range(ln - 1, -1, -1):
	if ar[x] == '-':
		z = x
		break
if z == -1 and q == -1:
	print(-1)
	exit(0)
elif q != -1:
	print(n[:q] + n[-1] + n[q + 1:ln - 1] + n[q])
	exit(0)
else:
	print(n[:z] + n[-1] + n[z + 1:ln - 1] + n[z])
	exit(0)


nr = input()
ok = 0
for i in nr:
	if int(i) % 2 == 0:
		ok = 1

def swap(a, b, l):
	la = l[a]
	lb = l[b]
	nl = l[:a] + lb + l[a + 1:b] + la
	if b != -1:
		nl += l[b + 1:]
	return nl
if ok == 0:
	print(-1)
else:
	lg = len(nr)
	if int(nr[-1]) % 2 == 0:
		lg -= 1
		max_p = nr
		max_r = nr
		for i in range(lg):
			if int(nr[i]) % 2 == 0 and nr[i] < nr[-1]:
				max_p = swap(i, -1, nr)
				break
		poz_mc = -1
		max_cif = 0
		while poz_mc < lg:
			for i in range(poz_mc + 1, lg):
				if int(nr[i]) >= max_cif:
					max_cif = int(nr[i])
					poz_mc = i
			for i in range(poz_mc):
				if nr[i] < max_cif:
					max_r = swap(poz_mc, i, nr)
					poz_mc = lg
					break
		nr = max(max_p, max_r)
	else:
		ok = 1
		for i in range(lg):
			if int(nr[i]) % 2 == 0 and nr[i] < nr[-1]:
				ok = 0
				nr = swap(i, -1, nr)
				break
		if ok == 1:
			for i in range(lg - 1, -1, -1):
				if int(nr[i]) % 2 == 0:
					nr = swap(i, -1, nr)
					break
	print(nr)


n = input()
a = [int(x) for x in str(n)]
even = []
f = 0
for i in range(len(n)):
	if a[i] % 2 == 0:
		even.append([i, a[i]])
		f = 1
if f == 0:
	print('-1')
else:
	x = 0
	f = 1
	x = a[len(a) - 1]
	for i in range(len(even)):
		if x > even[i][1]:
			(a[len(a) - 1], a[even[i][0]]) = (a[even[i][0]], a[len(a) - 1])
			f = 0
			break
	if f == 1:
		(a[len(a) - 1], a[even[len(even) - 1][0]]) = (a[even[len(even) - 1][0]], a[len(a) - 1])
	a = [str(x) for x in a]
	print(''.join(a))


import math

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

def comb(n, c):
	return fact(n) // (fact(n - c) * c)
s = list(str(input()))
swap = -1
done = False
for i in range(len(s) - 1):
	if int(s[-1]) > int(s[i]) and int(s[i]) % 2 == 0:
		(s[i], s[-1]) = (s[-1], s[i])
		swap = i
		done = True
		break
	elif int(s[i]) % 2 == 0:
		swap = i
if not done:
	(s[-1], s[swap]) = (s[swap], s[-1])
if swap == -1:
	print(-1)
else:
	print(''.join(s))


import math
import sys
debug = False
if debug:
	fin = open('input.txt', 'r')
	fout = open('output.txt', 'w')
else:
	fin = sys.stdin
	fout = sys.stdout
s = fin.readline()[:-1]
a = '-1'
n = len(s)
j = -1
for i in range(len(s)):
	if int(s[i]) % 2 == 0:
		if j == -1:
			j = i
		elif s[j] > s[-1]:
			j = i
if j > -1:
	a = s[0:j] + s[-1] + s[j + 1:-1] + s[j]
fout.write(a)


n = list(input())
l = len(n)
last_smallest = -1
first_largest = -1
last_digit = int(n[l - 1])
ans = -1
for i in range(l - 1):
	d = int(n[i])
	if d % 2 == 0:
		if d < last_digit:
			first_largest = i
			break
		else:
			last_smallest = i
if last_smallest == first_largest == -1:
	print(-1)
elif first_largest == -1:
	n[l - 1] = n[last_smallest]
	n[last_smallest] = str(last_digit)
	print(''.join(n))
else:
	n[l - 1] = n[first_largest]
	n[first_largest] = str(last_digit)
	print(''.join(n))


n = input()
ok = False
if int(n[-1]) % 2 == 1:
	for i in range(len(n)):
		if int(n[i]) < int(n[-1]) and int(n[i]) % 2 == 0:
			n = n[:i] + n[-1:] + n[i + 1:-1] + n[i:i + 1]
			ok = True
			break
	if ok:
		print(n)
	else:
		for i in range(len(n) - 2, -1, -1):
			if int(n[i]) % 2 == 0:
				n = n[:i] + n[-1:] + n[i + 1:-1] + n[i:i + 1]
				ok = True
				break
		if ok:
			print(n)
		else:
			print(-1)


n = input()
n = [int(i) for i in n]
has_even = 0
for i in n:
	if i % 2 == 0:
		has_even = 1
		break
if has_even == 0:
	print(-1)
else:
	max_even = -1
	last_num = n[-1]
	for i in range(len(n)):
		if n[i] % 2 == 0 and last_num > n[i]:
			max_even = i
			break
	if max_even != -1:
		(n[max_even], n[-1]) = (n[-1], n[max_even])
	else:
		for i in range(len(n) - 1, -1, -1):
			if n[i] % 2 == 0:
				max_even = i
				break
		(n[max_even], n[-1]) = (n[-1], n[max_even])
	print(''.join(map(str, n)))


n = list(input())
f = False
frst = -10 ** 7
for i in range(len(n)):
	if int(n[i]) % 2 == 0:
		frst = max(i, frst)
		if int(n[i]) < int(n[-1]):
			(n[i], n[-1]) = (n[-1], n[i])
			f = True
			break
if not f and frst != -10 ** 7:
	(n[frst], n[-1]) = (n[-1], n[frst])
	f = True
print(''.join(n) if f else '-1')


n = input()
digs = []
edigs = []
for i in range(len(n)):
	digs.append(int(n[i]))
	if int(n[i]) % 2 == 0:
		edigs.append([int(n[i]), i])
if len(edigs) is 0:
	print(-1)
else:
	cool = len(edigs)
	for i in range(len(edigs)):
		if edigs[i][0] < digs[-1]:
			cool = min(cool, i)
	if cool == len(edigs):
		digs[edigs[-1][1]] = digs[-1]
		digs[-1] = edigs[-1][0]
	else:
		digs[edigs[cool][1]] = digs[-1]
		digs[-1] = edigs[cool][0]
	ans = ''
	for element in digs:
		ans += str(element)
	print(ans)


n = input()
flag = 0
for (j, i) in enumerate(n):
	if i == '0' or i == '2' or i == '4' or (i == '6') or (i == '8'):
		flag = 1
		temp = j
		if str(n[len(n) - 1]) > i:
			print(f'{n[0:j]}{n[len(n) - 1]}{n[j + 1:len(n) - 1]}{n[j]}')
			exit()
if flag == 0:
	print('-1')
	exit()
else:
	j = temp
	print(f'{n[0:j]}{n[len(n) - 1]}{n[j + 1:len(n) - 1]}{n[j]}')


arr = []
for i in input():
	arr.append(int(i))
ans1 = -1
n = len(arr)
for (i, x) in enumerate(arr):
	if x % 2 == 0:
		ans1 = i
if ans1 == -1:
	print(-1)
else:
	ans2 = -1
	for i in range(len(arr) - 1, -1, -1):
		if arr[i] % 2 == 0 and arr[i] < arr[len(arr) - 1]:
			ans2 = i
	if ans2 == -1:
		(arr[n - 1], arr[ans1]) = (arr[ans1], arr[n - 1])
	else:
		(arr[n - 1], arr[ans2]) = (arr[ans2], arr[n - 1])
	for i in arr:
		print(i, end='')


n = input()
flag = False
last = int(n[-1])
for i in range(len(n)):
	if int(n[i]) % 2 == 0:
		if last > int(n[i]):
			flag = True
			print(n[:i] + str(last) + n[i + 1:-1] + n[i])
			break
if flag is False:
	for i in range(len(n) - 1, -1, -1):
		if int(n[i]) % 2 == 0:
			flag = True
			print(n[:i] + str(last) + n[i + 1:-1] + n[i])
			break
if flag == False:
	print(-1)


current = list(input())
even = []
swap = int(current[-1])
for j in range(len(current)):
	if int(current[j]) % 2 == 0:
		even.append(j)
if len(even) == 0:
	print('-1')
else:
	for i in range(len(even)):
		if int(current[even[i]]) < swap or i == len(even) - 1:
			(current[even[i]], current[-1]) = (current[-1], current[even[i]])
			break
	tomorrow = ''.join(current)
	print(tomorrow)


def currency(s):
	n = len(s)
	current_less_index = None
	for i in range(n):
		if int(s[i]) % 2 == 0 and int(s[i]) < int(s[-1]):
			return s[:i] + s[-1] + s[i + 1:-1] + s[i]
		elif int(s[i]) % 2 == 0 and int(s[i]) > int(s[-1]):
			current_less_index = i
	if current_less_index != None:
		return s[:current_less_index] + s[-1] + s[current_less_index + 1:-1] + s[current_less_index]
	return -1
t = input()
print(currency(t))


s = input().strip()
ls = len(s)
result = list(s)
swapped = False
last_int_index = -1
for i in range(ls):
	if int(s[i]) % 2 == 0:
		last_int_index = i
		if int(s[-1]) > int(s[i]):
			result[i] = s[-1]
			result[-1] = s[i]
			swapped = True
			break
if swapped:
	print(''.join(result))
elif last_int_index == -1:
	print(-1)
else:
	result[last_int_index] = s[-1]
	result[-1] = s[last_int_index]
	print(''.join(result))


s = list(map(int, list(input())))
n = len(s)
if s[n - 1] % 2 != 0:
	for i in range(n - 1):
		if s[i] % 2 == 0 and s[i] < s[n - 1]:
			(s[i], s[n - 1]) = (s[n - 1], s[i])
			break
	if s[n - 1] % 2 != 0:
		for i in range(n - 1, -1, -1):
			if s[i] % 2 == 0:
				(s[i], s[n - 1]) = (s[n - 1], s[i])
				break
	if s[n - 1] % 2 != 0:
		(s, n) = ([-1], 1)
else:
	count = [-1] * 10
	for i in range(n):
		count[s[i]] = i
	for i in range(n - 1):
		maximized = False
		for j in range(9, -1, -1):
			if count[j] > 0 and s[i] < j and (i < count[j]):
				maximized = True
				(s[i], s[count[j]]) = (s[count[j]], s[i])
				break
		if maximized:
			break
print(''.join(map(str, s)))


s = input().rstrip()
s = [int(i) for i in s]
flag = 0
ind1 = 0
for i in range(len(s) - 1):
	if s[i] % 2 == 0:
		if s[i] < s[-1]:
			ind1 = i
			flag = 1
			break
		ind1 = i
		flag = 1
if flag == 1:
	(s[-1], s[ind1]) = (s[ind1], s[-1])
	print(''.join((str(e) for e in s)))
else:
	print(-1)


n = list(input())
h = 0
u = -1
for j in range(len(n)):
	if int(n[j]) % 2 == 0:
		if n[j] < n[-1]:
			(n[j], n[-1]) = (n[-1], n[j])
			h += 1
			print(''.join(n))
			break
		else:
			u = j
if h == 0:
	if u != -1:
		(n[u], n[-1]) = (n[-1], n[u])
		print(''.join(n))
	else:
		print(-1)


n = input()
count = 0
mydict = dict()
for i in range(len(n)):
	if int(n[i]) % 2 == 0:
		count += 1
if count == 0:
	print(-1)
else:
	myArr = list(n)
	last = 0
	flag = 0
	for i in range(len(myArr) - 1):
		if int(myArr[i]) % 2 == 0:
			last = i
			if int(myArr[i]) < int(myArr[-1]):
				(myArr[i], myArr[-1]) = (myArr[-1], myArr[i])
				flag = 1
				break
		if flag == 1:
			break
	if flag == 1:
		print(''.join(myArr))
	else:
		(myArr[last], myArr[-1]) = (myArr[-1], myArr[last])
		print(''.join(myArr))


n = list(str(input()))
l = []
c = 0
count = 0
for i in range(len(n) - 1):
	if int(n[i]) % 2 == 0:
		count = 1
		lol = n[i]
		w = i
		if int(n[i]) < int(n[-1]):
			x = n[i]
			n[i] = n[-1]
			n[-1] = x
			c = 1
			break
if c == 1:
	print(''.join(n))
if count == 1 and c == 0:
	n[w] = n[-1]
	n[-1] = lol
	print(''.join(n))
if count == 0:
	print(-1)


a1 = input()
a = a1
ch = -1
m = 100000000000000000
m1 = -1
im = -1
ma = 100000000
for i in range(len(a)):
	if int(a[i]) % 2 == 0 and int(a[i]) < m:
		im = i
		m = int(a[i])
	if int(a[i]) % 2 == 0 and int(a[i]) > m1 and (int(a[i]) < int(a[-1])) and (i < ma):
		ma = i
		m1 = int(a[i])
	if int(a[i]) % 2 == 0:
		ch = i
if ch == -1:
	print(-1)
elif int(a[-1]) < int(a[im]):
	a = a[:ch] + a[-1] + a[ch + 1:-1] + a[ch]
	print(a)
elif int(a[-1]) > int(a[ma]):
	a = a[:ma] + a[-1] + a[ma + 1:-1] + a[ma]
	print(a)
else:
	a = a[:im] + a[-1] + a[im + 1:-1] + a[im]
	print(a)


n = input()
i = -1
for k in range(len(n) - 1):
	if int(n[k]) % 2 == 0:
		i = k
		if int(n[k]) < int(n[-1]):
			break
if i == -1:
	print(i)
else:
	s = n[-1]
	s2 = n[i]
	res = n[:i] + s + n[i + 1:len(n) - 1] + s2
	print(res)


num = list(input())
flag = False
for (index, i) in enumerate(num):
	if int(i) % 2 == 0 and int(i) < int(num[-1]):
		temp = num[index]
		num[index] = num[-1]
		num[-1] = temp
		flag = True
		break
flag2 = False
if not flag:
	num = num[::-1]
	for (index, i) in enumerate(num):
		if int(i) % 2 == 0:
			temp = num[index]
			num[index] = num[0]
			num[0] = temp
			flag2 = True
			break
if flag:
	for i in num:
		print(i, end='')
	print('')
elif flag2:
	for i in num[::-1]:
		print(i, end='')
	print('')
else:
	print(-1)


n = str(input())
intN = int(n)
lastCh = str(n[len(n) - 1])
f = 1
pos = -1
i = 0
while f and i < len(n):
	if n[i] < lastCh and int(n[i]) % 2 == 0:
		f = 0
		pos = i
	else:
		i += 1
i = len(n) - 2
while f and i >= 0:
	if int(n[i]) % 2 == 0:
		pos = i
		f = 0
	else:
		i -= 1
if f:
	print(pos)
else:
	n = n[:len(n) - 1] + n[pos]
	n = n[:pos] + str(lastCh) + n[pos + 1:]
	print(n)


n = input()
if all([int(n[i]) % 2 == 1 for i in range(len(n))]):
	print(-1)
else:
	direction = any([int(n[i]) % 2 == 0 and int(n[i]) < int(n[-1]) for i in range(len(n))])
	it = range(len(n)) if direction else range(len(n) - 1, -1, -1)
	for i in it:
		if int(n[i]) % 2 == 0 and (int(n[i]) < int(n[-1]) or not direction):
			print(n[:i] + n[-1] + n[i + 1:-1] + n[i])
			break


nr = input()
ok = 0
for i in nr:
	if int(i) % 2 == 0:
		ok = 1

def swap(a, b, l):
	la = l[a]
	lb = l[b]
	nl = l[:a] + lb + l[a + 1:b] + la
	if b != -1:
		nl += l[b + 1:]
	return nl
if ok == 0:
	print(-1)
else:
	lg = len(nr)
	ok = 1
	for i in range(lg):
		if int(nr[i]) % 2 == 0 and nr[i] < nr[-1]:
			ok = 0
			nr = swap(i, -1, nr)
			break
	if ok == 1:
		for i in range(lg - 1, -1, -1):
			if int(nr[i]) % 2 == 0:
				nr = swap(i, -1, nr)
				break
	print(nr)


a = [i for i in input()]
god = False
for i in range(len(a)):
	if int(a[i]) % 2 == 0:
		god = True
		if int(a[i]) <= int(a[-1]):
			(a[i], a[-1]) = (a[-1], a[i])
			print(''.join(a))
			quit()
if not god:
	print(-1)
	quit()
if god:
	for i in range(len(a) - 1, -1, -1):
		if int(a[i]) % 2 == 0:
			(a[i], a[-1]) = (a[-1], a[i])
			print(''.join(a))
			quit()


import sys
import io
import os
total = 0
failed = 0

def debug(*args):
	if 'LOCALTEST' in os.environ:
		print(*args, file=sys.stderr)

def run(test, res):
	x = io.StringIO()
	with io.StringIO(test) as sys.stdin:
		with x as sys.stdout:
			work()
			z = x.getvalue().strip()
	sys.stdout = sys.__stdout__
	print('Passed?', z == res)
	print('Expected: ', res)
	print('Actual  : ', z)
	global total, failed
	total += 1
	failed += 1 if z != res else 0

def work():
	s = input()
	n = len(s)
	a = set()
	for i in range(n - 1):
		if s[i] not in {'1', '3', '5', '7', '9'}:
			a.add(s[i])
	if len(a) == 0:
		print(-1)
		return
	z = list(filter(lambda x: x < s[n - 1], a))
	if len(z) > 0:
		for i in range(n - 1):
			if s[i] in z:
				debug(s[0:i] + s[n - 1] + s[i + 1:-1] + s[i])
				print(s[0:i] + s[n - 1] + s[i + 1:-1] + s[i])
				return
	for i in range(n - 2, -1, -1):
		if s[i] in a:
			print(s[0:i] + s[n - 1] + s[i + 1:-1] + s[i])
			return

def test():
	run('527', '572')
	run('4573', '3574')
	run('45673', '45376')
	run('65479', '95476')
	run('165479', '195476')
	run('385246627843978362170157540643675855323710353773677940411475196990509715752529160843392455573495010188243882382558472922204112350361246467416768459478030209854538107582510626063704160813094926075632868146563064819802533296712142335569927258520979994961865096239723316828287794398744124091180818727394089596668051860979159984286698041131600683449371516107143467478369268579340478734931842549019002584431211465609785063593300180811245235806427313597226897763366561773583469101869801696778514237679372806611094131', '385246627843978362171157540643675855323710353773677940411475196990509715752529160843392455573495010188243882382558472922204112350361246467416768459478030209854538107582510626063704160813094926075632868146563064819802533296712142335569927258520979994961865096239723316828287794398744124091180818727394089596668051860979159984286698041131600683449371516107143467478369268579340478734931842549019002584431211465609785063593300180811245235806427313597226897763366561773583469101869801696778514237679372806611094130')
	run('1357997531', '-1')
if 'LOCALTEST' in os.environ:
	test()
	print('\n Result: %s (%d total, %d failed)' % ('FAILED' if failed > 0 else 'PASSED', total, failed))
else:
	work()


n = list(input())
flag = 0
pat = 0
for i in range(len(n) - 1):
	if int(n[i]) % 2 == 0:
		if n[i] < n[-1]:
			(n[i], n[-1]) = (n[-1], n[i])
			flag = 2
			break
		else:
			flag = 1
			pat = i
if flag != 0:
	if flag == 2:
		print(''.join(n))
	else:
		(n[pat], n[-1]) = (n[-1], n[pat])
		print(''.join(n))
else:
	print(-1)


n = input()
l = len(n)
d = []
m = -1
for i in range(l):
	if int(n[i]) % 2 == 0:
		m = i
		if int(n[i]) < int(n[-1]):
			break
if m == -1:
	print(m)
else:
	print(n[:m] + n[-1] + n[m + 1:-1] + n[m])


def even(n):
	if n % 2 == 0:
		return 1
	else:
		return 0
g = input()
li = []
licf = []
lic = []
for i in range(len(g)):
	if even(int(g[i])) == 1:
		li.append(i)
if len(li) == 0:
	print('-1')
else:
	flag = 0
	for x in li:
		if g[len(g) - 1] > g[x]:
			t = list(g)
			temp = t[x]
			t[x] = t[len(t) - 1]
			t[len(t) - 1] = temp
			t = ''.join(t)
			print(t)
			flag = 1
			break
	if flag == 0:
		t = list(g)
		temp = t[li[len(li) - 1]]
		t[li[len(li) - 1]] = t[len(t) - 1]
		t[len(t) - 1] = temp
		t = ''.join(t)
		print(t)


n = input()
Max = []
x = -1
for i in range(len(n)):
	if int(n[i]) % 2 == 0:
		if int(n[i]) < int(n[-1]):
			x = n[:i] + n[-1] + n[i + 1:-1] + n[i]
			break
		else:
			Max.append(i)
if Max == [] and x == -1:
	print(-1)
elif x != -1:
	print(x)
else:
	for i in Max[::-1]:
		if int(n[i]) > int(n[-1]):
			print(n[:i] + n[-1] + n[i + 1:-1] + n[i])
			break


n = input()
is_even = lambda x: int(x[-1]) % 2 == 0
is_odd = lambda x: int(x[-1]) % 2 == 1

def swap(n, i, j):
	if i == j:
		return n
	if i > j:
		(i, j) = (j, i)
	return n[:i] + n[j] + n[i + 1:j] + n[i] + n[j + 1:]
if is_even(n):
	if len(n) == 2:
		if is_odd(n[0]):
			print(-1)
		else:
			print(n[1] + n[0])
	else:
		for i in range(len(n) - 1):
			max = (-1, -1)
			for j in range(i + 1, len(n)):
				if int(n[j]) > int(n[i]) and int(n[j]) > max[1]:
					max = (j, int(n[j]))
			if max != (-1, -1):
				print(swap(n, i, max[0]))
				break
		else:
			for i in reversed(range(len(n) - 1)):
				if is_even(n[i]):
					print(swap(n, i, len(n) - 1))
					break
			else:
				print(-1)
else:
	for i in range(len(n) - 1):
		if is_even(n[i]) and int(n[i]) < int(n[-1]):
			print(swap(n, i, len(n) - 1))
			break
	else:
		for i in reversed(range(len(n) - 1)):
			if is_even(n[i]):
				print(swap(n, i, len(n) - 1))
				break
		else:
			print(-1)


n = input()
even = -1
for i in range(0, len(n) - 1):
	if int(n[i]) % 2 == 0:
		even = i
		if int(n[i]) < int(n[-1]):
			break
if even >= 0:
	k = ''
	for i in range(0, len(n) - 1):
		if i == even:
			k += n[-1]
		else:
			k += n[i]
	k += n[even]
	print(k)
else:
	print(-1)


s = input()
even = []
for c in s:
	if int(c) % 2 == 0:
		even.append(c)
f = 0
if even:
	pass
else:
	print(-1)
	f = 1
lb = s[len(s) - 1]
for i in even:
	if i < lb:
		s = s.replace(i, lb, 1)
		s = s[::-1]
		s = s.replace(lb, i, 1)
		s = s[::-1]
		print(s)
		f = 1
		break
if f == 0:
	s = s[::-1]
	s = s.replace(i, lb, 1)
	s = s.replace(lb, i, 1)
	s = s[::-1]
	print(s)


s = input()
if (s.find('0') == -1 and s.find('2') == -1 and (s.find('4') == -1) and (s.find('6') == -1)) and s.find('8') == -1:
	print(-1)
else:
	p = s
	flag = True
	i = 0
	while i < len(s) and flag:
		if int(s[i]) % 2 == 0 and int(s[i]) < int(s[-1]):
			s = s[:i] + s[-1] + s[i + 1:-1] + s[i]
			flag = False
		i = i + 1
	if p != s:
		print(s)
	else:
		k = '02468'
		max_ind = -1
		max_val = -1
		for i in range(len(k)):
			f = s.rfind(k[i])
			if f != -1:
				if f > max_ind:
					max_ind = f
					max_val = k[i]
		s = s[:max_ind] + s[-1] + s[max_ind + 1:-1] + str(max_val)
		print(s)


n = list(input())
swap_idx = -1
for (i, val) in enumerate(n):
	val = int(n[i])
	if val % 2 == 0:
		swap_idx = i
		if val < int(n[-1]):
			break
if swap_idx != -1:
	(n[swap_idx], n[-1]) = (n[-1], n[swap_idx])
	print(''.join(n))
else:
	print(-1)


def swapPositions(list, pos1, pos2):
	(list[pos1], list[pos2]) = (list[pos2], list[pos1])
	return list
a = input()
la = a[-1]
eve = []
ans = 0
nil = 0
for _ in a:
	if int(_) % 2 == 0:
		eve.append(_)
if len(eve) == 0:
	print(-1)
else:
	for _ in range(len(a)):
		if int(a[_]) % 2 == 0:
			nil = _
			if int(a[_]) < int(la):
				c = swapPositions(list(a), _, -1)
				ans = 1
				break
	if ans == 0:
		c = swapPositions(list(a), nil, -1)
	print(''.join(c))


n = list(input())
last = int(n[-1])
index = -1
for i in range(len(n) - 1):
	if int(n[i]) % 2 == 0:
		index = i
		if int(n[i]) < last:
			break
if index == -1:
	print(-1)
else:
	(n[index], n[-1]) = (n[-1], n[index])
	print(''.join(n))


def ans():
	ap = list(input())
	a = [int(i) for i in ap]
	ans = []
	kkk = -1
	for i in range(len(a)):
		if a[i] % 2 == 0:
			kkk = i
			if a[-1] > a[i]:
				(ap[-1], ap[i]) = (ap[i], ap[-1])
				print(''.join(ap))
				return
	if kkk != -1:
		(ap[kkk], ap[-1]) = (ap[-1], ap[kkk])
		print(''.join(ap))
		return
	print(-1)
	return
ans()


x = input()
mine = 11
for i in range(len(x)):
	if int(x[i]) < int(x[len(x) - 1]) and int(x[i]) % 2 == 0:
		mine = int(x[i])
		index = i
		break
if mine > int(x[len(x) - 1]):
	for i in range(len(x) - 2, -1, -1):
		if int(x[i]) % 2 == 0:
			mine = int(x[i])
			index = i
			break
if not mine == 11:
	y = list(x)
	v = y[index]
	y[index] = y[len(x) - 1]
	y[len(x) - 1] = v
	print(''.join(y))
else:
	print('-1')


s = list(input())
n = len(s)
if all((int(i) % 2 for i in s)):
	print(-1)
	exit()
ev = sum((int(i) % 2 == 0 for i in s))
f = 0
for i in range(n):
	if int(s[i]) < int(s[-1]) and int(s[i]) % 2 == 0:
		(s[i], s[-1]) = (s[-1], s[i])
		f = 1
		break
if f == 0:
	for i in range(n - 1, -1, -1):
		if int(s[i]) % 2 == 0:
			(s[i], s[n - 1]) = (s[n - 1], s[i])
			break
print(*s, sep='')


n = list(map(int, list(input())))
if not [i for i in n if i % 2 == 0]:
	print(-1)
	exit()
if n[-1] % 2 == 1:
	found = False
	for i in range(len(n) - 1):
		if n[i] % 2 == 0 and n[i] < n[-1]:
			tmp = n[i]
			n[i] = n[-1]
			n[-1] = tmp
			found = True
			break
	if not found:
		for i in range(len(n) - 2, -1, -1):
			if n[i] % 2 == 0:
				tmp = n[i]
				n[i] = n[-1]
				n[-1] = tmp
				break
else:
	for i in range(len(n) - 1):
		if n[i] % 2 == 0 and n[i] < n[-1]:
			tmp = n[i]
			n[i] = n[-1]
			n[-1] = tmp
			break
print(''.join([str(i) for i in n]))


S = input()
g = 1
for i in range(len(S) - 1):
	if S[i] < S[len(S) - 1] and int(S[i]) % 2 == 0:
		print(S[:i] + S[len(S) - 1] + S[i + 1:len(S) - 1] + S[i])
		g = 0
		break
if g == 1:
	for i in range(len(S) - 1, -1, -1):
		if int(S[i]) % 2 == 0:
			print(S[:i] + S[len(S) - 1] + S[i + 1:len(S) - 1] + S[i])
			g = 0
			break
if g == 1:
	print(-1)


import sys
n = input()
last = int(n[-1])
for i in range(len(n) - 1):
	cur = int(n[i])
	if cur % 2 == 0:
		if cur < last:
			q = list(n)
			(q[-1], q[i]) = (q[i], q[-1])
			print(''.join(q))
			sys.exit()
		elif cur > last:
			rmost = i
try:
	q = list(n)
	(q[-1], q[rmost]) = (q[rmost], q[-1])
	print(''.join(q))
except NameError:
	print(-1)


n = list(input())
v = -1
for (i, j) in enumerate(n):
	if int(j) % 2 == 0:
		v = int(i)
		if int(j) < int(n[-1]):
			break
if int(v) < 0:
	print(-1)
else:
	(n[v], n[-1]) = (n[-1], n[v])
	print(''.join(n))


a = list(input())

def anton(arr):
	a = arr[-1]
	i = 0
	b = -1
	while i < len(arr) - 1:
		if int(arr[i]) % 2 == 0:
			b = i
			if arr[i] < a:
				break
		i += 1
	if b == -1:
		return -1
	(arr[b], arr[-1]) = (arr[-1], arr[b])
	return ''.join(arr)
print(anton(a))


n = list(input())
k = len(n)
last = int(n[k - 1])
opt = -1
for i in range(k):
	m = int(n[i])
	if m % 2 == 0 and m < last:
		c = n[i]
		n[i] = n[k - 1]
		n[k - 1] = c
		opt = 0
		break
	if m % 2 == 0 and m > last:
		opt = 1
		ind_even = i
if opt == -1:
	print(-1)
elif opt == 0:
	for i in range(k):
		print(n[i], end='')
else:
	c = n[ind_even]
	n[ind_even] = n[k - 1]
	n[k - 1] = c
	for i in range(k):
		print(n[i], end='')


s = input()
k = 0
l = [char for char in s]
for i in range(len(l)):
	if int(l[i]) % 2 == 0:
		if l[i] <= l[len(l) - 1]:
			temp = l[i]
			l[i] = l[len(l) - 1]
			l[len(l) - 1] = temp
			k = 1
			break
if k == 0:
	k = len(l)
	for i in range(k):
		if int(l[k - i - 1]) % 2 == 0:
			temp = l[k - i - 1]
			l[k - i - 1] = l[k - 1]
			l[k - 1] = temp
			break
s1 = ''
for i in l:
	s1 = s1 + i
if s1 != s:
	print(s1)
else:
	print(-1)


num = list(input())
n = len(num)
l = []
temp = 0
last = int(num[n - 1])
D = False
for i in range(n):
	c = int(num[i])
	if c % 2 == 0:
		l.append(i)
		if c <= last:
			temp = num[i]
			num[i] = str(last)
			num[n - 1] = temp
			print(''.join(num))
			break
	if i == n - 1 and len(l) != 0:
		temp = num[l[-1]]
		num[l[-1]] = str(last)
		num[n - 1] = temp
		print(''.join(num))
	elif i == n - 1 and len(l) == 0:
		print(-1)


s = input()

def fn(s):
	k = None
	index = 0
	for i in range(len(s) - 1):
		if int(s[i]) % 2 == 0:
			k = int(s[i])
			index = i
			if k < int(s[-1]):
				return s[:i] + s[-1] + s[i + 1:-1] + str(k)
	if k:
		return s[:index] + s[-1] + s[index + 1:-1] + str(k)
	return -1
print(fn(s))


nstring = input()
nlist = list()
min_even = 10
for c in nstring:
	nlist.append(int(c))
n = len(nlist)
foundIdx = -1
for i in range(n - 1):
	if nlist[i] % 2 == 0 and nlist[i] < nlist[n - 1]:
		foundIdx = i
		break
if foundIdx == -1:
	for i in range(n - 1, -1, -1):
		if nlist[i] % 2 == 0:
			foundIdx = i
			break
if foundIdx != -1:
	(nlist[foundIdx], nlist[n - 1]) = (nlist[n - 1], nlist[foundIdx])
	for i in range(n):
		print(nlist[i], end='')
else:
	print(-1)


import sys
s = input()
s = [int(i) for i in s]
ans = list([])
for i in range(len(s)):
	if s[i] % 2 == 0:
		ans.append(i)
flag = False
for i in ans:
	if s[i] < s[-1]:
		(s[i], s[-1]) = (s[-1], s[i])
		flag = True
		break
if not flag and len(ans):
	(s[ans[-1]], s[-1]) = (s[-1], s[ans[-1]])
if int(s[len(s) - 1]) % 2 == 0:
	for i in s:
		print(i, end='')
	print()
else:
	print(-1)


s = [int(x) for x in input()]
p = len([x for x in s if x % 2 == 0])
f = lambda ls: ''.join((str(x) for x in ls))
for (i, x) in enumerate(s):
	if x % 2 == 0:
		if x < s[-1]:
			print(f(s[:i]) + str(s[-1]) + f(s[i + 1:-1]) + str(x))
			break
		elif p > 1:
			p -= 1
		else:
			print(f(s[:i]) + str(s[-1]) + f(s[i + 1:-1]) + str(x))
			break
else:
	print(-1)


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

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

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

def si():
	return input()
s = si()
s = list(s)
n = len(s)
x = int(s[-1])
f = -1
y = 0
f1 = 0
for i in range(n - 1):
	if int(s[i]) % 2 == 0 and int(s[i]) < x:
		(s[i], s[n - 1]) = (s[n - 1], s[i])
		f1 = 1
		break
	if int(s[i]) % 2 == 0:
		f = i
if f < 0 and f1 == 0:
	print('-1')
else:
	if f1 == 0:
		(s[n - 1], s[f]) = (s[f], s[n - 1])
	print(''.join(s))


from collections import *
from bisect import *
from math import *
from heapq import *
from fractions import *
import sys
input = sys.stdin.readline
t = 1

def r(a):
	return a * (a - 1) // 2
while t:
	t -= 1
	a = input().rstrip('\n')
	f1 = {chr(48 + i): [] for i in range(10)}
	c = 0
	for i in a:
		f1[i].append(c)
		c += 1
	f = int(a[-1])
	small = []
	large = []
	for i in range(0, 9, 2):
		for j in f1[str(i)]:
			if i > f:
				large.append(j)
			else:
				small.append(j)
	if len(small) == len(large) == 0:
		print(-1)
		exit(0)
	if len(small):
		x = min(small)
		a = list(a)
		(a[-1], a[x]) = (a[x], a[-1])
	else:
		x = max(large)
		a = list(a)
		(a[-1], a[x]) = (a[x], a[-1])
	print(''.join(a))


def main():
	num = list(map(int, input()))
	found = False
	last = num[-1]
	for i in range(len(num) - 1):
		if num[i] % 2 == 0:
			if last > num[i]:
				found = True
				(num[i], num[-1]) = (num[-1], num[i])
				break
	if not found:
		for i in range(len(num) - 2, -1, -1):
			if num[i] % 2 == 0:
				found = True
				(num[i], num[-1]) = (num[-1], num[i])
				break
	if not found:
		print(-1)
		return
	for i in num:
		print(i, end='')
main()


def main():
	n = read(0)
	ld = int(n[-1])
	last = -1
	for i in range(len(n) - 1):
		c = int(n[i])
		if c % 2 == 0 and c < ld:
			return n[:i] + n[-1] + n[i + 1:-1] + n[i]
		if c % 2 == 0:
			last = i
	if last == -1:
		return -1
	return n[:last] + n[-1] + n[last + 1:-1] + n[last]

def read(mode=2):
	inputs = input().strip()
	if mode == 0:
		return inputs
	if mode == 1:
		return inputs.split()
	if mode == 2:
		return list(map(int, inputs.split()))

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


n = list(map(int, input()))
has_even = False
for i in range(len(n) - 1):
	if n[i] % 2 == 0:
		has_even = True
		if n[i] < n[len(n) - 1]:
			(n[i], n[len(n) - 1]) = (n[len(n) - 1], n[i])
			print(''.join(map(str, n)))
			exit()
if not has_even:
	print(-1)
	exit()
for i in range(len(n) - 2, -1, -1):
	if n[i] % 2 == 0:
		if n[i] > n[len(n) - 1]:
			(n[i], n[len(n) - 1]) = (n[len(n) - 1], n[i])
			print(''.join(map(str, n)))
			exit()


rate = input()
haveEven = False
posEven = -1
posEvenHigh = -1
for i in range(len(rate) - 1, -1, -1):
	if int(rate[i]) % 2 == 0:
		haveEven = True
		posEven = i
		break
for i in range(0, len(rate)):
	if int(rate[i]) % 2 == 0 and int(rate[i]) < int(rate[-1]):
		posEvenHigh = i
		break
if haveEven:
	change = [i for i in rate]
	change1 = [i for i in rate]
	(change[-1], change[posEven]) = (change[posEven], change[-1])
	(change1[-1], change1[posEvenHigh]) = (change1[posEvenHigh], change1[-1])
	if ''.join(change1) == rate:
		print(''.join(change))
	else:
		print(''.join(change1))
else:
	print(-1)


x = input()
m = list(x)
m = [int(x) for x in m]
t = []
maximum = 0
for i in range(len(m)):
	if m[i] % 2 == 0:
		t.append(i)
if len(t) == 0:
	print('-1')
	exit()
for i in t:
	if m[-1] > m[i]:
		x = m[i]
		m[i] = m[-1]
		m[-1] = x
		break
if m[-1] % 2 is not 0:
	x = m[t[-1]]
	m[t[-1]] = m[-1]
	m[-1] = x
z = ''.join((str(x) for x in m))
print(z)


n = list(input())
if not any([x in n for x in '02468']):
	print(-1)
	exit()
for i in range(len(n) - 1):
	if n[i] in '02468':
		if n[i] < n[len(n) - 1]:
			(n[i], n[len(n) - 1]) = (n[len(n) - 1], n[i])
			print(''.join(n))
			exit()
for i in range(len(n) - 2, -1, -1):
	if n[i] in '02468':
		if n[i] > n[len(n) - 1]:
			(n[i], n[len(n) - 1]) = (n[len(n) - 1], n[i])
			print(''.join(n))
			exit()


import sys
n = input()
counter = 0
for c in n:
	if int(c) % 2 == 0:
		counter += 1
if counter == 0:
	print(-1)
	sys.exit()
for i in range(len(n)):
	if int(n[i]) % 2 == 0:
		if counter == 1 or int(n[i]) < int(n[-1]):
			n = n[:i] + n[-1] + n[i + 1:len(n) - 1] + n[i]
			break
		counter -= 1
print(n)


def main():
	import sys
	n = sys.stdin.readline().strip()
	lodd = int(n[-1])
	odd = 0
	even = 0
	s = ''
	j = 0
	for i in n:
		if ord(i) & 1:
			odd += 1
		else:
			even += 1
			feven = int(i)
			feindex = j
			if feven < lodd:
				break
		j += 1
	if even:
		for i in range(len(n)):
			if i == feindex:
				sys.stdout.write(n[-1])
			elif i == len(n) - 1:
				sys.stdout.write(str(feven))
			else:
				sys.stdout.write(n[i])
	else:
		sys.stdout.write('-1')
main()


s = list(input())
f = -1
for inf in range(len(s)):
	i = s[inf]
	if int(i) % 2 == 0:
		f = inf
		if int(i) < int(s[-1]):
			(s[inf], s[-1]) = (s[-1], s[inf])
			print(''.join(s))
			exit(0)
if f == -1:
	print(-1)
else:
	(s[f], s[-1]) = (s[-1], s[f])
	print(''.join(s))


import sys
txt = list(input())
last = int(txt[-1])
for i in range(0, len(txt) - 1):
	if int(txt[i]) % 2 == 0:
		if int(txt[i]) < last:
			(txt[i], txt[len(txt) - 1]) = (txt[len(txt) - 1], txt[i])
			print(''.join(txt))
			sys.exit()
for i in range(len(txt) - 2, -1, -1):
	if int(txt[i]) % 2 == 0:
		if int(txt[i]) > last:
			(txt[i], txt[len(txt) - 1]) = (txt[len(txt) - 1], txt[i])
			print(''.join(txt))
			sys.exit()
print(-1)


num = list(input())
swap = -1
for (idx, d) in enumerate(num):
	if int(d) % 2 == 0:
		swap = idx
		if d < num[-1]:
			break
if swap < 0:
	print(-1)
else:
	(num[-1], num[swap]) = (num[swap], num[-1])
	print(''.join(num))


n = [int(x) for x in input()]
x = n[-1]
last_even_index = -1
for i in range(len(n) - 1):
	if n[i] % 2 == 0:
		last_even_index = i
		if n[i] < x:
			temp = n[i]
			n[i] = n[-1]
			n[-1] = temp
			break
else:
	if last_even_index == -1:
		print(-1)
		exit()
	temp = n[last_even_index]
	n[last_even_index] = n[-1]
	n[-1] = temp
print(''.join(map(str, n)))


a = list(input())
flag = 1
k = 0
for i in range(len(a)):
	if int(a[i]) % 2 == 0 and int(a[i]) < int(a[-1]):
		k = i
		flag = 0
		break
	elif int(a[i]) % 2 == 0:
		k = i
		flag = 0
if flag:
	print(-1)
else:
	temp = a[k]
	a[k] = a[-1]
	a[-1] = temp
	print(''.join(a))


def main():
	f = 0
	s = list(input())
	for i in range(len(s)):
		if not int(s[i]) & 1 and s[i] < s[-1]:
			(s[-1], s[i]) = (s[i], s[-1])
			print(''.join(s))
			f = 1
			break
	if f == 0:
		for i in range(len(s) - 1, -1, -1):
			if s[i] in '02468':
				f = 1
				(s[-1], s[i]) = (s[i], s[-1])
				print(''.join(s))
				break
	if f == 0:
		print(-1)
main()


import os
import sys
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')

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def sieve_of_eratosthenes(n):
	ans = []
	arr = [1] * (n + 1)
	(arr[0], arr[1], i) = (0, 0, 2)
	while i * i <= n:
		if arr[i] == 1:
			j = i + i
			while j <= n:
				arr[j] = 0
				j += i
		i += 1
	for k in range(n):
		if arr[k] == 1:
			ans.append(k)
	return ans

def nc2(x):
	if x == 1:
		return 0
	else:
		return x * (x - 1) // 2
for _ in range(1):
	given = list(input())
	integ = [int(x) for x in given]
	for i in integ:
		if i % 2 == 0:
			flag = 0
			break
		else:
			flag = 1
	if flag == 1:
		print(-1)
	else:
		for i in range(len(integ) - 1):
			if integ[i] % 2 == 0 and integ[i] < integ[-1]:
				(integ[i], integ[-1]) = (integ[-1], integ[i])
				flag = 1
				break
		if flag == 0:
			for i in range(len(integ) - 1, -1, -1):
				if integ[i] % 2 == 0:
					(integ[i], integ[-1]) = (integ[-1], integ[i])
					break
		print(''.join((str(x) for x in integ)))


s = input()
l = []
count = 0
for i in s:
	l.append(int(i))
for j in range(len(l)):
	if l[j] % 2 == 0 and l[j] < l[-1]:
		count += 1
		(l[j], l[-1]) = (l[-1], l[j])
		break
	elif l[j] % 2 == 0 and l[j] > l[-1]:
		count += 1
		temp = j
if count == 0:
	print(-1)
else:
	a = ''
	for k in l:
		a = a + str(k)
	if a == s:
		(l[temp], l[-1]) = (l[-1], l[temp])
		b = ''
		for k in l:
			b = b + str(k)
		print(b)
	else:
		print(a)


import sys
n = input()
flag = 'a'
for (j, i) in enumerate(n):
	a = int(i)
	if a % 2 == 0:
		if a < int(n[-1]):
			flag = j
			break
if flag == 'a':
	for i in range(-1, -len(n) - 1, -1):
		a = int(n[i])
		if a % 2 == 0:
			if a > int(n[-1]):
				flag = i
				break
if flag == 'a':
	print(-1)
else:
	n = list(n)
	(n[-1], n[flag]) = (n[flag], n[-1])
	print(''.join(n))


n = input()
l = list(n)
for i in range(len(l)):
	l[i] = int(l[i])
even = 0
evens = []
evenl = []
for i in range(len(l)):
	if l[i] % 2 == 0:
		even += 1
		evenl.append(i)
		evens.append(l[i])
if even == 0:
	print(-1)
elif even == 1:
	l[evenl[0]] = l[len(l) - 1]
	l[len(l) - 1] = evens[0]
	for i in range(len(l)):
		print(l[i], end='')
else:
	x = 0
	for i in range(len(evens)):
		if l[len(l) - 1] > evens[i]:
			l[evenl[i]] = l[len(l) - 1]
			l[len(l) - 1] = evens[i]
			x = 1
			break
	if x == 0:
		k = l[evenl[len(evenl) - 1]]
		l[evenl[len(evenl) - 1]] = l[len(l) - 1]
		l[len(l) - 1] = k
	for i in range(len(l)):
		print(l[i], end='')


s = list(map(int, input()))
even_cnt = 0
for i in range(len(s)):
	if s[i] % 2 == 0:
		even_cnt += 1
if even_cnt == 0:
	print(-1)
	exit()
for j in range(len(s)):
	if s[j] % 2 == 0:
		even_cnt -= 1
		if s[j] < s[-1] or even_cnt == 0:
			(s[j], s[-1]) = (s[-1], s[j])
			break
print(*s, sep='')


from sys import exit
n = input()
for i in range(0, len(n) - 1):
	if int(n[i]) % 2 == 1:
		continue
	if int(n[i]) < int(n[-1]):
		n = n[:i] + n[-1] + n[i + 1:len(n) - 1] + n[i]
		print(n)
		exit(0)
for i in range(len(n) - 2, -1, -1):
	if int(n[i]) % 2 == 0:
		n = n[:i] + n[-1] + n[i + 1:len(n) - 1] + n[i]
		print(n)
		exit(0)
print(-1)


n = input()
l = list(n)
even = ['0', '2', '4', '6', '8']
c = 0
yes = None
present = 0
for i in l:
	if i in even:
		yes = i
		present += 1
	else:
		c += 1
if c == len(l):
	print(-1)
	exit()
if present == 1:
	for i in reversed(range(len(l))):
		if l[i] == yes:
			temp = l[i]
			l[i] = l[-1]
			l[-1] = temp
			print(''.join(l))
			exit()
b = len(l) - 1
last = None
for i in range(len(l) - 1):
	if int(l[i]) % 2 == 0 and int(l[i]) < int(l[-1]):
		temp = l[i]
		l[i] = l[-1]
		l[-1] = temp
		print(''.join(l))
		exit()
	if int(l[i]) % 2 == 0:
		last = i
temp = l[last]
l[last] = l[-1]
l[-1] = temp
print(''.join(l))


import sys
inf = float('inf')
from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd
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, MOD) = (1000000007, 998244353)
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
n = input()
count = 0
mydict = dict()
for i in range(len(n)):
	if int(n[i]) % 2 == 0:
		count += 1
if count == 0:
	print(-1)
else:
	myArr = list(n)
	last = 0
	flag = 0
	for i in range(len(myArr) - 1):
		if int(myArr[i]) % 2 == 0:
			last = i
			if int(myArr[i]) < int(myArr[-1]):
				(myArr[i], myArr[-1]) = (myArr[-1], myArr[i])
				flag = 1
				break
		if flag == 1:
			break
	if flag == 1:
		print(''.join(myArr))
	else:
		(myArr[last], myArr[-1]) = (myArr[-1], myArr[last])
		print(''.join(myArr))


d = list(input())
last_index = len(d) - 1
last_val = d[last_index]
j = last_index
index = -1
for i in range(len(d)):
	if not int(d[i]) % 2:
		if d[i] < d[last_index]:
			(d[i], d[last_index]) = (d[last_index], d[i])
			print(''.join(d))
			exit()
		else:
			index = i
if index != -1:
	(d[index], d[last_index]) = (d[last_index], d[index])
	print(''.join(d))
else:
	print(-1)


def main():
	today = input()
	last = int(today[-1])
	even_idx = -1
	for i in range(len(today)):
		if int(today[i]) % 2 == 0:
			even_idx = i
			if int(today[i]) < last:
				return today[:i] + today[-1] + today[i + 1:-1] + today[i]
	if even_idx == -1:
		return -1
	return today[:even_idx] + today[-1] + today[even_idx + 1:-1] + today[even_idx]
print(main())


s = input()
if not any((int(i) % 2 == 0 for i in s)):
	print(-1)
elif int(s[-1]) % 2 == 0 and sum([s.count(str(i)) for i in range(2, 9, 2)]) == 1:
	print(-1)
else:
	for x in s:
		if int(x) % 2 == 0 and int(x) <= int(s[-1]):
			x1 = s.index(x)
			print(s[:x1] + s[-1] + s[x1 + 1:-1] + x)
			quit()
	for y in s[::-1]:
		if int(y) % 2 == 0 and int(y) > int(s[-1]):
			y1 = len(s) - 1 - s[::-1].index(y)
			print(s[:y1] + s[-1] + s[y1 + 1:-1] + y)
			break


s = input()
n = len(s)
pos = -1
mn = ':'
for i in range(n - 1):
	if s[i] < s[-1] and int(s[i]) % 2 == 0:
		pos = i
		mn = s[i]
		break
if pos == -1:
	for i in range(n - 1):
		if (int(s[-i - 2]) - int('0')) % 2 == 0:
			pos = n - i - 2
			mn = s[-i - 2]
			break
if pos == -1:
	print(-1)
else:
	s = list(s)
	t = s[pos]
	s[pos] = s[-1]
	s[-1] = t
	s = ''.join(s)
	print(s)


s = input()
c1 = 0
for i in range(len(s) - 1):
	if int(s[i]) % 2 == 0:
		if int(s[i]) < int(s[len(s) - 1]):
			print(s[:i] + s[len(s) - 1] + s[i + 1:len(s) - 1] + s[i])
			c1 = -1
			break
if c1 != -1:
	for i in range(len(s) - 1, 0, -1):
		if int(s[i]) % 2 == 0:
			print(s[:i] + s[len(s) - 1] + s[i + 1:len(s) - 1] + s[i])
			c1 = -1
			break
	if c1 != -1:
		if int(s[0]) % 2 == 0:
			print(s[len(s) - 1] + s[1:len(s) - 1] + s[0])
			c1 = -1
if c1 != -1:
	print('-1')


s = input()
s = list(s)
l = []
l2 = 0
n = len(s)
ce = 0
for j in range(n):
	i = int(s[j])
	l.append(i)
	if i % 2 == 0:
		ce += 1
		l2 = j
if ce == 0:
	print(-1)
else:
	f = 0
	for j in range(n - 1):
		if l[j] % 2 == 0 and l[j] < l[-1]:
			(l[j], l[-1]) = (l[-1], l[j])
			f = 1
			break
	if f == 0:
		(l[-1], l[l2]) = (l[l2], l[-1])
	for j in range(n):
		print(l[j], end='')


s = input()
last = s[len(s) - 1]
flag_find_odd = False
give_ans = False
if int(last) % 2 == 1:
	for i in range(len(s)):
		if int(s[i]) % 2 == 0:
			ans_else_1 = i
			flag_find_odd = True
		if (s[i] < last) & (int(s[i]) % 2 == 0):
			s = s[0:i] + last + s[i + 1:len(s) - 1] + s[i]
			give_ans = True
			break
	if flag_find_odd == False:
		s = -1
	elif give_ans == False:
		s = s[0:ans_else_1] + last + s[ans_else_1 + 1:len(s) - 1] + s[ans_else_1]
print(s)


from sys import stdin, stdout
from collections import Counter

def ai():
	return list(map(int, stdin.readline().split()))

def ei():
	return map(int, stdin.readline().split())

def ip():
	return int(stdin.readline().strip())

def op(ans):
	return stdout.write(str(ans) + '\n')
from math import ceil
n = input()
m = -1
for i in range(len(n)):
	if int(n[i]) & 1 == 0:
		m = i
		if n[i] < n[-1]:
			break
if m == -1:
	op(-1)
else:
	x = list(n)
	x[m] = n[-1]
	x[-1] = n[m]
	print(''.join(x))


mat = [int(x) for x in input()]
if mat[-1] % 2 == 0:
	for i in range(len(mat)):
		if mat[i] != max(mat[i:]):
			(mat[i], mat[len(mat) - mat[::-1].index(max(mat)) - 1]) = (max(mat[i:]), mat[i])
			print(''.join((str(i) for i in mat)))
			break
	else:
		print(-1)
else:
	last_even = -1
	for i in range(len(mat)):
		if mat[i] % 2 == 0:
			last_even = i
			if mat[i] < mat[-1]:
				(mat[i], mat[-1]) = (mat[-1], mat[i])
				print(''.join((str(i) for i in mat)))
				break
	else:
		if last_even == -1:
			print(last_even)
		else:
			(mat[last_even], mat[-1]) = (mat[-1], mat[last_even])
			print(''.join((str(i) for i in mat)))


n = list(input())
count = 0
for i in range(len(n)):
	if ord(n[i]) == 48 or ord(n[i]) == 50 or ord(n[i]) == 52 or (ord(n[i]) == 54) or (ord(n[i]) == 56):
		if n[i] < n[len(n) - 1]:
			(n[i], n[len(n) - 1]) = (n[len(n) - 1], n[i])
			count = 1
			break
if count == 0:
	i = len(n) - 1
	while i >= 0:
		if ord(n[i]) == 48 or ord(n[i]) == 50 or ord(n[i]) == 52 or (ord(n[i]) == 54) or (ord(n[i]) == 56):
			if n[i] > n[len(n) - 1]:
				(n[i], n[len(n) - 1]) = (n[len(n) - 1], n[i])
				count = 1
				break
		i -= 1
if count:
	s = ''
	for i in n:
		s += i
	print(s)
else:
	print(-1)


n = list(input())
nl = len(n)
ans = []
for i in range(nl):
	if int(n[i]) % 2 == 0:
		ans.append(i)
if len(ans) == 0:
	print(-1)
else:
	for i in ans:
		if n[-1] > n[i]:
			(n[-1], n[i]) = (n[i], n[-1])
			break
	else:
		(n[-1], n[ans[-1]]) = (n[ans[-1]], n[-1])
	print(''.join(n))


s = input()
a = [0] * len(s)
output = ''
even = 0
lastpos = 0
done = 0
evenexist = 0
unit = int(s[len(s) - 1])
for i in range(len(s)):
	a[i] = int(s[i])
for i in range(len(s)):
	if a[i] % 2 == 0:
		evenexist = 1
		even = a[i]
		if a[i] < unit:
			a[i] = unit
			a[len(s) - 1] = even
			done = 1
			break
		lastpos = i
if done == 0:
	a[lastpos] = unit
	a[len(s) - 1] = even
if evenexist == 0:
	print('-1')
else:
	for i in range(len(s)):
		output += str(a[i])
	print(output)


def main():
	s = input()
	temp = -1
	l = len(s)
	for i in range(l - 2, -1, -1):
		if int(s[i]) % 2 == 0:
			if int(s[i]) < int(s[-1]) or temp == -1:
				temp = i
	if temp == -1:
		print(-1)
	else:
		print(s[0:temp] + s[-1] + s[temp + 1:len(s) - 1] + s[temp])
main()


s = input()
(j, k) = (-1, -1)
for i in range(len(s) - 1):
	if ord(s[i]) % 2 == 0:
		k = i
		if j == -1 and s[i] < s[-1]:
			j = i
if j != -1:
	s = s[:j] + s[-1] + s[j + 1:-1] + s[j]
elif k != -1:
	s = s[:k] + s[-1] + s[k + 1:-1] + s[k]
else:
	s = '-1'
print(s)


def even(n):
	return not n % 2
s = str(input())
l = list(s)
l1 = [int(c) for c in s]
last = l1[-1]
flag = False
for i in range(len(l1)):
	if even(l1[i]) and l1[i] < last:
		temp = l1[i]
		l1[i] = last
		l1[-1] = temp
		flag = True
		break
if flag == False:
	for i in range(len(l1)):
		if even(l1[len(l1) - 1 - i]):
			temp = l1[len(l1) - 1 - i]
			l1[len(l1) - 1 - i] = last
			l1[-1] = temp
			break
l2 = [str(c) for c in l1]
if l2 == l:
	print(-1)
	exit()
print(''.join(l2))


n = str(input())
n = list(n)
n = [int(n[i]) for i in range(len(n))]
flag = 0
l = []
for i in n:
	if i % 2 == 0:
		flag = 1
		l.append(i)
		break
if flag == 0:
	print(-1)
else:
	f = 0
	for i in range(len(n)):
		if n[i] % 2 == 0 and n[i] < n[len(n) - 1]:
			(n[i], n[len(n) - 1]) = (n[len(n) - 1], n[i])
			f = 1
			break
	if f == 0:
		for i in range(len(n) - 1, -1, -1):
			if n[i] % 2 == 0 and n[i] > n[len(n) - 1]:
				(n[i], n[len(n) - 1]) = (n[len(n) - 1], n[i])
				break
	print(''.join((str(x) for x in n)))


n = list(str(input()))
flag = True
k = n[-1]
f = -1
for i in range(len(n) - 1, -1, -1):
	if int(n[i]) % 2 == 0:
		f = i
		break
	pass
if f == -1:
	print(f)
for i in range(len(n)):
	if not flag:
		break
	if int(n[i]) % 2 == 0:
		if int(n[i]) < int(k) or i == f:
			(n[-1], n[i]) = (n[i], n[-1])
			print(''.join(n))
			flag = False
			break


def cur(s):
	s1 = ''
	ci = -1
	for i in range(len(s) - 1):
		if int(s[i]) % 2 == 0 and int(s[i]) < int(s[-1]):
			return s[0:i] + s[-1] + s[i + 1:len(s) - 1] + s[i]
		elif int(s[i]) % 2 == 0 and int(s[i]) > int(s[-1]):
			ci = i
	if ci != -1:
		return s[0:ci] + s[-1] + s[ci + 1:len(s) - 1] + s[ci]
	return -1
st = input()
print(cur(st))


s = input()
t = s[-1]
ans = ''
temp = 0
s = list(s)
flag = False
re = 0
for i in range(len(s)):
	if int(s[i]) % 2 == 0:
		re += 1
if re == 0:
	print(-1)
	quit()
for i in range(len(s)):
	if int(s[i]) % 2 == 0:
		if int(t) > int(s[i]):
			(s[i], s[-1]) = (s[-1], s[i])
			print(''.join(s))
			flag = True
			break
		else:
			temp = i
if flag == False:
	(s[-1], s[temp]) = (s[temp], s[-1])
	print(''.join(s))


s = input()
max = len(s) - 1
for i in range(len(s) - 1, -1, -1):
	if int(s[i]) % 2 == 0 and (s[-1] > s[i] or max == len(s) - 1):
		max = i
if max == len(s) - 1:
	print(-1)
else:
	print(s[:max] + s[-1] + s[max + 1:-1] + s[max])


arr = list(input())
n = len(arr)
b = -1
for i in range(n):
	if int(arr[i]) % 2 != 0:
		continue
	else:
		b = i
	if arr[i] < arr[-1]:
		break
if b == -1:
	print(-1)
else:
	(arr[b], arr[-1]) = (arr[-1], arr[b])
	print(''.join(arr))


str1 = input()
numlist = list()
for ch in str1:
	numlist.append(int(ch))
check = False
for i in range(0, len(numlist)):
	if numlist[i] % 2 == 0 and numlist[i] < numlist[-1]:
		(numlist[i], numlist[-1]) = (numlist[-1], numlist[i])
		check = True
		break
if check == False:
	for i in range(len(numlist) - 1, -1, -1):
		if numlist[i] % 2 == 0:
			(numlist[i], numlist[-1]) = (numlist[-1], numlist[i])
			check = True
			break
if check == False:
	print(-1)
else:
	str1 = ''
	for el in numlist:
		str1 = str1 + str(el)
	print(str1)


def printlist(l):
	for i in l:
		print(i, end='')
	print()
s = list(input())
l = len(s)
x = int(s[l - 1])
last = -1
for i in range(int(l)):
	d = int(s[i])
	if d % 2 == 0:
		if d < x:
			(s[l - 1], s[i]) = (s[i], s[l - 1])
			printlist(s)
			exit()
		last = i
if last == -1:
	print(-1)
else:
	(s[l - 1], s[last]) = (s[last], s[l - 1])
	printlist(s)


n = input()
c_p = -1
for i in range(len(n)):
	if int(n[i]) % 2 == 0:
		if int(n[len(n) - 1]) > int(n[i]):
			print(n[:i] + n[len(n) - 1] + n[i + 1:len(n) - 1] + n[i])
			quit()
		else:
			c_p = i
if c_p == -1:
	print(-1)
else:
	print(n[:c_p] + n[len(n) - 1] + n[c_p + 1:len(n) - 1] + n[c_p])


inp = input()
n = [i for i in inp]
changeIdx = -1
for i in range(len(n) - 1):
	x = int(n[i])
	if x % 2 is 0:
		changeIdx = i
		if x < int(n[-1]):
			break
if changeIdx is -1:
	print('-1')
else:
	tmp = n[-1]
	n[-1] = n[changeIdx]
	n[changeIdx] = tmp
	print(''.join(n))


def swap(c, r, t):
	c = list(c)
	(c[r], c[t]) = (c[t], c[r])
	return ''.join(c)
k = -1
j = -1
n = input()
for i in range(len(n)):
	k = i
	if int(n[i]) % 2 == 0:
		j = i
		if n[i] < n[len(n) - 1]:
			print(swap(n, i, len(n) - 1))
			break
if k == len(n) - 1 and j != -1:
	print(swap(n, j, k))
elif k == len(n) - 1 and j == -1:
	print(-1)


from sys import stdin, stdout

def count_ev(string):
	result = 0
	for c in string:
		if int(c) & 1 == 0:
			result += 1
	return result

def swap_chars(string, pos, r):
	return string[:pos] + string[r] + string[pos + 1:r] + string[pos]

def solve(n):
	count_even = count_ev(n)
	if count_even == 0:
		return -1
	l = 0
	r = len(n) - 1
	result = ''
	while count_even > 0 and l < r:
		if int(n[l]) & 1 == 0:
			if n[r] > n[l] or count_even == 1:
				result = swap_chars(n, l, r)
				return result
			count_even -= 1
		l += 1
	return result
n = str(stdin.readline().rstrip())
stdout.write(str(solve(n)))


n = str(input())
max_n = -1
last_n = int(n[-1])
for (x, y) in enumerate(n):
	if int(y) % 2 == 0:
		max_n = x
		if int(y) < last_n:
			break
if max_n == -1:
	print(-1)
else:
	print(n[:max_n] + n[-1] + n[max_n + 1:-1] + n[max_n])


from sys import stdin, stdout
n = stdin.readline()
s = list(str(n))
del s[-1]
even = 0
for i in range(len(s)):
	if int(s[i]) % 2 == 0:
		j = i
		even = 1
		if int(s[i]) < int(s[-1]):
			break
if even:
	(s[j], s[-1]) = (s[-1], s[j])
	ans = ''.join(s)
else:
	ans = '-1'
stdout.write(ans + '\n')


n = [int(i) for i in input()]
a = n[-1]
(x, y) = (-1, -1)
b = 10
for i in range(len(n)):
	if n[i] % 2 == 0:
		if n[i] < a:
			y = i
			b = 0
			break
		x = i
		b = 0
if b != 0:
	print(-1)
else:
	if y == -1:
		(n[x], n[-1]) = (n[-1], n[x])
	else:
		(n[y], n[-1]) = (n[-1], n[y])
	print(''.join([str(i) for i in n]))


def swap(c, i, j):
	l1 = list(c)
	(l1[i], l1[j]) = (l1[j], l1[i])
	return ''.join(l1)
inp = input()
t = False
t1 = False
last = inp[len(inp) - 1]
for i in range(len(inp)):
	if int(inp[i]) % 2 == 0 and inp[i] < last:
		t = True
		x = swap(inp, i, len(inp) - 1)
		print(x)
		break
if t == False:
	n = len(inp)
	while n != 0:
		if int(inp[n - 1]) % 2 == 0:
			x = swap(inp, n - 1, len(inp) - 1)
			t1 = True
			print(x)
			break
		n = n - 1
if t == False and t1 == False:
	print('-1')


n = list(input())
s = n[-1]
f = 0
for i in range(len(n) - 1):
	if int(n[i]) % 2 == 0 and int(n[i]) < int(s):
		(n[i], n[-1]) = (n[-1], n[i])
		f = 1
		print(''.join(n))
		break
for i in range(len(n) - 2, -1, -1):
	if int(n[i]) % 2 == 0 and f == 0:
		temp = n[i]
		n[i] = n[-1]
		n[-1] = temp
		f = 1
		print(''.join(n))
		break
if f == 0:
	print(-1)


strr = input()
ans = -1
for i in range(len(strr) - 1):
	if strr[i] in '02468':
		ans = i
		if strr[ans] < strr[-1]:
			break
if ans == -1:
	print(ans)
else:
	strr = list(strr)
	(strr[ans], strr[-1]) = (strr[-1], strr[ans])
	print(''.join(strr))


from __future__ import division, print_function
from sys import stdin, stdout
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict
import heapq
from fractions import Fraction
import math

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

def si():
	return str(input())

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

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

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

def fsi():
	return str(stdin.readline())

def fmi():
	return map(int, stdin.readline().split())

def fli():
	return list(fmi())
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
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

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

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 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
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def dfs(v, c):
	if visited[v]:
		if col[v] != c:
			print('-1')
			exit()
		return
	col[v] = c
	visited[v] = 1
	for i in graph[v]:
		dfs(i, c ^ 1)

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph(e):
	d = defaultdict(list)
	for i in range(e):
		(x, y) = mi()
		d[x].append(y)
		d[y].append(x)
	return d

def gr2(n):
	d = defaultdict(list)
	for i in range(n):
		(x, y) = mi()
		d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans

def primeFactors(n):
	s = set()
	while n % 2 == 0:
		s.add(2)
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			s.add(i)
			n = n // i
	if n > 2:
		s.add(n)
	return s

def find_all(a_str, sub):
	start = 0
	while True:
		start = a_str.find(sub, start)
		if start == -1:
			return
		yield start
		start += len(sub)

def SieveOfEratosthenes(n, isPrime):
	isPrime[0] = isPrime[1] = False
	for i in range(2, n + 1):
		isPrime[i] = True
	p = 2
	while p * p <= n:
		if isPrime[p] == True:
			i = p * p
			while i <= n:
				isPrime[i] = False
				i += p
		p += 1
s = si()
s = list(s)
x = -1
for i in range(len(s)):
	if int(s[i]) % 2 == 0:
		if s[i] > s[-1]:
			x = i
		else:
			x = i
			break
if x != -1:
	(s[x], s[-1]) = (s[-1], s[x])
	print(''.join(s))
else:
	print(-1)


n = list(input())
flag = 0
tem = 0
for i in range(len(n) - 2, -1, -1):
	if int(n[i]) % 2 == 0:
		if flag == 1 and int(n[i]) < int(n[len(n) - 1]):
			tem = i
		elif flag == 0:
			tem = i
			flag = 1
if flag:
	a = n[tem]
	n[tem] = n[len(n) - 1]
	n[len(n) - 1] = a
	for i in n:
		print(i, end='')
else:
	print(-1)


s = [int(i) for i in input()]
p = -1
for i in range(len(s)):
	if s[i] % 2 == 0:
		if s[i] < s[-1]:
			(s[i], s[-1]) = (s[-1], s[i])
			[print(t, end='') for t in s]
			exit()
		else:
			p = i
if p == -1:
	print(p)
	exit()
(s[p], s[-1]) = (s[-1], s[p])
[print(t, end='') for t in s]


import sys
st = sys.stdin.readline()
ln = len(st) - 1
cur = -1
c = int(st[ln - 1])
res = list(st)
for i in range(ln - 1):
	if int(st[i]) % 2 == 0:
		if int(st[i]) < c:
			cur = i
			break
		else:
			cur = i
if cur == -1:
	print(-1)
else:
	v = res[cur]
	res[cur] = res[ln - 1]
	res[ln - 1] = v
	print(''.join(res))


s = input()
n = len(s)
cnt_even = 0
evens = []
shode = False
last = int(s[-1])
for i in range(n):
	if int(s[i]) % 2 == 0:
		cnt_even += 1
		evens.append(i)
if cnt_even == 0:
	print(-1)
else:
	for i in evens:
		if int(s[i]) < last:
			new_s = s[:i] + str(last) + s[i + 1:n - 1] + s[i]
			shode = True
			break
	if not shode:
		new_s = s[:evens[-1]] + str(last) + s[evens[-1] + 1:n - 1] + s[evens[-1]]
	print(new_s)


n = list(input())
last_swap = -1
for i in range(len(n) - 1):
	c = int(n[i])
	if c % 2 == 0:
		if c < int(n[-1]):
			(n[i], n[-1]) = (n[-1], n[i])
			print(''.join(n))
			exit()
		else:
			last_swap = i
if last_swap == -1:
	print(-1)
else:
	(n[last_swap], n[-1]) = (n[-1], n[last_swap])
	print(''.join(n))


n = list(map(int, input()))
even = -1
ind = -1
for i in range(len(n)):
	if n[i] % 2 == 0:
		if n[i] < n[-1]:
			ind = i
			break
		else:
			even = i
if even == -1 and ind == -1:
	print(-1)
else:
	if ind != -1:
		(n[ind], n[-1]) = (n[-1], n[ind])
	else:
		(n[even], n[-1]) = (n[-1], n[even])
	print(*n, sep='')


n = list(input())
a = []
yo = 0
y = -1
for (i, j) in enumerate(n):
	if int(j) % 2 == 0:
		y = i
		if int(j) < int(n[-1]):
			break
if y == -1:
	print(-1)
else:
	(n[-1], n[y]) = (n[y], n[-1])
	x = ''.join(n)
	print(x)


m = input()
n = 0
f = 0
j = 0
for i in m:
	if int(i) % 2 == 0:
		n = j
		f = 1
		if m[-1] > i:
			break
	j += 1
if f == 0:
	print(-1)
else:
	print(m[:n] + m[-1] + m[n + 1:-1] + m[n])


n = input()
l = list(n)
tochange = n[len(n) - 1]
index1 = len(n) - 1
changewith = -1
index2 = -1
for i in range(len(n)):
	if int(n[i]) % 2 == 0:
		changewith = n[i]
		index2 = i
		if int(n[i]) < int(tochange):
			break
if changewith == -1:
	print('-1')
else:
	temp = l[index2]
	l[index2] = l[index1]
	l[index1] = temp
	n = ''.join(l)
	print(n)


s = input()
n = len(s)
l = int(s[-1])
m = 1
k = -10
for i in range(n - 1):
	if int(s[i]) % 2 == 0:
		if m == 1:
			m = int(s[i])
			x = i
			k = l - m
		elif m == int(s[i]):
			if k < 0:
				x = i
		elif m > l:
			m = int(s[i])
			x = i
			k = l - m
if m != 1:
	print(s[:x] + s[-1] + s[x + 1:-1] + str(m))
else:
	print(-1)


n = list(map(int, input().rstrip()))
sum = -1
for i in range(len(n)):
	if n[i] % 2 != 0:
		continue
	sum = i
	if n[len(n) - 1] > n[i]:
		break
if sum != -1:
	(n[sum], n[len(n) - 1]) = (n[len(n) - 1], n[sum])
	print(*n, sep='')
else:
	print('-1')