There was a string $$$s$$$ which was supposed to be encrypted. For this reason, all $$$26$$$ lowercase English letters were arranged in a circle in some order, afterwards, each letter in $$$s$$$ was replaced with the one that follows in clockwise order, in that way the string $$$t$$$ was obtained. You are given a string $$$t$$$. Determine the lexicographically smallest string $$$s$$$ that could be a prototype of the given string $$$t$$$.A string $$$a$$$ is lexicographically smaller than a string $$$b$$$ of the same length if and only if:   in the first position where $$$a$$$ and $$$b$$$ differ, the string $$$a$$$ has a letter, that appears earlier in the alphabet than the corresponding letter in $$$b$$$.

The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^4$$$) — the number of test cases. The description of test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the string $$$t$$$. The next line contains the string $$$t$$$ of the length $$$n$$$, containing lowercase English letters. It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

For each test case, output a single line containing the lexicographically smallest string $$$s$$$ which could be a prototype of $$$t$$$.

5

1

a

2

ba

10

codeforces

26

abcdefghijklmnopqrstuvwxyz

26

abcdefghijklmnopqrstuvwxzy

b
ac
abcdebfadg
bcdefghijklmnopqrstuvwxyza
bcdefghijklmnopqrstuvwxyaz

NoteIn the first test case, we couldn't have the string "a", since the letter a would transit to itself. Lexicographically the second string "b" is suitable as an answer.In the second test case, the string "aa" is not suitable, since a would transit to itself. "ab" is not suitable, since the circle would be closed with $$$2$$$ letters, but it must contain all $$$26$$$. The next string "ac" is suitable.Below you can see the schemes for the first three test cases. The non-involved letters are skipped, they can be arbitrary placed in the gaps.

package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
)

var in = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func readInt(delim byte) (int, error) {
	s, err := in.ReadString(delim)
	if err != nil {
		return 0, err

	}
	s = strings.TrimRight(s, " \r\n")
	n, err := strconv.Atoi(s)
	if err != nil {
		return 0, err
	}

	return n, nil
}

