题干:

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 oddpositive 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 105, 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

题目大意:

给出一个长度小于10^5的奇数,交换其中两位,使其变成一个偶数,若有多种做法输出交换后数字最大的。若不能构造出一个偶数,输出-1。

解题报告:

  直接贪心,如果没有偶数就输出-1,否则肯定有解。如果有大于s[len]的偶数那就从前面往后找第一个(因为越靠前越好),否则就从后面往前面找第一个,交换就完事了。

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define ll long long
#define pb push_back
#define pm make_pair
#define fi first
#define se second
using namespace std;
const int MAX = 2e5 + 5;
char s[MAX];
int main()
{
	cin>>(s+1);
	int len = strlen(s+1);
	int flag = 0,ok=0;
	int tar = s[len]-'0';
	for(int i = 1; i<=len; i++) {
		if((s[i]-'0')%2==0) flag = 1;
	}
	if(flag == 0) {
		puts("-1");return 0 ;
	}
	for(int i = 1; i<=len; i++) {
		int cur = s[i]-'0';
		if(cur%2==0 && tar > cur) {
			swap(s[i],s[len]);ok=1;break;
		}
	}
	if(ok==1) {
		printf("%s",s+1);return 0 ;
	}
	for(int i = len; i>=1; i--) {
		int cur = s[i]-'0';
		if(cur%2==0 /*&& tar<cur*/) {
			swap(s[i],s[len]);break;
		}
	}
	printf("%s",s+1);
	return 0 ;
 }