#include<bits/stdc++.h>
using namespace std;
using ui=unsigned int;
using ll=long long;
using ull=unsigned long long;
using i128=__int128_t;
using u128=__uint128_t;
using ld=long double;
int dep(int x)
{
int temp=x,k=0;
while(temp>0)
{
int t=temp%10;
if(t%2==0)
{
int a=x%10;
return x-t*pow(10,k)+a*pow(10,k)-a+t;//构造新的x
}
temp/=10;
k++;
}
return -1;
}
void solve()
{//分类讨论 当x为偶数时 直接输出 当x为奇数时 进行进一步处理
//如果x为奇数 将x的从小到大每一位数字拆出 如果拆出了偶数 那么我们直接让这个数字和x的最后一位数字交换 然后返回x即可 如果没找到偶数 返回-1
//具体怎么交换数字详见函数dep
int q,x;
cin >> q;
while(q--)
{
cin >> x;
if(x%2==0) cout << x << "\n";
else
{
cout << dep(x) << "\n";
}
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t=1;
//cin >> t;
while(t--)
{
solve();
}
return 0;
}