func main() {
	defer out.Flush()
	t, err := readInt('\n')
	if err != nil {
		out.WriteString("Error received in reading t: " + err.Error() + "\n")
	} else {
		for {
			if t == 0 {
				break
			}
			t--
			n, err := readInt('\n')
			if err != nil {
				out.WriteString("Error received in reading n: " + err.Error() + "\n")
			}
			s, err := in.ReadString('\n')
			if err != nil {
				out.WriteString("Error in reading string: " + err.Error())
				break
			}
			s = strings.TrimRight(s, " \r\n")
			if len(s) != n {
				out.WriteString("Not enough length\n")
				break
			}
			a := make([]int, 26)

			done := make([]bool, 26)
			tail := make([]int, 26)
			lens := make([]int, 26)
			head := make([]int, 26)
			for i := 0; i < 26; i++ {
				tail[i] = i
				lens[i] = 1
				a[i] = -1
				head[i] = i
			}
			for i := 0; i < n; i++ {
				cur := int(s[i] - 'a')
				//out.WriteRune(rune(cur + 'a'))
				if a[cur] == -1 {
					for j := 0; j < 26; j++ {
						if !done[j] && (tail[cur] != j || lens[cur] == 26) {
							a[cur] = j
							done[j] = true
							tail[head[j]] = tail[cur]
							head[tail[cur]] = head[j]
							lens[head[j]] += lens[cur]
							break
						}
					}
				}
				//out.WriteString(" " + string(a[cur]+'a') + "\n")
				out.WriteRune(rune(a[cur] + 'a'))
			}
			out.WriteString("\n")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func get_cycle_length(next *map[string]string, root string) int {
	i := 1
	v := (*next)[root]
	for v != root {
		i++
		_, prs := (*next)[v]
		if !prs {
			i = -1
			break
		}
		v = (*next)[v]
	}
	return i
}

func get_new_parent(next *map[string]string, excl string) string {
	alpha := []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
	for _, a := range alpha {
		if _, prs := (*next)[a]; !prs && a != excl {
			(*next)[a] = excl
			cl := get_cycle_length(next, a)
			delete(*next, a)
			if cl != -1 && cl != 26 {
				continue
			}
			return a
		}
	}
	return "a"
}

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var T, n int
	fmt.Fscan(r, &T)
	for i := 0; i < T; i++ {
		fmt.Fscan(r, &n)
		var t, s string

		fmt.Fscan(r, &t)
		t_slice := strings.Split(t, "")

		next := make(map[string]string)
		parent := make(map[string]string)

		var s_slice []string
		for _, c := range t_slice {
			v, prs := parent[c]
			if !prs {
				v = get_new_parent(&next, c)
				parent[c] = v
				next[v] = c
			}
			s_slice = append(s_slice, v)
		}

		s = strings.Join(s_slice, "")
		fmt.Fprintln(w, s)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func get_cycle_length(next *map[string]string, root string) int {
	i := 1
	v := (*next)[root]
	for v != root && i < 30 {
		i++
		_, prs := (*next)[v]
		if !prs {
			i = -1
			break
		}
		v = (*next)[v]
	}
	return i
}

func get_new_parent(next *map[string]string, excl string) string {
	alpha := []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
	for _, a := range alpha {
		if _, prs := (*next)[a]; !prs && a != excl && (*next)[excl] != a {
			(*next)[a] = excl
			cl := get_cycle_length(next, a)
			delete(*next, a)
			// fmt.Println("%%% Alpha ", a) // ***
			// fmt.Println("%%% length of cycle ", cl) // ***
			if cl != -1 && cl != 26 {
				continue
			}
			return a
		}
	}
	return "a"
}

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var T, n int
	fmt.Fscan(r, &T)
	for i := 0; i < T; i++ {
		// fmt.Println("### TC ", i+1) // ***
		fmt.Fscan(r, &n)
		var t, s string

		fmt.Fscan(r, &t)
		t_slice := strings.Split(t, "")
		// fmt.Println("### t_slice ", t_slice) // ***

		next := make(map[string]string)
		parent := make(map[string]string)

		var s_slice []string
		for _, c := range t_slice {
			// fmt.Println("### Looping through t_slice, c ", c) // ***
			v, prs := parent[c]
			if !prs {
				v = get_new_parent(&next, c)
				parent[c] = v
				next[v] = c
			}
			// fmt.Println("### Looping through t_slice, parent of c ", parent[c]) // ***
			s_slice = append(s_slice, v)
			// fmt.Println("### Looping through t_slice, contents of s_slice ", s_slice) // ***
		}

		s = strings.Join(s_slice, "")
		fmt.Fprintln(w, s)
	}
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		var s string
		fmt.Fscan(in, &n, &s)

		aa := make([]int, 26)
		bb := make([]int, 26)
		for i := range aa {
			aa[i] = -1
			bb[i] = 1
		}

		next := func(x int) int {
			var c int
			g := x
			for g != -1 {
				c++
				g = aa[g]
				if g == x {
					return c
				}
			}
			return -1
		}

		for _, ch := range s {
			if aa[ch-'a'] < 0 {
				for i := 0; i < 26; i++ {
					if bb[i] != 0 && i != int(ch-'a') {
						aa[ch-'a'] = i
						z := next(i)
						if z == -1 || z == 26 {
							bb[i] = 0
							break
						}
					}
				}
			}
		}

		var buf bytes.Buffer
		for _, ch := range s {
			buf.WriteRune(rune(aa[ch-'a'] + 'a'))
		}
		fmt.Fprintln(out, buf.String())
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const cf = true

func solve() {
	var n int
	fmt.Fscan(in, &n)
	arr := make([]byte, n)
	fmt.Fscan(in, &arr)
	transitions := make(map[byte]byte)
	var taken set[byte]
	ans := make([]byte, n)
loop:
	for i, char := range arr {
		val, ok := transitions[char]
		if ok {
			ans[i] = val
			continue
		}

		for ch := "a"[0]; ch <= "z"[0]; ch++ {
			if ch == char || taken.has(ch) {
				continue
			}
			res, ok := transitions[ch]
			transCnt := 1
			for ok && transCnt <= 26 {
				next, ok := transitions[res]
				if !ok {
					break
				}
				res = next
				transCnt++
				if res == char {
					break
				}
			}
			if ok && res == char && transCnt != 25 {
				continue
			}
			transitions[char] = ch
			ans[i] = ch
			taken.add(ch)
			continue loop
		}
	}
	fmt.Fprintln(out, string(ans))
}

func main() {
	defer out.Flush()
	t := 1
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		solve()
	}
}

func ConvertInt(val string, base, toBase int) (string, error) {
	i, err := strconv.ParseInt(val, base, 64)
	if err != nil {
		return "", err
	}
	return strconv.FormatInt(i, toBase), nil
}

type set[T Ordered] struct {
	itms map[T]struct{}
}

func (s *set[T]) init() {
	if s.itms == nil {
		s.itms = make(map[T]struct{})
	}
}

func (s *set[T]) add(item T) *set[T] {
	s.init()
	s.itms[item] = exists
	return s
}

func (s *set[T]) remove(item T) *set[T] {
	s.init()
	delete(s.itms, item)
	return s
}

func (s *set[T]) has(item T) bool {
	s.init()
	_, c := s.itms[item]
	return c
}

func (s *set[T]) sortedItems() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	sort.Slice(items, func(i, j int) bool {
		return items[i] < items[j]
	})
	return items
}

func (s *set[T]) items() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	return items
}

func (s *set[T]) size() int {
	s.init()
	return len(s.itms)
}

var exists = struct{}{}

const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1

func reverseStr(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type Ordered interface {
	Integer | Float | ~string
}

func abs[T Signed](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

func min[T Ordered](x, y T) T {
	if x < y {
		return x
	}
	return y
}

func max[T Ordered](x, y T) T {
	if x > y {
		return x
	}
	return y
}

var (
	in  = getReader()
	out = getWriter()
)

func getReader() *bufio.Reader {
	if cf {
		return bufio.NewReader(os.Stdin)
	} else {
		in, _ := os.Open("input.txt")
		return bufio.NewReader(in)
	}
}

func getWriter() *bufio.Writer {
	if cf {
		return bufio.NewWriter(os.Stdout)
	} else {
		out, _ := os.Create("output.txt")
		return bufio.NewWriter(out)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	writer  = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
)

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(writer, f, a...)
}

func _int() int {
	s := _string()
	i := 0
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int(r - '0')
	}
	return i
}

func _int64() int64 {
	s := _string()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func _string() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func main() {
	defer writer.Flush()
	for t := _int(); t > 0; t-- {
		n := _int()
		ts := _string()
		printf("%s\n", sol(n, ts))
	}
}

func sol(n int, t string) string {
	sm := make26()
	tm := make26()
	count := 0
	for i := range t {
		// printf("mapping ch:%v\n", i)
		ch := int(t[i] - 'a')
		if tm[ch] != -1 {
			continue
		}
		// try each letter
		for i := range sm {
			// printf("trying candidate=%v->%v\n", i, ch)
			if i == ch {
				continue
			}
			// found candidate
			if sm[i] == -1 {
				if count != 25 { // special case last letter
					// printf("sm=%v\n", sm)
					cyc := false
					to := sm[ch]
					for {
						// printf("to=%v\n", to)
						if to == -1 {
							break
						}
						if to == i {
							cyc = true
							break
						}
						to = sm[to]
					}
					// printf("cyc=%v\n", cyc)
					if cyc {
						// printf("cycle detected \n")
						continue
					}
				}
				sm[i] = ch
				tm[ch] = i
				count++
				break
			}
		}
	}
	ret := make([]rune, len(t))
	for i := range t {
		ch := t[i] - 'a'
		ret[i] = rune(tm[ch] + 'a')
	}
	return string(ret)
}

func make26() [26]int {
	ret := [26]int{}
	for i := range ret {
		ret[i] = -1
	}
	return ret
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var in, out = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)

func main() {
	defer out.Flush()

	var tc, n int
	var q [1e5 + 1]byte
	for fmt.Fscan(in, &tc); tc > 0; tc-- {
		var s string
		fmt.Fscan(in, &n, &s)
		var prev [128]byte
		for i, c := range s {
			c := byte(c)
			if prev[c] != 0 {
				q[i] = prev[c]
				continue
			}
			for ch := byte('a'); ch <= 'z'; ch++ {
				if ch == byte(c) {
					continue
				}
				ok := true
				for och := 'a'; ok && och <= 'z'; och++ {
					ok = prev[och] != ch
				}
				if !ok {
					continue
				}
				if prev[ch] != 0 {
					// don't form bad cycles
					startch, cyclelen := prev[ch], 1
					for ; prev[startch] != 0; startch = prev[startch] {
						cyclelen++
					}
					if startch == c && cyclelen < 25 {
						continue
					}
				}
				prev[c] = ch
				q[i] = ch
				break
			}
			if prev[c] == 0 {
				panic("internal error")
			}
		}
		fmt.Fprintln(out, string(q[:len(s)]))
	}
}

package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
)

var in = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func readInt(delim byte) (int, error) {
	s, err := in.ReadString(delim)
	if err != nil {
		return 0, err

	}
	s = strings.TrimRight(s, " \r\n")
	n, err := strconv.Atoi(s)
	if err != nil {
		return 0, err
	}

	return n, nil
}

func main() {
	defer out.Flush()
	t, err := readInt('\n')
	if err != nil {
		out.WriteString("Error received in reading t: " + err.Error() + "\n")
	} else {
		for {
			if t == 0 {
				break
			}
			t--
			n, err := readInt('\n')
			if err != nil {
				out.WriteString("Error received in reading n: " + err.Error() + "\n")
			}
			s, err := in.ReadString('\n')
			if err != nil {
				out.WriteString("Error in reading string: " + err.Error())
				break
			}
			s = strings.TrimRight(s, " \r\n")
			if len(s) != n {
				out.WriteString("Not enough length\n")
				break
			}
			a := make([]int, 26)

			done := make([]bool, 26)
			rep := make([]int, 26)
			lens := make([]int, 26)
			for i := 0; i < 26; i++ {
				rep[i] = i
				lens[i] = 1
				a[i] = -1
			}
			for i := 0; i < n; i++ {
				cur := int(s[i] - 'a')
				//out.WriteRune(rune(cur + 'a'))
				if a[cur] == -1 {
					for j := 0; j < 26; j++ {
						if !done[j] && (rep[cur] != j || lens[cur] == 26) {
							a[cur] = j
							done[j] = true
							rep[j] = rep[cur]
							lens[j] += lens[cur]
							break
						}
					}
				}
				//out.WriteString(" " + string(a[cur]+'a') + "\n")
				out.WriteRune(rune(a[cur] + 'a'))
			}
			out.WriteString("\n")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const cf = true

func solve() {
	var n int
	fmt.Fscan(in, &n)
	arr := make([]byte, n)
	fmt.Fscan(in, &arr)
	transitions := make(map[byte]byte)
	var taken set[byte]
	ans := make([]byte, n)
loop:
	for i, ch := range arr {
		val, ok := transitions[ch]
		if ok {
			ans[i] = val
			continue
		}

		cha := "a"[0]
		if taken.has(ch) {
			cha = ch + 1
		}

		for ; cha <= "z"[0]; cha++ {
			if cha == ch {
				continue
			}
			if taken.has(cha) {
				continue
			}
			taken.add(cha)
			transitions[ch] = cha
			ans[i] = cha
			continue loop
		}
		tmp := cha
		for cha := "a"[0]; cha < tmp; cha++ {
			if cha == ch {
				continue
			}
			if taken.has(cha) {
				continue
			}
			taken.add(cha)
			transitions[ch] = cha
			ans[i] = cha
			continue loop
		}
	}
	fmt.Fprintln(out, string(ans))
}

func main() {
	defer out.Flush()
	t := 1
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		solve()
	}
}

func ConvertInt(val string, base, toBase int) (string, error) {
	i, err := strconv.ParseInt(val, base, 64)
	if err != nil {
		return "", err
	}
	return strconv.FormatInt(i, toBase), nil
}

type set[T Ordered] struct {
	itms map[T]struct{}
}

func (s *set[T]) init() {
	if s.itms == nil {
		s.itms = make(map[T]struct{})
	}
}

func (s *set[T]) add(item T) *set[T] {
	s.init()
	s.itms[item] = exists
	return s
}

func (s *set[T]) remove(item T) *set[T] {
	s.init()
	delete(s.itms, item)
	return s
}

func (s *set[T]) has(item T) bool {
	s.init()
	_, c := s.itms[item]
	return c
}

func (s *set[T]) sortedItems() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	sort.Slice(items, func(i, j int) bool {
		return items[i] < items[j]
	})
	return items
}

func (s *set[T]) items() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	return items
}

func (s *set[T]) size() int {
	s.init()
	return len(s.itms)
}

var exists = struct{}{}

const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1

func reverseStr(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type Ordered interface {
	Integer | Float | ~string
}

func abs[T Signed](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

func min[T Ordered](x, y T) T {
	if x < y {
		return x
	}
	return y
}

func max[T Ordered](x, y T) T {
	if x > y {
		return x
	}
	return y
}

var (
	in  = getReader()
	out = getWriter()
)

func getReader() *bufio.Reader {
	if cf {
		return bufio.NewReader(os.Stdin)
	} else {
		in, _ := os.Open("input.txt")
		return bufio.NewReader(in)
	}
}

func getWriter() *bufio.Writer {
	if cf {
		return bufio.NewWriter(os.Stdout)
	} else {
		out, _ := os.Create("output.txt")
		return bufio.NewWriter(out)
	}
}


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!

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 105, inclusive. The representation of n doesn't contain any leading zeroes.

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.

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"bytes"
)

var reader = bufio.NewReader(os.Stdin)
var scanner = bufio.NewScanner(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	s, _ := reader.ReadBytes('\n')
	s = bytes.TrimSpace(s)
	n := len(s) - 1

	for i := 0; i < n; i++ {
		if (s[i] - '0') % 2 == 0 && s[i] < s[n] {
			s[i], s[n] = s[n], s[i]
			println(string(s))
			return
		}
	}

	for i := n-1; i >= 0; i-- {
		if (s[i] % 2) == 0 && s[i] > s[n] {
			s[i], s[n] = s[n], s[i]
			println(string(s))
			return
		}
	}

	println(-1)
}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"bytes"
	"io/ioutil"
)

var reader = bufio.NewReader(os.Stdin)
var scanner = bufio.NewScanner(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	s, _ := ioutil.ReadAll(os.Stdin)
	// s, _ := reader.ReadBytes('\n')
	s = bytes.TrimSpace(s)
	n := len(s) - 1

	for i := 0; i < n; i++ {
		if (s[i] - '0') % 2 == 0 && s[i] < s[n] {
			s[i], s[n] = s[n], s[i]
			println(string(s))
			return
		}
	}

	for i := n-1; i >= 0; i-- {
		if (s[i] % 2) == 0 && s[i] > s[n] {
			s[i], s[n] = s[n], s[i]
			println(string(s))
			return
		}
	}

	println(-1)
}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	// "bytes"
	// "io/ioutil"
)

var reader = bufio.NewReader(os.Stdin)
var scanner = bufio.NewScanner(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	t := ""
	scan(&t)

	// s, _ := ioutil.ReadAll(os.Stdin)
	// s, _ := reader.ReadBytes('\n')
	// s = bytes.TrimSpace(s)
	s := []byte(t)
	n := len(s) - 1

	for i := 0; i < n; i++ {
		if (s[i] - '0') % 2 == 0 && s[i] < s[n] {
			s[i], s[n] = s[n], s[i]
			println(string(s))
			return
		}
	}

	for i := n-1; i >= 0; i-- {
		if (s[i] % 2) == 0 && s[i] > s[n] {
			s[i], s[n] = s[n], s[i]
			println(string(s))
			return
		}
	}

	println(-1)
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

package main

import (
  "os"
  "bufio"
  "strings"
)

func cToI(c byte) int {
  return int(c - '0')
}

func main() {
  reader := bufio.NewReader(os.Stdin)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  line, _ := reader.ReadString('\n')
  bytes := []byte(strings.TrimSpace(line))
  n := len(bytes)
  last := cToI(bytes[n-1])
  for i := 0; i < n; i++ {
    current := cToI(bytes[i])
    if current%2 == 0 && current < last {
      bytes[i], bytes[n-1] = bytes[n-1], bytes[i]
      writer.Write(bytes)
      writer.WriteString("\n")
      return
    }
  }
  for i := n-2; i >= 0; i-- {
    current := cToI(bytes[i])
    if current%2 == 0 {
      bytes[i], bytes[n-1] = bytes[n-1], bytes[i]
      writer.Write(bytes)
      writer.WriteString("\n")
      return
    }
  }

  writer.WriteString("-1\n")
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	if str, err := reader.ReadString('\n'); err != nil {
		if err != io.EOF {
			return
		}
	} else {
		var n int
		for n = 0; str[n] != '\n' && str[n] != '\r'; n++ {
		}

		s := make([]byte, n)

		var last_digit byte = str[n-1] - '0'
		var last_even_idx int = -1
		var swapped_idx int = -1

		for i := 0; i < n-1; i++ {
			s[i] = str[i] - '0'
			if s[i]%2 == 0 {
				last_even_idx = i
				if s[i] < last_digit && swapped_idx < 0 {
					s[n-1] = s[i]
					s[i] = last_digit
					swapped_idx = i
				}
			}
		}
		if swapped_idx < 0 {
			if last_even_idx < 0 {
				fmt.Println("-1")
				return
			} else {
				s[n-1] = s[last_even_idx]
				s[last_even_idx] = last_digit
			}
		}
		for i := 0; i < n; i++ {
			fmt.Printf("%d", s[i])
		}
		fmt.Println()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	n      string
	result string
)

func in() {
	read(&n)
}

func out() {
	println(result)
	defer output.Flush()
}

func run() {
	arr := []byte(n)
	l := len(arr)
	last := arr[l-1]
	switched := false
	for i := 0; i < l-1; i++ {
		if arr[i]%2 == 0 && arr[i] < last {
			arr[i], arr[l-1] = arr[l-1], arr[i]
			switched = true
			break
		}
	}

	if !switched {
		for i := l - 2; i >= 0; i-- {
			if arr[i]%2 == 0 {
				arr[i], arr[l-1] = arr[l-1], arr[i]
				switched = true
				break
			}
		}
	}

	if switched {
		result = string(arr)
	} else {
		result = "-1"
	}
}

/** main **/
func main() {
	in()
	run()
	out()
}

// Input & Output
var (
	input  = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

func read(a ...interface{}) {
	_, err := fmt.Fscan(input, a...)
	if err != nil {
		println(err)
	}
}

func println(a ...interface{}) {
	fmt.Fprintln(output, a...)
}

func printf(format string, a ...interface{}) {
	fmt.Fprintf(output, format, a...)
}

package main

import (
	"fmt"
	"io"
	"os"
)

func contest(in io.Reader) {
	var s string
	if _, err := fmt.Fscanln(in, &s); err != nil {
		panic(err)
	}
	n := len(s)
	d := make([]int, n)
	for i := 0; i < n; i++ {
		d[i] = int(s[i] - '0')
	}
	for i := 0; i < n; i++ {
		if d[i]%2 == 0 && d[i] < d[n-1] {
			d[i], d[n-1] = d[n-1], d[i]
			for i := 0; i < n; i++ {
				fmt.Print(d[i])
			}
			fmt.Println()
			return
		}
	}
	for i := n - 1; i >= 0; i-- {
		if d[i]%2 == 0 {
			d[i], d[n-1] = d[n-1], d[i]
			for i := 0; i < n; i++ {
				fmt.Print(d[i])
			}
			fmt.Println()
			return
		}
	}
	fmt.Println(-1)
}

func main() {
	contest(os.Stdin)
}

package main

import (
	"fmt"
)

func main() {
	var S string
	fmt.Scan(&S)
	N := len(S)
	D := make([]int, N)
	for i, r := range S {
		D[i] = int(r - '0')
	}
	odd := 1
	for _, d := range D {
		odd &= d & 1
	}
	if odd == 1 {
		fmt.Println(-1)
		return
	}
	odd = D[N-1]
	for i, d := range D {
		if (d&1) == 0 && d < odd {
			D[i], D[N-1] = odd, d
			for j := 0; j < N; j++ {
				fmt.Printf("%d", D[j])
			}
			fmt.Println()
			return
		}
	}
	for i := N - 2; i >= 0; i-- {
		d := D[i]
		if (d & 1) == 0 {
			D[i], D[N-1] = odd, d
			for j := 0; j < N; j++ {
				fmt.Printf("%d", D[j])
			}
			fmt.Println()
			return
		}
	}
	fmt.Println(-1)
}

package main

import "fmt"

func main() {
	var a string
	fmt.Scan(&a)
	l := len(a) - 1
	for i := 0; i < len(a); i++ {
		if ((a[i]-'0')%2 == 0) && (a[i] < a[l]) {
			for j := 0; j < len(a)-1; j++ {
				if j == i {
					fmt.Printf("%c", a[l])
				} else {
					fmt.Printf("%c", a[j])
				}
			}
			fmt.Printf("%c\n", a[i])
			return
		}
	}

	for i := len(a) - 2; i >= 0; i-- {
		if (a[i]-'0')%2 == 0 {
			for j := 0; j < len(a)-1; j++ {
				if j == i {
					fmt.Printf("%c", a[l])
				} else {
					fmt.Printf("%c", a[j])
				}
			}
			fmt.Printf("%c\n", a[i])
			return
		}
	}

	fmt.Println(-1)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"io/ioutil"
)

var scanner = bufio.NewScanner(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	// reader := bufio.NewReader(os.Stdin)
	// s, _ := reader.ReadBytes('\n')
	// s = s[:len(s)-1]

	s, _ := ioutil.ReadAll(os.Stdin)
	println(s)
	s = s[:len(s)-1]
	println(s)

	// // t := ""
	// // fmt.Scan(&t)
	// // s := []uint8(t)
	// n := len(s)
	// lastI := -1

	// for i := 0; i < n; i++ {
	// 	if ((s[i] - '0') % 2 == 0) {
	// 		if (s[i] < s[n-1]) {
	// 			lastI = i
	// 			break
	// 		} else {
	// 			if lastI == -1 {
	// 				lastI = i
	// 			} else {
	// 				if s[lastI] > s[i] {
	// 					lastI = i
	// 				}
	// 			}
	// 		}
	// 	}
	// }

	// if lastI != -1 {
	// 	s[lastI], s[n-1] = s[n-1], s[lastI]
	// 	println(string(s))
	// } else {
	// 	println(-1)
	// }

}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"io/ioutil"
)

var scanner = bufio.NewScanner(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	// reader := bufio.NewReader(os.Stdin)
	// s, _ := reader.ReadBytes('\n')
	// s = s[:len(s)-1]

	s, _ := ioutil.ReadAll(os.Stdin)
	s = s[:len(s)-1]

	// t := ""
	// fmt.Scan(&t)
	// s := []uint8(t)
	n := len(s)
	lastI := -1

	for i := 0; i < n; i++ {
		if ((s[i] - '0') % 2 == 0) {
			if (s[i] < s[n-1]) {
				lastI = i
				break
			} else {
				if lastI == -1 {
					lastI = i
				} else {
					if s[lastI] > s[i] {
						lastI = i
					}
				}
			}
		}
	}

	if lastI != -1 {
		s[lastI], s[n-1] = s[n-1], s[lastI]
		println(string(s))
	} else {
		println(-1)
	}

}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	// "io/ioutil"
	"bytes"
)

var reader = bufio.NewReader(os.Stdin)
var scanner = bufio.NewScanner(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	// reader := bufio.NewReader(os.Stdin)
	// s, _ := reader.ReadBytes('\n')
	// s = s[:len(s)-1]

	s, _ := reader.ReadBytes('\n')
	// s, _ := ioutil.ReadAll(os.Stdin)
	s = bytes.TrimSpace(s)
	n := len(s)
	lastI := -1

	for i := 0; i < n; i++ {
		if ((s[i] - '0') % 2 == 0) {
			if (s[i] < s[n-1]) {
				lastI = i
				break
			} else {
				if lastI == -1 {
					lastI = i
				} else {
					if s[lastI] > s[i] {
						lastI = i
					}
				}
			}
		}
	}

	if lastI != -1 {
		s[lastI], s[n-1] = s[n-1], s[lastI]
		println(string(s))
	} else {
		println(-1)
	}

}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"io/ioutil"
	"bytes"
)

var scanner = bufio.NewScanner(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	// reader := bufio.NewReader(os.Stdin)
	// s, _ := reader.ReadBytes('\n')
	// s = s[:len(s)-1]

	s, _ := ioutil.ReadAll(os.Stdin)
	println(s)
	s = bytes.TrimSpace(s)
	println(s)
	// // t := ""
	// // fmt.Scan(&t)
	// // s := []uint8(t)
	// n := len(s)
	// lastI := -1

	// for i := 0; i < n; i++ {
	// 	if ((s[i] - '0') % 2 == 0) {
	// 		if (s[i] < s[n-1]) {
	// 			lastI = i
	// 			break
	// 		} else {
	// 			if lastI == -1 {
	// 				lastI = i
	// 			} else {
	// 				if s[lastI] > s[i] {
	// 					lastI = i
	// 				}
	// 			}
	// 		}
	// 	}
	// }

	// if lastI != -1 {
	// 	s[lastI], s[n-1] = s[n-1], s[lastI]
	// 	println(string(s))
	// } else {
	// 	println(-1)
	// }

}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	// reader := bufio.NewReader(os.Stdin)
	// s, _ := reader.ReadBytes('\n')
	t := ""
	fmt.Scan(&t)
	s := []uint8(t)
	n := len(s)
	lastI := -1

	for i := 0; i < n; i++ {
		if ((s[i] - '0') % 2 == 0) {
			if (s[i] < s[n-1]) {
				lastI = i
				break
			} else {
				if lastI == -1 {
					lastI = i
				} else {
					if s[lastI] > s[i] {
						lastI = i
					}
				}
			}
		}
	}

	if lastI != -1 {
		s[lastI], s[n-1] = s[n-1], s[lastI]
		println(string(s))
	} else {
		println(-1)
	}

}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	reader := bufio.NewReader(os.Stdin)

	s, _ := reader.ReadBytes('\n')
	n := len(s)
	// fmt.Scan(&t)
	// s := []uint8(t)
	lastI := -1

	for i := 0; i < n; i++ {
		if ((s[i] - '0') % 2 == 0) {
			if (s[i] < s[n-1]) {
				lastI = i
				break
			} else {
				if lastI == -1 {
					lastI = i
				} else {
					if s[lastI] > s[i] {
						lastI = i
					}
				}
			}
		}
	}

	if lastI != -1 {
		s[lastI], s[n-1] = s[n-1], s[lastI]
		println(string(s))
	} else {
		println(-1)
	}

}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"io/ioutil"
)

