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

Difficulty: interview

Starter code:

Solutions:
"""
Codeforces Contest 288 Div 2 Problem B

Author  : chaotic_iak
Language: Python 3.4.2
"""

################################################### SOLUTION

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]



#################################################### HELPERS



def read(mode=2):
    # 0: String
    # 1: List of strings
    # 2: List of integers
    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())

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 = '')

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 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))
        return

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))
        return

print(-1)

x = input()

pos = -1
last = ord(x[-1]) - 48
for i, c in enumerate(x):
    cur = ord(c) - 48
    if not cur & 0b1:
        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)


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()


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)



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))

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')


def ans():
    ap= list(input())
    #b= a[::-1]
    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()      

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)
    return
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)
        return
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)
        return

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])


N = input()

arr = []
for i in range( 0 , len(N)-1):
    if int(N[i])%2 == 0:
        arr.append( {"index":i , "num":N[i]} )
#print(arr)

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()
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)


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))

	

def __starting_point():
	main()


__starting_point()

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)


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)


def __starting_point():
    main()

__starting_point()

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)

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 = list(input())
m = -1
for i, d in enumerate(n):
	if int(d) % 2 == 0:
		m = i
		if int(d) < int(n[-1]):
			break
if m < 0:
	print(-1)
else:
	n[-1], n[m] = n[m], n[-1]
	print(''.join(n))


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()
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)

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)

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)


def judge(ss):
    n=len(ss)
    for i in range(n):
        if( (int(ss[i])%2==0) ):  #input() haoxiang doushi str
            return i
    return -1

s=input()
p=judge(s)
#print(p)
if(p==-1):
    print("-1")
else:
    n=len(s)
    flag=0
    las=n-1
    for i in range(n):
        if( int(s[i])%2==0 ):
            p=i
            if int(s[i])<int(s[las]) :
                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)