var scanner = bufio.NewScanner(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	s, _ := ioutil.ReadAll(os.Stdin)
	n := len(s)
	i := 0

	for ; i < n; i++ {
		if ((s[i] - '0') % 2 == 0) {
			break
		}
	}

	if i != n {
		s[i], s[n-1] = s[n-1], s[i]
		println(string(s))
	} else {
		println(-1)
	}

}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	reader := bufio.NewReader(os.Stdin)
	s, _ := reader.ReadBytes('\n')
	s = s[:len(s)-1]
	// t := ""
	// fmt.Scan(&t)
	// s := []uint8(t)
	n := len(s)
	lastI := -1
	// lastT := ""

	for i := 0; i < n; i++ {
		if ((s[i] - '0') % 2 == 0) {
			if (s[i] < s[n-1]) {
				lastI = i
				break
			} else {
				if lastI == -1 {
					lastI = i
				} else {
					if s[lastI] > s[i] {
						lastI = i
					}
				}
			}

			// s[i], s[n-1] = s[n-1], s[i]
			// t = string(s)

			// if lastT == "" {
			// 	lastT = t
			// } else if t > lastT {
			// 	lastT = t
			// }

			// s[i], s[n-1] = s[n-1], s[i]
		}
	}

	if lastI != -1 {
		s[lastI], s[n-1] = s[n-1], s[lastI]
		println(string(s))
	} else {
		println(-1)
	}

	// if lastT == "" {
	// 	println(-1)
	// } else {
	// 	println(lastT)
	// }

}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	// "io/ioutil"
)

var scanner = bufio.NewScanner(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	t := ""
	fmt.Scan(&t)
	s := []uint8(t)
	// s, _ := ioutil.ReadAll(os.Stdin)
	// println(t)
	n := len(s)
	i := 0

	for ; i < n; i++ {
		if ((s[i] - '0') % 2 == 0) {
			break
		}
	}

	if i != n {
		s[i], s[n-1] = s[n-1], s[i]
		println(string(s))
	} else {
		println(-1)
	}

}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"io/ioutil"
	"bytes"
)

var scanner = bufio.NewScanner(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	// reader := bufio.NewReader(os.Stdin)
	// s, _ := reader.ReadBytes('\n')
	// s = s[:len(s)-1]

	s, _ := ioutil.ReadAll(os.Stdin)
	s = bytes.TrimSpace(s)
	n := len(s)
	lastI := -1

	for i := 0; i < n; i++ {
		if ((s[i] - '0') % 2 == 0) {
			if (s[i] < s[n-1]) {
				lastI = i
				break
			} else {
				if lastI == -1 {
					lastI = i
				} else {
					if s[lastI] > s[i] {
						lastI = i
					}
				}
			}
		}
	}

	if lastI != -1 {
		s[lastI], s[n-1] = s[n-1], s[lastI]
		println(string(s))
	} else {
		println(-1)
	}

}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

package main

import (
  "os"
  "bufio"
  "strings"
)

func cToI(c byte) int {
  return int(c - '0')
}

func main() {
  reader := bufio.NewReader(os.Stdin)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  line, _ := reader.ReadString('\n')
  bytes := []byte(strings.TrimSpace(line))
  n := len(bytes)
  last := cToI(bytes[n-1])
  for i := 0; i < n; i++ {
    current := cToI(bytes[i])
    if current%2 == 0 && current > last {
      bytes[i], bytes[n-1] = bytes[n-1], bytes[i]
      writer.Write(bytes)
      writer.WriteString("\n")
      return
    }
  }
  for i := n-2; i >= 0; i-- {
    current := cToI(bytes[i])
    if current%2 == 0 {
      bytes[i], bytes[n-1] = bytes[n-1], bytes[i]
      writer.Write(bytes)
      writer.WriteString("\n")
      return
    }
  }

  writer.WriteString("-1\n")
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	if str, err := reader.ReadString('\n'); err != nil {
		if err != io.EOF {
			return
		}
	} else {
		var n int
		for n = 0; str[n] != '\n' && str[n] != '\r'; n++ {
		}

		s := make([]byte, n)

		var last_digit byte = str[n-1] - '0'
		var last_even_idx int = -1
		var swapped_idx int = -1

		for i := 0; i < n-1; i++ {
			s[i] = str[i] - '0'
			if s[i]%2 == 0 {
				last_even_idx = i
				if s[i] < last_digit && swapped_idx < 0 {
					s[n-1] = s[i]
					s[i] = last_digit
					swapped_idx = i
				}
			}
		}
		if swapped_idx < 0 {
			if last_even_idx < 0 {
				fmt.Println("-1")
				return
			} else {
				s[n-1] = s[last_even_idx]
				s[last_even_idx] = last_digit
			}
		}
		for i := 0; i < n; i++ {
			fmt.Printf("%d\n", s[i])
		}
		fmt.Println()
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	if str, err := reader.ReadString('\n'); err != nil {
		if err != io.EOF {
			return
		}
	} else {
		var n int
		for n = 0; str[n] != '\n'; n++ {
		}

		s := make([]byte, n)

		var last_digit byte = str[n-1] - '0'
		var last_even_idx int = -1
		var swapped_idx int = -1

		for i := 0; i < n-1; i++ {
			s[i] = str[i] - '0'
			if s[i]%2 == 0 {
				last_even_idx = i
				if s[i] < last_digit && swapped_idx < 0 {
					s[n-1] = s[i]
					s[i] = last_digit
					swapped_idx = i
				}
			}
		}
		if swapped_idx < 0 {
			if last_even_idx < 0 {
				fmt.Println("-1")
				return
			} else {
				s[n-1] = s[last_even_idx]
				s[last_even_idx] = last_digit
			}
		}
		for i := 0; i < n; i++ {
			fmt.Printf("%d\n", s[i])
		}
		fmt.Println()
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	if str, err := reader.ReadString('\n'); err != nil {
		if err != io.EOF {
			return
		}
	} else {
		var n int
		for n = 0; str[n] != '\n'; n++ {
		}

		s := make([]byte, n)

		var last_digit byte = str[n-1] - '0'
		var last_even_idx int = -1
		var swapped_idx int = -1

		for i := 0; i < n-1; i++ {
			s[i] = str[i] - '0'
			if s[i]%2 == 0 {
				last_even_idx = i
				if s[i] < last_digit && swapped_idx < 0 {
					s[n-1] = s[i]
					s[i] = last_digit
					swapped_idx = i
				}
			}
		}
		if swapped_idx < 0 {
			if last_even_idx < 0 {
				fmt.Println("-1")
				return
			} else {
				s[n-1] = s[last_even_idx]
				s[last_even_idx] = last_digit
			}
		}
		for i := 0; i < n; i++ {
			fmt.Printf("%d", s[i])
		}
		fmt.Println()
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	if str, err := reader.ReadString('\n'); err != nil {
		if err != io.EOF {
			return
		}
	} else {
		n := len(str) - 1
		if str[len(str)-1] == '\r' {
			n -= 1
		}
		s := make([]byte, n)
		copy(s, str[0:n])

		var last_digit byte = s[n-1]
		var last_even_idx int = -1
		var swapped_idx int = -1

		for i := 0; i < n-1; i++ {
			if (s[i]-'0')%2 == 0 {
				last_even_idx = i
				if s[i] < last_digit && swapped_idx < 0 {
					s[n-1] = s[i]
					s[i] = last_digit
					swapped_idx = i
				}
			}
		}
		if swapped_idx < 0 {
			if last_even_idx < 0 {
				fmt.Println("-1")
				return
			} else {
				s[n-1] = s[last_even_idx]
				s[last_even_idx] = last_digit
			}
		}
		fmt.Printf("%s\n", s)
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	if str, err := reader.ReadString('\n'); err != nil {
		if err != io.EOF {
			return
		}
	} else {
		var n int
		for n = 0; str[n] != '\n'; n++ {
		}

		s := make([]byte, n)
		copy(s, str[0:n])

		var last_digit byte = s[n-1]
		var last_even_idx int = -1
		var swapped_idx int = -1

		for i := 0; i < n-1; i++ {
			if (s[i]-'0')%2 == 0 {
				last_even_idx = i
				if s[i] < last_digit && swapped_idx < 0 {
					s[n-1] = s[i]
					s[i] = last_digit
					swapped_idx = i
				}
			}
		}
		if swapped_idx < 0 {
			if last_even_idx < 0 {
				fmt.Println("-1")
				return
			} else {
				s[n-1] = s[last_even_idx]
				s[last_even_idx] = last_digit
			}
		}
		fmt.Printf("%s\n", s)
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	if str, err := reader.ReadString('\n'); err != nil {
		if err != io.EOF {
			return
		}
	} else {
		n := len(str) - 1
		s := make([]byte, n)
		copy(s, str[0:n])

		var last_digit byte = s[n-1]
		var last_even_idx int = -1
		var swapped_idx int = -1

		for i := 0; i < n-1; i++ {
			if (s[i]-'0')%2 == 0 {
				last_even_idx = i
				if s[i] < last_digit && swapped_idx < 0 {
					s[n-1] = s[i]
					s[i] = last_digit
					swapped_idx = i
				}
			}
		}
		if swapped_idx < 0 {
			if last_even_idx < 0 {
				fmt.Println("-1")
				return
			} else {
				s[n-1] = s[last_even_idx]
				s[last_even_idx] = last_digit
			}
		}
		fmt.Printf("%s\n", s)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	n      string
	result string
)

func in() {
	read(&n)
}

func out() {
	println(result)
	defer output.Flush()
}

func run() {
	arr := []byte(n)
	l := len(arr)
	last := arr[l-1]
	switched := false
	for i := 0; i < l-1; i++ {
		if arr[i]%2 == 0 && arr[i] < last {
			arr[i], arr[l-1] = arr[l-1], arr[i]
			switched = true
		}
	}

	if !switched {
		max := byte(0)
		max_i := -1
		for i := 0; i < l-1; i++ {
			if arr[i]%2 == 0 && arr[i] >= max {
				max, max_i = arr[i], i
			}
		}
		if max_i >= 0 {
			arr[max_i], arr[l-1] = arr[l-1], arr[max_i]
			switched = true
		}
	}
	if switched {
		result = string(arr)
	} else {
		result = "-1"
	}
}

/** main **/
func main() {
	in()
	run()
	out()
}

// Input & Output
var (
	input  = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

func read(a ...interface{}) {
	_, err := fmt.Fscan(input, a...)
	if err != nil {
		println(err)
	}
}

func println(a ...interface{}) {
	fmt.Fprintln(output, a...)
}

func printf(format string, a ...interface{}) {
	fmt.Fprintf(output, format, a...)
}

package main

import (
	"fmt"
)

func main() {
	var S string
	fmt.Scan(&S)
	N := len(S)
	D := make([]int, N)
	for i, r := range S {
		D[i] = int(r - '0')
	}
	odd := 1
	for _, d := range D {
		odd &= d & 1
	}
	if odd == 1 {
		fmt.Println(-1)
		return
	}
	odd = D[N-1]
	for i, d := range D {
		if (d&1) == 0 && d < odd {
			D[i], D[N-1] = odd, d
			for j := 0; j < N; j++ {
				fmt.Printf("%d", D[j])
			}
			fmt.Println()
			return
		}
	}
	for i := N - 2; i >= 0; i-- {
		d := D[i]
		if (d & 1) == 0 {
			D[i], D[N-1] = odd, d
			for j := 0; j < N; j++ {
				fmt.Printf("%d", D[j])
			}
			fmt.Println()
		}
	}
}