#include <bits/stdc++.h>

#define ll long long

#define endl '\n'

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        string s;
        cin>>s;
        ll sum=0;
        for(int i=0; i<n; ++i)
        {
            sum+=(s[i]-'0');
        }
        if(n==1&&s[0]=='0')
        {
            cout<<-1<<endl;
        }
        else
        {
            int j=n-1;
            while((s[j]-'0')%2==0&&j>=0)
            {
                s.erase(j,1);
                j--;
            }
            if(sum%2!=0)
            {
                bool f=0;
                for(int i=0; i<n; ++i)
                {
                    if((s[i]-'0')%2!=0)
                    {
                        s.erase(i,1);
                        f=1;
                        break;
                    }
                }
                int j=n-1;
                while((s[j]-'0')%2==0&&j>=0)
                {
                    s.erase(j,1);
                    j--;
                }
                while(s[0]=='0'&&s.size()>0)
                {
                    s.erase(0,1);
                }
                f=(s.size()>0);
                if(!f)
                {
                    cout<<-1<<endl;
                }
                else
                {
                    cout<<s<<endl;
                }
            }
            else
            {
                bool f1=0;
                while(s[0]=='0'&&s.size()>0)
                {
                    s.erase(0,1);
                }
                f1=(s.size()>0);
                if(!f1)
                {
                    cout<<-1<<endl;
                }
                else
                {
                    cout<<s<<endl;
                }
            }
        }
    }
}


#include <bits/stdc++.h>

#define ll long long

#define endl '\n'

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        string s;
        cin>>s;
        ll sum=0;
        for(int i=0; i<n; ++i)
        {
            sum+=(s[i]-'0');
        }
        if(n==1&&s[0]=='0')
        {
            cout<<-1<<endl;
        }
        else
        {
            int j=s.size()-1;
            while((s[j]-'0')%2==0&&j>=0)
            {
                s.erase(j,1);
                j--;
            }
            if(sum%2!=0)
            {
                bool f=0;
                for(int i=0; i<n; ++i)
                {
                    if((s[i]-'0')%2!=0)
                    {
                        s.erase(i,1);
                        f=1;
                        break;
                    }
                }
                int j=s.size()-1;
                while((s[j]-'0')%2==0&&j>=0)
                {
                    s.erase(j,1);
                    j--;
                }
                while(s[0]=='0'&&s.size()>0)
                {
                    s.erase(0,1);
                }
                f=(s.size()>0);
                if(!f)
                {
                    cout<<-1<<endl;
                }
                else
                {
                    cout<<s<<endl;
                }
            }
            else
            {
                bool f1=0;
                while(s[0]=='0'&&s.size()>0)
                {
                    s.erase(0,1);
                }
                f1=(s.size()>0);
                if(!f1)
                {
                    cout<<-1<<endl;
                }
                else
                {
                    cout<<s<<endl;
                }
            }
        }
    }
}


#include <bits/stdc++.h>

#define ll long long

#define endl '\n'

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        string s;
        cin>>s;
        ll sum=0;
        for(int i=0; i<n; ++i)
        {
            sum+=(s[i]-'0');
        }
        if(n==1&&s[0]=='0')
        {
            cout<<-1<<endl;
        }
        else
        {
            int j=n-1;
            while((s[j]-'0')%2==0&&j>=0)
            {
                s.erase(j,1);
                j--;
            }
            if(sum%2!=0)
            {
                bool f=0;
                for(int i=0;i<n;++i)
                {
                    if((s[i]-'0')%2!=0){s.erase(i,1);f=1;break;}
                }
                while(s[0]=='0'&&s.size()>0)
                {
                    s.erase(0,1);
                }
                f=(s.size()>0);
                if(!f){cout<<-1<<endl;}
                else {cout<<s<<endl;}
            }
            else
            {
                bool f1=0;
                while(s[0]=='0'&&s.size()>0)
                {
                    s.erase(0,1);
                }
                f1=(s.size()>0);
                if(!f1){cout<<-1<<endl;}
                else {cout<<s<<endl;}
            }
        }
    }
}


#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        string s;
        cin>>s;
        ll sum=0;
        for(int i=0; i<n; ++i)
        {
            sum+=int(s[i]-'0');
        }
        if(n==1&&s[0]==0)
        {
            cout<<-1<<endl;
        }
        else
        {
            while(s[s.size()-1]%2==0&&s.size()>0)
            {
                s.erase(s.size()-1,1);
            }
            if(sum%2!=0)
            {
                bool f=0;
                for(int i=0;i<n;++i)
                {
                    if((s[i]-'0')%2!=0){s.erase(i,1);f=1;break;}
                }
                while(s[0]=='0'&&s.size()>0)
                {
                    s.erase(0,1);
                }
                f=(s.size()>0);
                if(!f){cout<<-1<<endl;}
                else {cout<<s<<endl;}
            }
            else
            {
                bool f1=0;
                while(s[0]=='0'&&s.size()>0)
                {
                    s.erase(0,1);
                }
                f1=(s.size()>0);
                if(!f1){cout<<-1<<endl;}
                else {cout<<s<<endl;}
            }
        }
    }
}


#include <bits/stdc++.h>

#define ll long long

#define endl '\n'

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        string s;
        cin>>s;
        ll sum=0;
        for(int i=0; i<n; ++i)
        {
            sum+=(s[i]-'0');
        }
        if(n==1&&s[0]=='0')
        {
            cout<<-1<<endl;
        }
        else
        {
            int j=n-1;
            while((s[j]-'0')%2==0&&j>0)
            {
                s.erase(j,1);
                j--;
            }
            if(sum%2!=0)
            {
                bool f=0;
                for(int i=0;i<n;++i)
                {
                    if((s[i]-'0')%2!=0){s.erase(i,1);f=1;break;}
                }
                while(s[0]=='0'&&s.size()>0)
                {
                    s.erase(0,1);
                }
                f=(s.size()>0);
                if(!f){cout<<-1<<endl;}
                else {cout<<s<<endl;}
            }
            else
            {
                bool f1=0;
                while(s[0]=='0'&&s.size()>0)
                {
                    s.erase(0,1);
                }
                f1=(s.size()>0);
                if(!f1){cout<<-1<<endl;}
                else {cout<<s<<endl;}
            }
        }
    }
}


#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        string s;
        cin>>s;
        ll h=0;
        for(int i=0;i<n;++i)
        {
            h+=(s[i]-'0');
        }
        bool f=0;
        if(n==1&&s[0]=='0'){cout<<-1<<endl;}
        else if((s[n-1]-'0')%2!=0)
        {
            if(h%2==0)
            {
                cout<<s<<endl;
                f=1;
            }
            else
            {
                for(int i=0;i<n;++i)
                {
                    if((s[i]-'0')%2!=0){s.erase(i,1);f=1;break;}
                }
                while(s[0]=='0')
                {
                    s.erase(0,1);
                }
                if(!f){cout<<-1<<endl;}
                else cout<<s<<endl;
            }
        }
        else
        {
            f=0;
            int j=n-1;
            while((s[j]-'0')%2==0)
            {
                s.erase(j,1);
                --j;
            }
            if(s.size()==0){f=0;cout<<-1<<endl;}
            else cout<<s<<endl;
        }
    }
}


#include<bits/stdc++.h>
const int N=100005;
int t,n,s,o[N],cnt;
char a[N];
int main()
{
    cin>>t;
    register int i;
    while(t--)
	{
        scanf("%d%s",&n,a+1),cnt=0;
        for(i=1;cnt<2&&i<=n;++i)
            if((a[i]-'0')&1) o[++cnt]=i;
        if(cnt<2) puts("-1");
        else printf("%c%c\n",a[o[1]],a[o[2]]);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int t,n;
string a;
int main()
{
	cin>>t;
	while(t--)
	{
		cin>>n;
		cin>>a;
		int sum=0;
		for(int i=0;i<=n-1;i++)
		{
			sum+=a[i];
		}
		if(sum%2==0&&a[n-1]%2==1)
		{
			cout<<a<<endl;
		}
		else if(sum%2==0&&a[n-1]%2==0)
		{
			int record=n;
			for(int i=n-2;i>=0;i--)
			{
				if(a[i]%2==1)
				{
					record=i;
					break;
				}
			}
			if(record==n)
			{
				cout<<"-1"<<endl;
			}
			else if(record!=n)
			{
				for(int i=0;i<=record;i++)
				{
					if(a[i]!=0)
					{
						cout<<a[i];
					}
				}
				cout<<endl;
			}
		}
		else if(sum%2==1)
		{
			if(a[n-1]%2==1)
			{
				int record=n;
				for(int i=n-2;i>=0;i--)
				{
					if(a[i]%2==1)
					{
						record=i;
						break;
					}
				}
				if(record==n)
				{
					cout<<"-1"<<endl;
				}
				else if(record!=n)
				{
					for(int i=0;i<=n-1;i++)
					{
						if(i!=record&&a[i]!=0)
						{
							cout<<a[i];
						}
					}
					cout<<endl;
				}
			}
			else if(a[n-1]%2==0)
			{
				int record1=n;
				int record2=n;
				for(int i=n-2;i>=0;i--)
				{
					if(a[i]%2==1)
					{
						record1=i;
						break;
					}
				}
				if(record1==n)
				{
					cout<<"-1"<<endl;
				}
				else if(record1!=n)
				{
					for(int i=record1-1;i>=0;i++)
					{
						if(a[i]%2==1)
						{
							record2=i;
							break;
						}
					}
					if(record2==n)
					{
						cout<<"-1"<<endl;
					}
					else if(record2!=n)
					{
						for(int i=0;i<=record1;i++)
						{
							if(i!=record2&&a[i]!=0)
							{
								cout<<a[i];
							}
						}
						cout<<endl;
					}
				}
			}
		}
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int t,n;
string a;
int main()
{
	cin>>t;
	while(t--)
	{
		cin>>n;
		cin>>a;
		int sum=0;
		for(int i=0;i<=n-1;i++)
		{
			sum+=a[i];
		}
		if(sum%2==0&&a[n-1]%2==1)
		{
			cout<<a<<endl;
		}
		else if(sum%2==0&&a[n-1]%2==0)
		{
			int record=n;
			for(int i=n-2;i>=0;i--)
			{
				if(a[i]%2==1)
				{
					record=i;
					break;
				}
			}
			if(record==n)
			{
				cout<<"-1"<<endl;
			}
			else if(record!=n)
			{
				for(int i=0;i<=record;i++)
				{
					if(a[i]!=0)
					{
						cout<<a[i];
					}
				}
				cout<<endl;
			}
		}
		else if(sum%2==1)
		{
			if(a[n-1]%2==1)
			{
				int record=n;
				for(int i=n-2;i>=0;i--)
				{
					if(a[i]%2==1)
					{
						record=i;
						break;
					}
				}
				if(record==n)
				{
					cout<<"-1"<<endl;
				}
				else if(record!=n)
				{
					for(int i=0;i<=n-1;i++)
					{
						if(i!=record&&a[i]!=0)
						{
							cout<<a[i];
						}
					}
					cout<<endl;
				}
			}
			else if(a[n-1]%2==0)
			{
				int record1=n;
				int record2=n;
				for(int i=n-2;i>=0;i--)
				{
					if(a[i]%2==1)
					{
						record1=i;
						break;
					}
				}
				if(record1==n)
				{
					cout<<"-1"<<endl;
				}
				else if(record1!=n)
				{
					for(int i=record1-1;i>=0;i++)
					{
						if(a[i]%2==1)
						{
							record2=i;
							break;
						}
					}
					if(record2==n)
					{
						cout<<"-1"<<endl;
					}
					else if(record2!=n)
					{
						for(int i=0;i<=record1;i++)
						{
							if(i!=record2&&a[i]!=0)
							{
								cout<<a[i];
							}
							else
							{
								continue;
							}
						}
						cout<<endl;
					}
				}
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int t,n;
string a;
int main()
{
	cin>>t;
	while(t--)
	{
		cin>>n;
		cin>>a;
		int sum=0;
		for(int i=0;i<=n-1;i++)
		{
			sum+=a[i];
		}
		if(sum%2==0&&a[n-1]%2==1)
		{
			cout<<a<<endl;
		}
		else if(sum%2==0&&a[n-1]%2==0)
		{
			int record=n;
			for(int i=n-2;i>=0;i--)
			{
				if(a[i]%2==1)
				{
					record=i;
					break;
				}
			}
			if(record==n)
			{
				cout<<"-1"<<endl;
			}
			else if(record!=n)
			{
				for(int i=0;i<=record;i++)
				{
					if(a[i]!=0)
					{
						cout<<a[i];
					}
				}
				cout<<endl;
			}
		}
		else if(sum%2==1)
		{
			if(a[n-1]%2==1)
			{
				int record=n;
				for(int i=n-2;i>=0;i--)
				{
					if(a[i]%2==1)
					{
						record=i;
						break;
					}
				}
				if(record==n)
				{
					cout<<"-1"<<endl;
				}
				else if(record!=n)
				{
					for(int i=0;i<=n-1;i++)
					{
						if(i!=record&&a[i]!=0)
						{
							cout<<a[i];
						}
					}
					cout<<endl;
				}
			}
			else if(a[n-1]%2==0)
			{
				int record1=n;
				int record2=n;
				for(int i=n-2;i>=0;i--)
				{
					if(a[i]%2==1)
					{
						record1=i;
						break;
					}
				}
				if(record1==n)
				{
					cout<<"-1"<<endl;
				}
				else if(record1!=n)
				{
					if(record1==0)
					{
						cout<<"-1"<<endl;
					}
					else if(record1!=0)
					{
					for(int i=record1-1;i>=0;i++)
					{
						if(a[i]%2==1)
						{
							record2=i;
							break;
						}
					}
					if(record2==n)
					{
						cout<<"-1"<<endl;
					}
					else if(record2!=n)
					{
						for(int i=0;i<=record1;i++)
						{
							if(i!=record2&&a[i]!=0)
							{
								cout<<a[i];
							}
						}
						cout<<endl;
					}
				}
				}
			}
		}
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int t,n;
string a;
int main()
{
	cin>>t;
	while(t--)
	{
		cin>>n;
		cin>>a;
		int sum=0;
		for(int i=0;i<=n-1;i++)
		{
			sum+=a[i];
		}
		if(sum%2==0&&a[n-1]%2==1)
		{
			cout<<a<<endl;
		}
		else if(sum%2==0)
		{
			int record=n;
			for(int i=n-1;i>=0;i--)
			{
				if(a[i]%2==1)
				{
					record=i;
					break;
				}
			}
			if(record==n)
			{
				cout<<"-1"<<endl;
			}
			if(record!=n)
			{
				for(int i=0;i<=record;i++)
				{
					cout<<a[i];
				}
				cout<<endl;
			}
		}
		else if(sum%2==1)
		{
			if(a[n-1]%2==1)
			{
				int record=n;
				for(int i=n-2;i>=0;i--)
				{
					if(a[i]%2==1)
					{
						record=i;
						break;
					}
				}
				if(record==n)
				{
					cout<<"-1"<<endl;
				}
				else if(record!=n)
				{
					for(int i=0;i<=n-1;i++)
					{
						if(i!=record)
						{
							cout<<a[i];
						}
					}
					cout<<endl;
				}
			}
			else if(a[n-1]%2==0)
			{
				int record1=n,record2=n;
				for(int i=n-2;i>=0;i--)
				{
					if(a[i]%2==1)
					{
						record1=i;
						break;
					}
				}
				if(record1==n)
				{
					cout<<"-1"<<endl;
				}
				else if(record1!=n)
				{
					for(int i=record1-1;i>=0;i++)
					{
						if(a[i]%2==1)
						{
							record2=i;
							break;
						}
					}
					if(record2==n)
					{
						cout<<"-1"<<endl;
					}
					else if(record2!=n)
					{
						for(int i=0;i<=record1;i++)
						{
							if(i!=record2)
							{
								cout<<a[i];
							}
						}
						cout<<endl;
					}
				}
			}
		}
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int t,n,s,o[N],cnt;
char a[N];
int main()
{
    cin>>t;
    register int i;
    while(t--)
	{
        scanf("%d%s",&n,a+1),cnt=0;
        for(i=1;cnt<2&&i<=n;++i)
            if((a[i]-'0')&1) o[++cnt]=i;
        if(cnt<2) puts("-1");
        else printf("%c%c\n",a[o[1]],a[o[2]]);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int t,n;
string a;
int main()
{
	cin>>t;
	while(t--)
	{
		cin>>n;
		cin>>a;
		int sum=0;
		for(int i=0;i<=n-1;i++)
		{
			sum+=a[i];
		}
		if(sum%2==0&&a[n-1]%2==1)
		{
			cout<<a<<endl;
		}
		else if(sum%2==0&&a[n-1]%2==0)
		{
			int record=n;
			for(int i=n-2;i>=0;i--)
			{
				if(a[i]%2==1)
				{
					record=i;
					break;
				}
			}
			if(record==n)
			{
				cout<<"-1"<<endl;
			}
			else if(record!=n)
			{
				for(int i=0;i<=record;i++)
				{
					cout<<a[i];
				}
				cout<<endl;
			}
		}
		else if(sum%2==1)
		{
			if(a[n-1]%2==1)
			{
				int record=n;
				for(int i=n-2;i>=0;i--)
				{
					if(a[i]%2==1)
					{
						record=i;
						break;
					}
				}
				if(record==n)
				{
					cout<<"-1"<<endl;
				}
				else if(record!=n)
				{
					for(int i=0;i<=n-1;i++)
					{
						if(i!=record)
						{
							cout<<a[i];
						}
					}
					cout<<endl;
				}
			}
			else if(a[n-1]%2==0)
			{
				int record1=n;
				int record2=n;
				for(int i=n-2;i>=0;i--)
				{
					if(a[i]%2==1)
					{
						record1=i;
						break;
					}
				}
				if(record1==n)
				{
					cout<<"-1"<<endl;
				}
				else if(record1!=n)
				{
					for(int i=record1-1;i>=0;i++)
					{
						if(a[i]%2==1)
						{
							record2=i;
							break;
						}
					}
					if(record2==n)
					{
						cout<<"-1"<<endl;
					}
					else if(record2!=n)
					{
						for(int i=0;i<=record1;i++)
						{
							if(i!=record2)
							{
								cout<<a[i];
							}
						}
						cout<<endl;
					}
				}
			}
		}
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int t,n;
string a;
int main()
{
	cin>>t;
	while(t--)
	{
		cin>>n;
		cin>>a;
		int sum=0;
		for(int i=0;i<=n-1;i++)
		{
			sum+=a[i];
		}
		if(sum%2==0&&a[n-1]%2==1)
		{
			cout<<a<<endl;
		}
		else if(sum%2==0)
		{
			int record=n;
			for(int i=n-1;i>=0;i--)
			{
				if(a[i]%2==1)
				{
					record=i;
					break;
				}
			}
			if(record==n)
			{
				cout<<"-1"<<endl;
			}
			else if(record!=n)
			{
				for(int i=0;i<=record;i++)
				{
					cout<<a[i];
				}
				cout<<endl;
			}
		}
		else if(sum%2==1)
		{
			if(a[n-1]%2==1)
			{
				int record=n;
				for(int i=n-2;i>=0;i--)
				{
					if(a[i]%2==1)
					{
						record=i;
						break;
					}
				}
				if(record==n)
				{
					cout<<"-1"<<endl;
				}
				else if(record!=n)
				{
					for(int i=0;i<=n-1;i++)
					{
						if(i!=record)
						{
							cout<<a[i];
						}
					}
					cout<<endl;
				}
			}
			else if(a[n-1]%2==0)
			{
				int record1=n;
				int record2=n;
				for(int i=n-2;i>=0;i--)
				{
					if(a[i]%2==1)
					{
						record1=i;
						break;
					}
				}
				if(record1==n)
				{
					cout<<"-1"<<endl;
				}
				else if(record1!=n)
				{
					for(int i=record1-1;i>=0;i++)
					{
						if(a[i]%2==1)
						{
							record2=i;
							break;
						}
					}
					if(record2==n)
					{
						cout<<"-1"<<endl;
					}
					else if(record2!=n)
					{
						for(int i=0;i<=record1;i++)
						{
							if(i!=record2)
							{
								cout<<a[i];
							}
						}
						cout<<endl;
					}
				}
			}
		}
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll t,n,m,k,l,i,j;
	cin>>t;
	while(t--)
	{
		string s;
		std::vector<char>sss;
		ll sum = 0;
		cin>>n;
		cin>>s;
		l = s.size();
		ll even=0;
		ll odd=0;
		for(i=0;i<l;i++)
		{
			sum+= (s[i]-'0');
			if((s[i]-'0')%2==0)
				even++;
			else
				odd++;
		}
		if(sum%2==0 && sum!=0){
		  if((s[l-1]-'0')%2!=0)
		  {
		  	cout<<s<<endl;
		  }
		  else
		  {

		  	ll ss = sum;
		  	if(even==l)
		  		cout<<"-1"<<endl;
		  	else{
		  		ll cn = 0;
		  	for(i=l;i>=0;i--)
		  	{
              if((s[i]%2==0) && cn==0)
              {
              	continue;
              }
              else
              {
              	sss.push_back(s[i]);
              	cn=1;
              }
		  	}
		  	ll szz = sss.size();
		  	for(i=szz-1;i>0;i--)
		  	{
		  		cout<<sss[i];
		  	}
		  	cout<<sss[0]<<endl;
		  }
		  }
       }
       else if(sum%2!=0 && sum!=0)
       {
       	if(l==2 || l==1 || odd==1)
       		cout<<"-1"<<endl;
       	else
       	{
       		//cout<<l<<endl;
       		ll cnt2=0;
       		j=0;
       		for(i=l-1;i>=0;i--)
       		{
       			if((s[i]-'0')%2==0 && i==l-1)
       			{
       				continue;
       			}
       			else if((s[i]-'0')%2==0 && cnt2==0)
       			{
       				continue;
       			}
       			else{
       				sss.push_back(s[i]);
       				cnt2=2;
       			}
       		}

       		ll cnt=0;
       		ll sz = sss.size();
       		for(i=sz-1;i>=0;i--)
       			{
       				if((sss[i]-'0')%2!=0 && cnt==0)
       				{
                       cnt=1;
       				}
       				else
       					cout<<sss[i];
       			}
       			cout<<endl;
       	}
       }
       else if(sum==0)
       	cout<<"-1"<<endl;
	}

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll t,n,m,k,l,i,j;
	cin>>t;
	while(t--)
	{
		string s;
		std::vector<char>sss;
		ll sum = 0;
		cin>>n;
		cin>>s;
		l = s.size();
		ll even=0;
		ll odd=0;
		for(i=0;i<l;i++)
		{
			sum+= (s[i]-'0');
			if((s[i]-'0')%2==0)
				even++;
			else
				odd++;
		}
		if(sum%2==0 && sum!=0){
		  if((s[l-1]-'0')%2!=0)
		  {
		  	cout<<s<<endl;
		  }
		  else
		  {

		  	ll ss = sum;
		  	if(even==l)
		  		cout<<"-1"<<endl;
		  	else{
		  		ll cn = 0;
		  	for(i=l;i>=0;i--)
		  	{
              if((s[i]%2==0) && cn==0)
              {
              	continue;
              }
              else
              {
              	sss.push_back(s[i]);
              	cn=1;
              }
		  	}
		  	ll szz = sss.size();
		  	for(i=szz-1;i>0;i--)
		  	{
		  		cout<<sss[i];
		  	}
		  	cout<<sss[0]<<endl;
		  }
		  }
       }
       else if(sum%2!=0 && sum!=0)
       {
       	if(l==2 || l==1 || odd==1)
       		cout<<"-1"<<endl;
       	else
       	{
       		cout<<l<<endl;
       		ll cnt2=0;
       		j=0;
       		for(i=l-1;i>=0;i--)
       		{
       			if((s[i]-'0')%2==0 && i==l-1)
       			{
       				continue;
       			}
       			else if((s[i]-'0')%2==0 && cnt2==0)
       			{
       				continue;
       			}
       			else{
       				sss.push_back(s[i]);
       				cnt2=2;
       			}
       		}

       		ll cnt=0;
       		ll sz = sss.size();
       		for(i=sz-1;i>=0;i--)
       			{
       				if((sss[i]-'0')%2!=0 && cnt==0)
       				{
                       cnt=1;
       				}
       				else
       					cout<<sss[i];
       			}
       			cout<<endl;
       	}
       }
       else if(sum==0)
       	cout<<"-1"<<endl;
	}

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t,n;
	cin>>t;
	while(t--)
	{
		string s,v;
		cin>>n;
		cin>>s;
		int cnt = 0;
		for(int i=0;i<n;i++)
 		{
 			if((s[i]-'0')%2)
 			{
 				v.push_back(s[i]);
 				cnt++;
 			}
 			if(cnt==2)
 				break;
 		}
 		if(cnt<2)
 			cout<<"-1"<<endl;
 		else
 			cout<<v<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll t,n,m,k,l,i,j;
	cin>>t;
	while(t--)
	{
		string s;
		std::vector<char>sss;
		ll sum = 0;
		cin>>n;
		cin>>s;
		l = s.size();
		ll even=0;
		ll odd=0;
		for(i=0;i<l;i++)
		{
			sum+= (s[i]-'0');
			if((s[i]-'0')%2==0)
				even++;
			else
				odd++;
		}
		if(sum%2==0 && sum!=0){
		  if((s[l-1]-'0')%2!=0)
		  {
		  	cout<<s<<endl;
		  }
		  else
		  {

		  	ll ss = sum;
		  	if(even==l)
		  		cout<<"-1"<<endl;
		  	else{
		  		ll cn = 0;
		  	for(i=l;i>=0;i--)
		  	{
              if((s[i]%2==0) && cn==0)
              {
              	continue;
              }
              else
              {
              	sss.push_back(s[i]);
              	cn=1;
              }
		  	}
		  	ll szz = sss.size();
		  	for(i=szz-1;i>0;i--)
		  	{
		  		cout<<sss[i];
		  	}
		  	cout<<sss[0]<<endl;
		  }
		  }
       }
       else if(sum%2!=0 && sum!=0)
       {
       	if(l==2 || l==1 || odd==1)
       		cout<<"-1"<<endl;
       	else
       	{
       		//cout<<l<<endl;
       		ll cnt2=0;
       		j=0;
       		for(i=l-1;i>=0;i--)
       		{
       			if((s[i]-'0')%2==0 && i==l-1)
       			{
       				continue;
       			}
       			else if((s[i]-'0')%2==0 && cnt2==0)
       			{
       				continue;
       			}
       			else{
       				sss.push_back(s[i]);
       				cnt2=2;
       			}
       		}

       		ll cnt=0;
       		ll sz = sss.size();
       		for(i=sz-1;i>=0;i--)
       			{
       				if((sss[i]-'0')%2!=0 && cnt==0 && (sss[i-1]-'0')!=0)
       				{
                       cnt=1;
       				}
       				else
       					cout<<sss[i];
       			}
       			cout<<endl;
       	}
       }
       else if(sum==0)
       	cout<<"-1"<<endl;
	}

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t,n;
	cin>>t;
	while(t--)
	{
		string s,v;
		cin>>n;
		cin>>s;
		int cnt = 0;
		for(int i=0;i<n;i++)
 		{
 			if(s[i]-'0'%2)
 			{
 				v.push_back(s[i]);
 				cnt++;
 			}
 			if(cnt==2)
 				break;
 		}
 		if(cnt<2)
 			cout<<"-1"<<endl;
 		else
 			cout<<v<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t,n;
	cin>>t;
	while(t--)
	{
		string s;
		vector<char>v;
		cin>>n;
		cin>>s;
		int cnt = 0;
		for(i=0;i<n;i++)
 		{
 			if(s[i]-'0'%2)
 			{
 				v.push_back(s[i]);
 				cnt++;
 			}
 			if(cnt==2)
 				break;
 		}
 		if(cnt<2)
 			cout<<"-1"<<endl;
 		else
 			cout<<v<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll t,n,m,k,l,i,j;
	cin>>t;
	while(t--)
	{
		string s;
		std::vector<char>sss;
		ll sum = 0;
		cin>>n;
		cin>>s;
		l = s.size();
		ll even=0;
		ll odd=0;
		for(i=0;i<l;i++)
		{
			sum+= (s[i]-'0');
			if((s[i]-'0')%2==0)
				even++;
			else
				odd++;
		}
		if(sum%2==0 && sum!=0){
		  if((s[l-1]-'0')%2!=0)
		  {
		  	cout<<s<<endl;
		  }
		  else
		  {

		  	ll ss = sum;
		  	if(even==l)
		  		cout<<"-1"<<endl;
		  	else{
		  		ll cn = 0;
		  	for(i=l;i>=0;i--)
		  	{
              if((s[i]%2==0) && cn==0)
              {
              	continue;
              }
              else
              {
              	sss.push_back(s[i]);
              	cn=1;
              }
		  	}
		  	ll szz = sss.size();
		  	for(i=szz-1;i>0;i--)
		  	{
		  		cout<<sss[i];
		  	}
		  	cout<<sss[0]<<endl;
		  }
		  }
       }
       else if(sum%2!=0 && sum!=0)
       {
       	if(l==2 || l==1 || odd==1)
       		cout<<"-1"<<endl;
       	else
       	{
       		//cout<<l<<endl;
       		ll cnt2=0;
       		j=0;
       		for(i=l-1;i>=0;i--)
       		{
       			if((s[i]-'0')%2==0 && i==l-1)
       			{
       				continue;
       			}
       			else if((s[i]-'0')%2==0 && cnt2==0)
       			{
       				continue;
       			}
       			else{
       				sss.push_back(s[i]);
       				cnt2=2;
       			}
       		}

       		ll cnt=0;
       		ll sz = sss.size();
       		for(i=sz-1;i>=0;i--)
       			{

       				if((sss[i]-'0')%2!=0 && cnt==0 )
       				{
       					if(i==sz-1 && (sss[i-1]-'0')!=0)
                           cnt=1;
                       else if(i==sz-1 && (sss[i-1]-'0')==0)
                       	 cout<<sss[i];
                       else	if(i!=sz-1 && (sss[i-1]-'0')==0)
                       {
                       	cnt=1;
                       }
                       else if(i!=sz-1 && (sss[i-1]-'0')!=0)
                       	 cnt=1;
       				}
       				else
       					cout<<sss[i];
       			}
       			cout<<endl;
       	}
       }
       else if(sum==0)
       	cout<<"-1"<<endl;
	}

}


#include<bits/stdc++.h>
#define  mx  1000011
using namespace std;
typedef long long ll;
ll isp[mx],indx[mx];
vector<ll>prime;
void seive()
{
	isp[0]=isp[1]=1;
	for(ll i = 2; i*i <= mx; i++)
	{
		if(isp[i]==0){
		for(ll j = i; j <= mx; j++)
		{
			if(i*j>mx)
				break;
			isp[i*j] = 1;
		}
      }
	}
	prime.push_back(2);
	for(ll i = 3; i <= mx; i+=2)
	{
		if(isp[i]==0)
			prime.push_back(i);
	}
}
void cal()
{
	seive();
	indx[1] = 0;
	for(ll i = 2; i <mx; i++)
	{
		indx[i] = indx[i-1];

			ll n = i;
			ll j = 0;

			while(isp[n]==1)
			{
				if(n%prime[j]==0)
				{
					n/=prime[j];
                    indx[i]++;
				}
				else
					j++;

			}
			if(isp[n]==0)
				indx[i]++;
     }

}
int main()
{
    cal();
	ll n;
	while(scanf("%lld",&n)!=EOF)
	{
       printf("%lld\n",indx[n]);
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n;
		cin>>n;
		string s;
		cin>>s;
		ll last=n-1;
		ll i;
		for(i=n-1;i>=0;i--)
		{
			if((s[i]-'0')%2==1)
				break;
		}
		if(i==-1 || i==0)
		{
			cout<<-1<<endl;
			continue;
		}
		last=i;
		ll flag=-1;
		ll count=0;
		for(i=0;i<=last;i++)
		{
			count+=(s[i]-'0');
		}
		if(count%2==0)
		{
			i=0;
			while((s[i]-'0')==0)
				i++;
			for(;i<=last;i++)
				cout<<s[i];
			cout<<endl;
			continue;
		}
		else
		{
			for(i=0;i<last;i++)
			{
				if((s[i]-'0')%2==1)
				{
					flag=i;
					break;
				}
			}
//			cout<<last<<"-"<<flag<<endl;
			if(i==last)
				cout<<-1<<endl;
			else
			{
				i=0;
				while((s[i]=='0' || i==flag ))
					i++;

				for(;i<=last;i++)
				{
					if(i!=flag)
						cout<<s[i];
				}
				cout<<endl;
			}
		}

	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{	ll t;
	cin>>t;
	while(t--)
	{
		ll n;
		cin>>n;
		string str;
		cin>>str;
		ll flag=0
		ll karan=0;
		for(int ok=0;ok<100;ok++)
		karan++;
		for(ll i=0;ok<str.length();i++)
		{
			if(((int)str[i])%2!=0)
				flag=1;
		}
		if(flag)
		{
			ll sum=0;
			string mystr;
			ll yes=0;
			for(ll i=0;i<str.length();i++)
			{
				sum+=((int)str[i]);
				mystr+=str[i];
				if((((int)str[i])%2!=0) && (sum%2)==0)
				{
					cout<<mystr<<"\n";
					yes=1;
					break;
				}
			}
			if(yes==0)
				cout<<-1<<"\n";
		}
		else
		{
			cout<<-1<<"\n";
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n;
		cin>>n;
		string s;
		cin>>s;
		ll last=n-1;
		ll i;
		for(i=n-1;i>=0;i--)
		{
			if((s[i]-'0')%2==1)
				break;
		}
		if(i==-1 || i==0)
		{
			cout<<-1<<endl;
			continue;
		}
		last=i;
		ll flag=-1;
		ll count=0;
		for(i=0;i<=last;i++)
		{
			count+=(s[i]-'0');
		}
		if(count%2==0)
		{
			i=0;
			while((s[i]-'0')==0)
				i++;
			for(;i<=last;i++)
				cout<<s[i];
			cout<<endl;
			continue;
		}
		else
		{
			for(i=0;i<last;i++)
			{
				if((s[i]-'0')%2==1)
				{
					flag=i;
					break;
				}
			}
//			cout<<last<<"-"<<flag<<endl;
			if(i==last)
				cout<<-1<<endl;
			else
			{
				i=0;
				while((s[i]-'0' || i==flag )==0)
					i++;

				for(;i<=last;i++)
				{
					if(i!=flag)
						cout<<s[i];
				}
				cout<<endl;
			}
		}

	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n;
		cin>>n;
		string s;
		cin>>s;
		ll last=n-1;
		ll i;
		for(i=n-1;i>=0;i--)
		{
			if((s[i]-'0')%2==1)
				break;
		}
		if(i==-1 || i==0)
		{
			cout<<-1<<endl;
			continue;
		}
		last=i;
		ll flag=-1;
		ll count=0;
		for(i=0;i<=last;i++)
		{
			count+=(s[i]-'0');
		}
		if(count%2==0)
		{
			for(i=0;i<=last;i++)
				cout<<s[i];
			cout<<endl;
			continue;
		}
		else
		{
			for(i=0;i<last;i++)
			{
				if((s[i]-'0')%2==1)
				{
					flag=i;
					break;
				}
			}
//			cout<<last<<"-"<<flag<<endl;
			if(i==last)
				cout<<-1<<endl;
			else
			{
				for(i=0;i<=last;i++)
				{
					if(i!=flag)
						cout<<s[i];
				}
				cout<<endl;
			}
		}

	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{	ll t;
	cin>>t;
	while(t--)
	{
		ll n;
		cin>>n;
		string str;
		cin>>str;
		ll flag=0;
		ll karan=0;
		for(int ok=0;ok<100;ok++)
		karan++;
		for(ll i=0;ok<str.length();i++)
		{
			if(((int)str[i])%2!=0)
				flag=1;
		}
		if(flag)
		{
			ll sum=0;
			string mystr;
			ll yes=0;
			for(ll i=0;i<str.length();i++)
			{
				sum+=((int)str[i]);
				mystr+=str[i];
				if((((int)str[i])%2!=0) && (sum%2)==0)
				{
					cout<<mystr<<endl;
					yes=1;
					break;
				}
			}
			if(yes==0)
				cout<<-1<<endl;
		}
		else
		{
			cout<<-1<<endl;
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n;
		cin>>n;
		string s;
		cin>>s;
		ll last=n-1;
		ll i;
		for(i=n-1;i>=0;i--)
		{
			if((s[i]-'0')%2==1)
				break;
		}
		if(i==-1 || i==0)
		{
			cout<<-1<<endl;
			continue;
		}
		last=i;
		ll flag=-1;
		ll count=0;
		for(i=0;i<=last;i++)
		{
			count+=s[i]-'0';
		}
		if(count%2==0)
		{
			for(i=0;i<=last;i++)
				cout<<s[i];
			cout<<endl;
			continue;
		}
		else
		{
			for(i=0;i<last;i++)
			{
				if((s[i]-'0')%2==1)
				{
					flag=i;
					break;
				}
			}
			if(i==last)
				cout<<-1<<endl;
			else
			{
				for(i=0;i<=last;i++)
				{
					if(i!=flag)
						cout<<s[i];
				}
				cout<<endl;
			}
		}

	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n;
		cin>>n;
		string s;
		cin>>s;
		ll last=n-1;
		ll i;
		for(i=n-1;i>=0;i--)
		{
			if((s[i]-'0')%2==1)
				break;
		}
		if(i==-1 || i==0)
		{
			cout<<-1<<endl;
			continue;
		}
		last=i;
		ll flag=-1;
		ll count=0;
		for(i=0;i<=last;i++)
		{
			count+=(s[i]-'0');
		}
		if(count%2==0)
		{
			i=0;
			while((s[i]-'0')==0)
				i++;
			for(;i<=last;i++)
				cout<<s[i];
			cout<<endl;
			continue;
		}
		else
		{
			for(i=0;i<last;i++)
			{
				if((s[i]-'0')%2==1)
				{
					flag=i;
					break;
				}
			}
//			cout<<last<<"-"<<flag<<endl;
			if(i==last)
				cout<<-1<<endl;
			else
			{
				i=0;
				while((s[i]-'0')==0)
					i++;
				for(;i<=last;i++)
				{
					if(i!=flag)
						cout<<s[i];
				}
				cout<<endl;
			}
		}

	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{	ll t;
	cin>>t;
	while(t--)
	{
		ll n;
		cin>>n;
		string str;
		cin>>str;
		ll flag=0
		ll karan=0;
		for(int ok=0;i<100;ok++)
		karan++;
		for(ll i=0;ok<str.length();i++)
		{
			if(((int)str[i])%2!=0)
				flag=1;
		}
		if(flag)
		{
			ll sum=0;
			string mystr;
			ll yes=0;
			for(ll i=0;i<str.length();i++)
			{
				sum+=((int)str[i]);
				mystr+=str[i];
				if((((int)str[i])%2!=0) && (sum%2)==0)
				{
					cout<<mystr<<"\n";
					yes=1;
					break;
				}
			}
			if(yes==0)
				cout<<-1<<"\n";
		}
		else
		{
			cout<<-1<<"\n";
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{	ll t;
	cin>>t;
	while(t--)
	{
		ll n;
		cin>>n;
		string str;
		cin>>str;
		ll flag=0;
		ll karan=0;
		for(int ok=0;ok<100;ok++)
		karan++;
		for(ll i=0;i<str.length();i++)
		{
			if(((int)str[i])%2!=0)
				flag=1;
		}
		if(flag)
		{
			ll sum=0;
			string mystr;
			ll yes=0;
			for(ll i=0;i<str.length();i++)
			{
				sum+=((int)str[i]);
				mystr+=str[i];
				if((((int)str[i])%2!=0) && (sum%2)==0)
				{
					cout<<mystr<<"\n";
					yes=1;
					break;
				}
			}
			if(yes==0)
				cout<<-1<<"\n";
		}
		else
		{
			cout<<-1<<"\n";
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n;
		cin>>n;
		string s;
		cin>>s;
		ll last=n-1;
		ll i;
		for(i=n-1;i>=0;i--)
		{
			if((s[i]-'0')%2==1)
				break;
		}
		if(i==-1 || i==0)
		{
			cout<<-1<<endl;
			continue;
		}
		last=i;
		ll flag=-1;
		ll count=0;
		for(i=0;i<=last;i++)
		{
			count+=s[i]-'0';
		}
		if(count%2==0)
		{
			for(i=0;i<=last;i++)
				cout<<s[i];
			cout<<endl;
			continue;
		}
		else
		{
			for(i=0;i<=last;i++)
			{
				if((s[i]-'0')%2==1)
				{
					flag=i;
					break;
				}
			}
			if(i==last+1)
			cout<<-1<<endl;
			else
			{
				for(i=0;i<=last;i++)
				{
					if(i!=flag)
						cout<<s[i];
				}
				cout<<endl;
			}
		}

	}
}


//		HYSO SERIOUS? WHY SO SERIOUS                            RIOUS? WHY SO SERIOUS? WHYSO SERIO
//		 ERIOUS? WHY SO SERIOUS ? WHY                          WHY SO SERIOUS? WHY SOSERIOUSWHYS
//		       OSERIOUS? WHY SO SERIOU         SERIOUS        ERIOUS? WHY SO SERIOUS? WHYS
//		          WHY SO SERIOUS? WHY SOSERIOUS? WHYSOSERIOUS? WHY SO SERIOUS?WHY SO SE
//		           ERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SOSERIO
//		           WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WH
//		            SERIOUS?WHYSO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHYSO SE
//		              ?WHYSOSERIOUS?WHY SO SERIOUS? WHY SO SERIOUS?WHYSO SERIOUS?
//		                           OSERIOUS? WHY SO SERIOUS?WHYSOSER
//		                                 HYSOSERIOUS?WHYSOSERI
//		                                     SOSERIOUS?W
//		                                         SER
//		                                          W

#include <iostream>
#include <queue>
#include <tuple>
#include <vector>
using namespace std;
#include<bits/stdc++.h>
#include <algorithm>
#define ll long long int
#define read(a) long long int a; cin>>a;
#define readstr(s) string s; cin>>s;
#define readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define v(pi) vector<ll>pi
#define vp(pi) vector<pair<ll,ll>>pi
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define pb(p) push_back(p)
#define mp make_pair
#include <cmath>
#include <map>
#define mi(lol) map<ll,ll>lol
#define fsort(vec) sort(vec.begin(),vec.end())
#define rsort(vec) sort(vec.begin(),vec.end(),compare)
#define inf ll inf=INT_MAX
//sorting according to the second element vector

bool compare(pair<ll,ll> p,pair<ll,ll> q){
	return p.second < q.second;
}

//   example:-
//   sort(vec.begin(),vec.end(),compare);

int main() {
	fast;
#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
	read(a)
	loop(i,0,a){
		read(b)
		readstr(s);
	bool flag=true;
	string st="";
	ll k=s.length()-1;
	while(flag){
		// cout<<s<<endl;
		ll c=s[k]-'0';
		// cout<<c<<endl;
		if(c%2==0){
			// cout<<1<<endl;
			s.erase(s.begin()+k);
		}
		else {
			flag=false;
		}
		if(s.length()==0) flag=0;
		k--;
}
// cout<<s<<endl;
if(s.length()==0) {cout<<-1<<endl; continue;}
	ll sum=0;
	ll sum_0=0;
	loop(j,0,s.length()){
		char c=s[j];
		ll n=c-'0';
		sum=sum+n;
		if(s[j]=='0')
		sum_0++;
	}
	// cout<<sum<<endl;
	if(sum_0==s.length()) {cout<<-1<<endl;continue;}
	string str="";
	string str1="";
	ll r=s.length();
	ll kk=0;
	// cout<<sum<<endl;
	// cout<<s<<endl;
	if(sum%2==0) {cout<<s<<endl;continue;}
	else {
		loop(j,0,b-1){
			if((int)s[j]%2!=0){
					s.erase(s.begin()+j);
				// cout<<str<<" "<<str1<<endl;
				kk=1;
				break;
			}

		}
if(kk==0) cout<<-1<<endl;
else cout<<s<<endl;
	}

	}
	return 0;
}


//		HYSO SERIOUS? WHY SO SERIOUS                            RIOUS? WHY SO SERIOUS? WHYSO SERIO
//		 ERIOUS? WHY SO SERIOUS ? WHY                          WHY SO SERIOUS? WHY SOSERIOUSWHYS
//		       OSERIOUS? WHY SO SERIOU         SERIOUS        ERIOUS? WHY SO SERIOUS? WHYS
//		          WHY SO SERIOUS? WHY SOSERIOUS? WHYSOSERIOUS? WHY SO SERIOUS?WHY SO SE
//		           ERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SOSERIO
//		           WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WH
//		            SERIOUS?WHYSO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHYSO SE
//		              ?WHYSOSERIOUS?WHY SO SERIOUS? WHY SO SERIOUS?WHYSO SERIOUS?
//		                           OSERIOUS? WHY SO SERIOUS?WHYSOSER
//		                                 HYSOSERIOUS?WHYSOSERI
//		                                     SOSERIOUS?W
//		                                         SER
//		                                          W

#include <iostream>
#include <queue>
#include <tuple>
#include <vector>
using namespace std;
#include<bits/stdc++.h>
#include <algorithm>
#define ll long long int
#define read(a) long long int a; cin>>a;
#define readstr(s) string s; cin>>s;
#define readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define v(pi) vector<ll>pi
#define vp(pi) vector<pair<ll,ll>>pi
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define pb(p) push_back(p)
#define mp make_pair
#include <cmath>
#include <map>
#define mi(lol) map<ll,ll>lol
#define fsort(vec) sort(vec.begin(),vec.end())
#define rsort(vec) sort(vec.begin(),vec.end(),compare)
#define inf ll inf=INT_MAX
//sorting according to the second element vector

bool compare(pair<ll,ll> p,pair<ll,ll> q){
	return p.second < q.second;
}

//   example:-
//   sort(vec.begin(),vec.end(),compare);

int main() {
	fast;
#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
	read(a)
	loop(i,0,a){
		read(b)
		readstr(s);
	bool flag=true;
	string st="";
	ll k=b-1;
	// cout<<k<<endl;
	// while(flag){
	// 	ll c=s[k]-'0';
	// 	// cout<<s<<endl;
	// 	cout<<k<<endl;
	// 	cout<<c<<endl;
	// 	if(c%2==0){
	// 		st=s.substr(0,k-1);
	// 		s=st;
	// 	}
	// 	else {
	// 		flag=false;
	// 	}
	// 	k--;
	// }
	// cout<<s<<endl;
	if((int)s[b-1]%2==0) s=s.substr(0,b-1);
	ll sum=0;
	ll sum_0=0;
	loop(j,0,b){
		char c=s[j];
		ll n=c-'0';
		sum=sum+n;
		if(s[j]=='0')
		sum_0++;
	}
	if(sum_0==s.length()) {cout<<-1<<endl;continue;}
	string str="";
	string str1="";
	ll r=s.length();
	ll kk=0;
	// cout<<sum<<endl;
	if(sum%2==0) {cout<<s<<endl;continue;}
	else {
		loop(j,0,b-1){
			if((int)s[j]%2!=0){
				if(j!=0)
				str=s.substr(0,j-1);
				str1=s.substr(j+1,r);
				// cout<<str<<" "<<str1<<endl;
				s=str+str1;
				kk=1;
				break;
			}

		}
		// cout<<kk<<endl;
if(kk==0) cout<<-1<<endl;
else cout<<s<<endl;
	}

	}
	return 0;
}


//		HYSO SERIOUS? WHY SO SERIOUS                            RIOUS? WHY SO SERIOUS? WHYSO SERIO
//		 ERIOUS? WHY SO SERIOUS ? WHY                          WHY SO SERIOUS? WHY SOSERIOUSWHYS
//		       OSERIOUS? WHY SO SERIOU         SERIOUS        ERIOUS? WHY SO SERIOUS? WHYS
//		          WHY SO SERIOUS? WHY SOSERIOUS? WHYSOSERIOUS? WHY SO SERIOUS?WHY SO SE
//		           ERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SOSERIO
//		           WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WH
//		            SERIOUS?WHYSO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHYSO SE
//		              ?WHYSOSERIOUS?WHY SO SERIOUS? WHY SO SERIOUS?WHYSO SERIOUS?
//		                           OSERIOUS? WHY SO SERIOUS?WHYSOSER
//		                                 HYSOSERIOUS?WHYSOSERI
//		                                     SOSERIOUS?W
//		                                         SER
//		                                          W

#include <iostream>
#include <queue>
#include <tuple>
#include <vector>
using namespace std;
#include<bits/stdc++.h>
#include <algorithm>
#define ll long long int
#define read(a) long long int a; cin>>a;
#define readstr(s) string s; cin>>s;
#define readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define v(pi) vector<ll>pi
#define vp(pi) vector<pair<ll,ll>>pi
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define pb(p) push_back(p)
#define mp make_pair
#include <cmath>
#include <map>
#define mi(lol) map<ll,ll>lol
#define fsort(vec) sort(vec.begin(),vec.end())
#define rsort(vec) sort(vec.begin(),vec.end(),compare)
#define inf ll inf=INT_MAX
//sorting according to the second element vector

bool compare(pair<ll,ll> p,pair<ll,ll> q){
	return p.second < q.second;
}

//   example:-
//   sort(vec.begin(),vec.end(),compare);

int main() {
	fast;
#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
	read(a)
	loop(i,0,a){
		read(b)
		readstr(s);
	bool flag=true;
	string st="";
	ll k=b-1;
	while(flag){
		// cout<<s<<endl;
		ll c=s[k]-'0';
		if(c%2==0){
			s.erase(s.begin()+k);
		}
		else {
			flag=false;
		}
		if(s.length()==0) flag=0;
		k--;
}
// cout<<s<<endl;
if(s.length()==0) {cout<<-1<<endl; continue;}
	ll sum=0;
	ll sum_0=0;
	loop(j,0,b){
		char c=s[j];
		ll n=c-'0';
		sum=sum+n;
		if(s[j]=='0')
		sum_0++;
	}
	if(sum_0==s.length()) {cout<<-1<<endl;continue;}
	string str="";
	string str1="";
	ll r=s.length();
	ll kk=0;
	// cout<<sum<<endl;
	if(sum%2==0) {cout<<s<<endl;continue;}
	else {
		loop(j,0,b-1){
			if((int)s[j]%2!=0){
				if(j!=0)
				str=s.substr(0,j-1);
				str1=s.substr(j+1,r);
				// cout<<str<<" "<<str1<<endl;
				s=str+str1;
				kk=1;
				break;
			}

		}
if(kk==0) cout<<-1<<endl;
else cout<<s<<endl;
	}

	}
	return 0;
}


#include 	<ext/pb_ds/assoc_container.hpp>
#include 	<ext/pb_ds/tree_policy.hpp>
#include 	<iostream>
#include 	<queue>
#include 	<tuple>
#include 	<vector>
#include	<bits/stdc++.h>
#include	<algorithm>
#include 	<cmath>
#include 	<map>
#include 	<string>
#include 	<iomanip>
#include 	<ctype.h>
#define 	ll  long long int
#define		read(a) long long int a; cin>>a;
#define 	readstr(s) string s; cin>>s;
#define 	readc(c) char c; cin>>c;
#define 	readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define 	loop(i,a,b) for(ll i=a;i<b;i++)
#define 	rloop(i,a,b) for(ll i=a;i>b;i--)
#define 	loopchar() for(char c='a';c<='z';c++)
#define 	printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define		printv(v) for (int i: v) cout << i << " "; cout << endl;
#define 	loopitr(vec) for(auto itr=vec.begin();itr!=vec.end();itr++)
#define 	ff first
#define 	ss second
#define 	readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define 	all(a) a.begin(), a.end()
#define 	yes cout <<"YES"<<endl;
#define 	no cout <<"NO"<<endl;
#define 	sc(x) cout << (#x) << " is " << (x) << endl;
#define 	fast ios_base::sync_with_stdio(false);cin.tie(0);
#define 	pb(p) push_back(p)
#define 	mp make_pair
#define 	fsort(vec) sort(vec.begin(),vec.end())
#define 	rsort(vec) sort(vec.begin(),vec.end(),compare)
#define 	Endl endl
#define 	ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define 	roundoff std::cout << std::setprecision(15)
#define 	inf 9223372036854775807
#define 	infn -9223372036854775807
#define 	pi 3.14159265358979323846
const 		int mod = 1e9+7;
#define 	intsize ll size = trunc(log10(num)) + 1
#define 	REVERSE(vec) reverse(vec.begin(),vec.end())
using 		namespace __gnu_pbds;
using 		namespace std;

ll gcd (ll a, ll b) { return b ? gcd (b, a % b) : a; }
ll lcm (ll a, ll b) { return a / gcd(a, b) * b; }

//code start from here

int main() {
	fast;
	#ifndef ONLINE_JUDGE
 	 	freopen("input.txt","r",stdin);
	  	freopen("output.txt","w",stdout);
	#endif
	read(a)
	while(a--){
		read(b)
		readstr(s)
		ll sum=0;
		string g="";
		loop(j,0,s.length()){
			ll m=(int)(s[j]-'0');
			if(m%2!=0){
				g+=s[j];
				sum++;
			}
			if(sum==2) break;
		}
		if(sum!=2)
			cout<<-1<<endl;
		else
		cout<<g<<endl;

	}
	return 0;
}

//ends here


//		HYSO SERIOUS? WHY SO SERIOUS                            RIOUS? WHY SO SERIOUS? WHYSO SERIO
//		 ERIOUS? WHY SO SERIOUS ? WHY                          WHY SO SERIOUS? WHY SOSERIOUSWHYS
//		       OSERIOUS? WHY SO SERIOU         SERIOUS        ERIOUS? WHY SO SERIOUS? WHYS
//		          WHY SO SERIOUS? WHY SOSERIOUS? WHYSOSERIOUS? WHY SO SERIOUS?WHY SO SE
//		           ERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SOSERIO
//		           WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WH
//		            SERIOUS?WHYSO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHYSO SE
//		              ?WHYSOSERIOUS?WHY SO SERIOUS? WHY SO SERIOUS?WHYSO SERIOUS?
//		                           OSERIOUS? WHY SO SERIOUS?WHYSOSER
//		                                 HYSOSERIOUS?WHYSOSERI
//		                                     SOSERIOUS?W
//		                                         SER
//		                                          W

#include <iostream>
#include <queue>
#include <tuple>
#include <vector>
using namespace std;
#include<bits/stdc++.h>
#include <algorithm>
#define ll long long int
#define read(a) long long int a; cin>>a;
#define readstr(s) string s; cin>>s;
#define readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define v(pi) vector<ll>pi
#define vp(pi) vector<pair<ll,ll>>pi
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define pb(p) push_back(p)
#define mp make_pair
#include <cmath>
#include <map>
#define mi(lol) map<ll,ll>lol
#define fsort(vec) sort(vec.begin(),vec.end())
#define rsort(vec) sort(vec.begin(),vec.end(),compare)
#define inf ll inf=INT_MAX
//sorting according to the second element vector

bool compare(pair<ll,ll> p,pair<ll,ll> q){
	return p.second < q.second;
}

//   example:-
//   sort(vec.begin(),vec.end(),compare);

int main() {
	fast;
#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
	read(a)
	loop(i,0,a){
		read(b)
		readstr(s);
	bool flag=true;
	string st="";
	ll k=b-1;
	// cout<<k<<endl;
	// while(flag){
	// 	ll c=s[k]-'0';
	// 	// cout<<s<<endl;
	// 	cout<<k<<endl;
	// 	cout<<c<<endl;
	// 	if(c%2==0){
	// 		st=s.substr(0,k-1);
	// 		s=st;
	// 	}
	// 	else {
	// 		flag=false;
	// 	}
	// 	k--;
	// }
	// cout<<s<<endl;
	if((int)s[b-1]%2==0) s=s.substr(0,b-1);
	ll sum=0;
	ll sum_0=0;
	loop(j,0,b){
		char c=s[j];
		ll n=c-'0';
		sum=sum+n;
		if(s[j]=='0')
		sum_0++;
	}
	if(sum_0==s.length()) {cout<<-1<<endl;continue;}
	string str="";
	string str1="";
	ll r=s.length();
	ll kk=0;
	if(sum%2==0) {cout<<s<<endl;continue;}
	else {
		loop(j,0,b-1){
			if((int)s[j]%2!=0){
				str=s.substr(0,j-1);
				str1=s.substr(j+1,r);
				s=str+str1;
				kk=1;
				// cout<<12<<endl;
			}

		}
		cout<<kk<<endl;
if(kk==0) cout<<-1<<endl;
else cout<<s<<endl;
	}

	}
	return 0;
}


//		HYSO SERIOUS? WHY SO SERIOUS                            RIOUS? WHY SO SERIOUS? WHYSO SERIO
//		 ERIOUS? WHY SO SERIOUS ? WHY                          WHY SO SERIOUS? WHY SOSERIOUSWHYS
//		       OSERIOUS? WHY SO SERIOU         SERIOUS        ERIOUS? WHY SO SERIOUS? WHYS
//		          WHY SO SERIOUS? WHY SOSERIOUS? WHYSOSERIOUS? WHY SO SERIOUS?WHY SO SE
//		           ERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SOSERIO
//		           WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WH
//		            SERIOUS?WHYSO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHYSO SE
//		              ?WHYSOSERIOUS?WHY SO SERIOUS? WHY SO SERIOUS?WHYSO SERIOUS?
//		                           OSERIOUS? WHY SO SERIOUS?WHYSOSER
//		                                 HYSOSERIOUS?WHYSOSERI
//		                                     SOSERIOUS?W
//		                                         SER
//		                                          W

#include <iostream>
#include <queue>
#include <tuple>
#include <vector>
using namespace std;
#include<bits/stdc++.h>
#include <algorithm>
#define ll long long int
#define read(a) long long int a; cin>>a;
#define readstr(s) string s; cin>>s;
#define readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define v(pi) vector<ll>pi
#define vp(pi) vector<pair<ll,ll>>pi
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define pb(p) push_back(p)
#define mp make_pair
#include <cmath>
#include <map>
#define mi(lol) map<ll,ll>lol
#define fsort(vec) sort(vec.begin(),vec.end())
#define rsort(vec) sort(vec.begin(),vec.end(),compare)
#define inf ll inf=INT_MAX
//sorting according to the second element vector

bool compare(pair<ll,ll> p,pair<ll,ll> q){
	return p.second < q.second;
}

//   example:-
//   sort(vec.begin(),vec.end(),compare);

int main() {
	fast;
#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
	read(a)
	loop(i,0,a){
		read(b)
		readstr(s);
	bool flag=true;
	string st="";
	ll k=s.length()-1;
	while(flag){
		// cout<<s<<endl;
		ll c=s[k]-'0';
		// cout<<c<<endl;
		if(c%2==0){
			// cout<<1<<endl;
			s.erase(s.begin()+k);
		}
		else {
			flag=false;
		}
		if(s.length()==0) flag=0;
		k--;
}
// cout<<s<<endl;
if(s.length()==0) {cout<<-1<<endl; continue;}
	ll sum=0;
	ll sum_0=0;
	loop(j,0,s.length()){
		char c=s[j];
		ll n=c-'0';
		sum=sum+n;
		if(s[j]=='0')
		sum_0++;
	}
	// cout<<sum<<endl;
	if(sum_0==s.length()) {cout<<-1<<endl;continue;}
	string str="";
	string str1="";
	ll r=s.length();
	ll kk=0;
	if(sum%2==0) {cout<<s<<endl;continue;}
	else {
		loop(j,0,b-1){
			if((int)s[j]%2!=0){
					s.erase(s.begin()+j);
					kk=1;
					if(s[j]!=0)
					break;
			}
		}
if(kk==0||(int)s[s.length()-1]%2==0) cout<<-1<<endl;
else cout<<s<<endl;
	}

	}
	return 0;
}


//		HYSO SERIOUS? WHY SO SERIOUS                            RIOUS? WHY SO SERIOUS? WHYSO SERIO
//		 ERIOUS? WHY SO SERIOUS ? WHY                          WHY SO SERIOUS? WHY SOSERIOUSWHYS
//		       OSERIOUS? WHY SO SERIOU         SERIOUS        ERIOUS? WHY SO SERIOUS? WHYS
//		          WHY SO SERIOUS? WHY SOSERIOUS? WHYSOSERIOUS? WHY SO SERIOUS?WHY SO SE
//		           ERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SOSERIO
//		           WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WH
//		            SERIOUS?WHYSO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHYSO SE
//		              ?WHYSOSERIOUS?WHY SO SERIOUS? WHY SO SERIOUS?WHYSO SERIOUS?
//		                           OSERIOUS? WHY SO SERIOUS?WHYSOSER
//		                                 HYSOSERIOUS?WHYSOSERI
//		                                     SOSERIOUS?W
//		                                         SER
//		                                          W

#include <iostream>
#include <queue>
#include <tuple>
#include <vector>
using namespace std;
#include<bits/stdc++.h>
#include <algorithm>
#define ll long long int
#define read(a) long long int a; cin>>a;
#define readstr(s) string s; cin>>s;
#define readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define v(pi) vector<ll>pi
#define vp(pi) vector<pair<ll,ll>>pi
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define pb(p) push_back(p)
#define mp make_pair
#include <cmath>
#include <map>
#define mi(lol) map<ll,ll>lol
#define fsort(vec) sort(vec.begin(),vec.end())
#define rsort(vec) sort(vec.begin(),vec.end(),compare)
#define inf ll inf=INT_MAX
//sorting according to the second element vector

bool compare(pair<ll,ll> p,pair<ll,ll> q){
	return p.second < q.second;
}

//   example:-
//   sort(vec.begin(),vec.end(),compare);

int main() {
	fast;
#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
	read(a)
	loop(i,0,a){
		read(b)
		readstr(s);
	bool flag=true;
	string st="";
	ll k=s.length()-1;
	while(flag){
		// cout<<s<<endl;
		ll c=s[k]-'0';
		// cout<<c<<endl;
		if(c%2==0){
			// cout<<1<<endl;
			s.erase(s.begin()+k);
		}
		else {
			flag=false;
		}
		if(s.length()==0) flag=0;
		k--;
}
// cout<<s<<endl;
if(s.length()==0) {cout<<-1<<endl; continue;}
	ll sum=0;
	ll sum_0=0;
	loop(j,0,s.length()){
		char c=s[j];
		ll n=c-'0';
		sum=sum+n;
		if(s[j]=='0')
		sum_0++;
	}
	// cout<<sum<<endl;
	if(sum_0==s.length()) {cout<<-1<<endl;continue;}
	string str="";
	string str1="";
	ll r=s.length();
	ll kk=0;
	// cout<<sum<<endl;
	// cout<<s<<endl;
	if(sum%2==0) {cout<<s<<endl;continue;}
	else {
		loop(j,0,b-1){
			if((int)s[j]%2!=0){
					s.erase(s.begin()+j);
					kk=1;
					break;
			}
		}
if(kk==0||(int)s[s.length()-1]%2==0) cout<<-1<<endl;
else cout<<s<<endl;
	}

	}
	return 0;
}


//		HYSO SERIOUS? WHY SO SERIOUS                            RIOUS? WHY SO SERIOUS? WHYSO SERIO
//		 ERIOUS? WHY SO SERIOUS ? WHY                          WHY SO SERIOUS? WHY SOSERIOUSWHYS
//		       OSERIOUS? WHY SO SERIOU         SERIOUS        ERIOUS? WHY SO SERIOUS? WHYS
//		          WHY SO SERIOUS? WHY SOSERIOUS? WHYSOSERIOUS? WHY SO SERIOUS?WHY SO SE
//		           ERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SOSERIO
//		           WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WH
//		            SERIOUS?WHYSO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHYSO SE
//		              ?WHYSOSERIOUS?WHY SO SERIOUS? WHY SO SERIOUS?WHYSO SERIOUS?
//		                           OSERIOUS? WHY SO SERIOUS?WHYSOSER
//		                                 HYSOSERIOUS?WHYSOSERI
//		                                     SOSERIOUS?W
//		                                         SER
//		                                          W

#include <iostream>
#include <queue>
#include <tuple>
#include <vector>
using namespace std;
#include<bits/stdc++.h>
#include <algorithm>
#define ll long long int
#define read(a) long long int a; cin>>a;
#define readstr(s) string s; cin>>s;
#define readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define v(pi) vector<ll>pi
#define vp(pi) vector<pair<ll,ll>>pi
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define pb(p) push_back(p)
#define mp make_pair
#include <cmath>
#include <map>
#define mi(lol) map<ll,ll>lol
#define fsort(vec) sort(vec.begin(),vec.end())
#define rsort(vec) sort(vec.begin(),vec.end(),compare)
#define inf ll inf=INT_MAX
//sorting according to the second element vector

bool compare(pair<ll,ll> p,pair<ll,ll> q){
	return p.second < q.second;
}

//   example:-
//   sort(vec.begin(),vec.end(),compare);

int main() {
	fast;
#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
	read(a)
	loop(i,0,a){
		read(b)
		readstr(s);
	bool flag=true;
	string st="";
	ll k=b-1;
	while(flag){
		// cout<<s<<endl;
		ll c=s[k]-'0';
		if(c%2==0){
			s.erase(s.begin()+k);
		}
		else {
			flag=false;
		}
		if(s.length()==0) flag=0;
		k--;
}
// cout<<s<<endl;
if(s.length()==0) {cout<<-1<<endl; continue;}
	ll sum=0;
	ll sum_0=0;
	loop(j,0,s.length()){
		char c=s[j];
		ll n=c-'0';
		sum=sum+n;
		if(s[j]=='0')
		sum_0++;
	}
	// cout<<sum<<endl;
	if(sum_0==s.length()) {cout<<-1<<endl;continue;}
	string str="";
	string str1="";
	ll r=s.length();
	ll kk=0;
	// cout<<sum<<endl;
	// cout<<s<<endl;
	if(sum%2==0) {cout<<s<<endl;continue;}
	else {
		loop(j,0,b-1){
			if((int)s[j]%2!=0){
					s.erase(s.begin()+j);
				// cout<<str<<" "<<str1<<endl;
				kk=1;
				break;
			}

		}
if(kk==0) cout<<-1<<endl;
else cout<<s<<endl;
	}

	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define MAXX 200010

#define PI   3.14159265358979323846264338327950

#define PB push_back
#define F first
#define S second

#define ll 	long long

#define mod  1000000007

int main()
{
	FAST;
	int t;
	cin >> t;
	while(t --){
		int n; string s;
		cin >> n >> s;
		ll x = 0;
		for(int i = 0; i < n; i ++){
			x += (s[i] - 48);
		}
		for(int i = n-1; i > 0; i --){
			if((s[i] - 48) % 2){
				break;
			}
			else{
				x -= (s[i] - 48);
				s.erase(s.begin() + i);
				i--;
				n --;
			}
		}
		if((s[n-1] - 48) % 2){
			if(x % 2){
				for(int i = n-1; i > 0; i --){
					if((s[i] - 48) % 2 ){
						x -= (s[i] - 48);
						s.erase(s.begin() + i);
						n --;
						break;
					}
				}
			}
			if(x % 2 == 0 ){
				cout << s;
			}
			else{
				cout << -1;
			}
		}
		else{
			cout << -1;

		}
		cout << endl;

	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define MAXX 200010

#define PI   3.14159265358979323846264338327950

#define PB push_back
#define F first
#define S second

#define ll 	long long

#define mod  1000000007

int main()
{
	FAST;
	int t;
	cin >> t;
	while(t --){
		int n; string s;
		cin >> n >> s;
		ll x = 0;
		for(int i = 0; i < n; i ++){
			x += (s[i] - 48);
		}
		for(int i = n-1; i > 0; i --){
			if((s[i] - 48) % 2){
				break;
			}
			else{
				x -= (s[i] - 48);
				s.erase(s.begin() + i);
				i--;
				n --;
			}
		}
		if((s[n-1] - 48) % 2){
			if(x % 2){
				for(int i = 0; i < n - 1; i ++){
					if((s[i] - 48) % 2 ){
						x -= (s[i] - 48);
						s.erase(s.begin() + i);
						n --;
						break;
					}
				}
			}
			if(x % 2 == 0 ){
				cout << s;
			}
			else{
				cout << -1;
			}
		}
		else{
			cout << -1;

		}
		cout << endl;

	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define MAXX 200010

#define PI   3.14159265358979323846264338327950

#define PB push_back
#define F first
#define S second

#define ll 	long long

#define mod  1000000007

int main()
{
	FAST;
	int t;
	cin >> t;
	while(t --){
		int n; string s;
		cin >> n >> s;
		ll x = 0;
		for(int i = 0; i < n; i ++){
			x += (s[i] - 48);
		}
		for(int i = s.size() - 1; i > 0; i --){
			if((s[i] - 48) % 2 == 0){
				x -= (s[i] - 48);

				s.erase(s.begin() + i);
			}
			else{
				break;
			}
		}
		if(x % 2){
			for(int i = 0; i + 1< s.size() ; i ++){
				if((i == 0 && (s[i]- 48)%2 && s[i+1] != '0' ) || (i >= 1 && (s[i]- 48)%2)){
					x -= (s[i] - 48);;
					s.erase(s.begin() + i);
					break;
				}
			}
		}
		if(x % 2 == 0 && (s[s.size() - 1] - 48)%2 && s.size() >= 2){
			cout << s << endl ; continue;
		}
		cout << -1 << endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define MAXX 200010

#define PI   3.14159265358979323846264338327950

#define PB push_back
#define F first
#define S second

#define ll 	long long

#define mod  1000000007

int main()
{
	FAST;
	int t;
	cin >> t;
	while(t --){
		int n; string s;
		cin >> n >> s;
		ll x = 0;
		for(int i = 0; i < n; i ++){
			x += (s[i] - 48);
		}
		for(int i = n-1; i >= 0; i --){
			if((s[i] - 48) % 2 == 0){
				x -= (s[i] - 48);

				s.erase(s.begin() + i);
			}
			else{
				break;
			}
		}
		if(x % 2){
			for(int i = n-2; i >= 0; i --){
				if((s[i] - 48) % 2){
					x -= (s[i] - 48);;
					n --;
					s.erase(s.begin() + i);
					break;
				}
			}
		}
		if(x % 2 == 0 && (s[s.size() - 1] - 48)%2 && s.size() > 2){
			cout << s << endl ; continue;
		}
		cout << -1 << endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define MAXX 200010

#define PI   3.14159265358979323846264338327950

#define PB push_back
#define F first
#define S second

#define ll 	long long

#define mod  1000000007

int main()
{
	FAST;
	int t;
	cin >> t;
	while(t --){
		int n; string s;
		cin >> n >> s;
		ll x = 0;
		for(int i = 0; i < n; i ++){
			x += (s[i] - 48);
		}
		for(int i = n-1; i > 0; i --){
			if((s[i] - 48) % 2){
				break;
			}
			else{
				x -= (s[i] - 48);
				s.erase(s.begin() + i);
				//i--;
				n --;
			}
		}
		if((s[n-1] - 48) % 2){
			if(x % 2){
				for(int i = n-1; i > 0; i --){
					if((s[i] - 48) % 2 ){
						x -= (s[i] - 48);
						s.erase(s.begin() + i);
						n --;
						break;
					}
				}
			}
			if(x % 2 == 0 ){
				cout << s;
			}
			else{
				cout << -1;
			}
		}
		else{
			cout << -1;

		}
		cout << endl;

	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define MAXX 200010

#define PI   3.14159265358979323846264338327950

#define PB push_back
#define F first
#define S second

#define ll 	long long

#define mod  1000000007

int main()
{
	FAST;
	int t;
	cin >> t;
	while(t --){
		int n; string s;
		cin>> n >> s;
		ll x = 0;
		int f = s[n-1] - 48;
		for(int i = 0; i < n; i ++){
			x += s[i] - 48;

		}
		if(n == 1){
			cout << -1 << endl; continue;
		}
		while(f % 2 == 0){
			n --;
			x -= (s[n] - 48);
			s.erase(s.begin() + n);
			f = s[n-1];
		}
		if(x % 2){
			for(int i = 0; i < n; i ++){
				if((s[i] - 48) % 2){
					x -= s[i]-48;
					s.erase(s.begin() + i);
					break;
				}
			}
		}
		if(x % 2 || f % 2 == 0){
			cout << -1;
		}
		else{
			cout << s;
		}
		cout << endl;

	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define MAXX 200010

#define PI   3.14159265358979323846264338327950

#define PB push_back
#define F first
#define S second

#define ll 	long long

#define mod  1000000007

int main()
{
	FAST;
	int t;
	cin >> t;
	while(t --){
		int n; string s;
		cin>> n >> s;
		ll x = 0;
		int f = s[n-1] - 48;
		for(int i = 0; i < n; i ++){
			x += s[i] - 48;

		}

		while(f % 2 == 0 && s.size() > 0){
			n --;
			x -= (s[n] - 48);
			s.erase(s.begin() + n);
			f = s[n-1];
		}
		if(x % 2){
			for(int i = 0; i < n; i ++){
				if((s[i] - 48) % 2){
					x -= s[i]-48;
					s.erase(s.begin() + i);
					break;
				}
			}
		}
		if(x % 2 || f % 2 == 0 || s.size() == 0){
			cout << -1;
		}
		else{
			cout << s;
		}
		cout << endl;

	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define MAXX 200010

#define PI   3.14159265358979323846264338327950

#define PB push_back
#define F first
#define S second

#define ll 	long long

#define mod  1000000007

int main()
{
	FAST;
	int t;
	cin >> t;
	while(t --){
		int n; string s;
		cin>> n >> s;
		ll x = 0;
		int f = s[n-1] - 48;
		for(int i = 0; i < n; i ++){
			x += s[i] - 48;

		}

		while(f % 2 == 0){
			n --;
			x -= (s[n] - 48);
			s.erase(s.begin() + n);
			f = s[n-1];
		}
		if(x % 2){
			for(int i = 0; i < n; i ++){
				if((s[i] - 48) % 2){
					x -= s[i]-48;
					s.erase(s.begin() + i);
					break;
				}
			}
		}
		if(x % 2 || f % 2 == 0 || s.size() == 0){
			cout << -1;
		}
		else{
			cout << s;
		}
		cout << endl;

	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t; cin>>t;
    while(t--)
    {
        int n,i; cin>>n;
        string s; cin>>s;
        vector <int> num(n);
        for(i=0; i<n; ++i)
        {
        num[i]=s[i]-'0';
        }
        if(num.size()==1)
        {
           cout<<"-1"<<endl;
           continue;
        }
        while(*(num.end()-1)%2==0)
        {
            auto it=num.end()-1;
            num.erase(it);
            if(num.size()==1)
            {
            cout<<"-1"<<endl;
            break;
            }
        }
        long long sum=0;
        if(num.size()!=0)
        {
            for(i=0; i<n; ++i) sum+=num[i];
            while((sum%2)!=0)
            {
                sum-=*num.begin();
                num.erase(num.begin());

            }
            if(num.size()!=0)
            {
                for(i=0; i<(int)num.size(); ++i)
                {   if(num[i]!=0)
                     cout<<num[i];
                }
                cout<<endl;
            }
            else
                cout<<"-1"<<endl;
        }
        else
            cout<<"-1"<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t; cin>>t;
    while(t--)
    {
        int n,i; cin>>n;
        string s; cin>>s;
        vector <int> num(n);
        for(i=0; i<n; ++i)
        {
        num[i]=s[i]-'0';
        }
        int cnt=0;
        vector <int> vec;
        for(i=0; i<(int)num.size(); ++i)
        {
            if(num[i]%2!=0)
            {
                vec.push_back(num[i]);
                cnt++;
                if(cnt==2)
                    break;
            }
        }
        if(cnt!=2)
            cout<<"-1"<<endl;
        else
        {
            cout<<vec[0]<<vec[1]<<endl;
        }
        vec.clear();
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t; cin>>t;
    while(t--)
    {
        int n,i; cin>>n;
        string s; cin>>s;
        vector <int> num(n);
        for(i=0; i<n; ++i)
        {
        num[i]=s[i]-'0';
        }
        int cnt=0;
        for(i=0; i<(int)num.size(); ++i)
        {
            if(num[i]%2!=0)
            {
                cout<<num[i];
                cnt++;
                if(cnt==2)
                    break;
            }
        }
        if(cnt!=2)
            cout<<"-1"<<endl;
        else
            cout<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t; cin>>t;
    while(t--)
    {
        int n,i; cin>>n;
        string s; cin>>s;
        vector <int> num(n);
        for(i=0; i<n; ++i)
        {
        num[i]=s[i]-'0';
        }
        if(num.size()==1)
        {
           cout<<"-1"<<endl;
           continue;
        }
        while(*(num.end()-1)%2==0)
        {
            auto it=num.end()-1;
            num.erase(it);
        }
        long long sum=0;
        if(num.size()!=0)
        {
            for(i=0; i<n; ++i) sum+=num[i];
            while((sum%2)!=0)
            {
                sum-=*num.begin();
                num.erase(num.begin());

            }
            if(num.size()!=0)
            {
                for(i=0; i<(int)num.size(); ++i)
                {   if(num[i]!=0)
                     cout<<num[i];
                }
                cout<<endl;
            }
            else
                cout<<"-1"<<endl;
        }
        else
            cout<<"-1"<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t; cin>>t;
    while(t--)
    {
        int n,i; cin>>n;
        string s; cin>>s;
        vector <int> num(n);
        for(i=0; i<n; ++i)
        {
        num[i]=s[i]-'0';
        }
        if(num.size()==1)
        {
            if(num[0]%2==0)
             cout<<num[0]<<endl;
            else
             cout<<"-1"<<endl;

            continue;
        }
        while(*(num.end()-1)%2==0)
        {
            auto it=num.end()-1;
            num.erase(it);
        }
        long long sum=0;
        if(num.size()!=0)
        {
            for(i=0; i<n; ++i) sum+=num[i];
            while((sum%2)!=0)
            {
                sum-=*num.begin();
                num.erase(num.begin());

            }
            if(num.size()!=0)
            {
                for(i=0; i<(int)num.size(); ++i)
                {   if(num[i]!=0)
                     cout<<num[i];
                }
                cout<<endl;
            }
            else
                cout<<"-1"<<endl;
        }
        else
            cout<<"-1"<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t; cin>>t;
    while(t--)
    {
        int n,i; cin>>n;
        string s; cin>>s;
        vector <int> num(n);
        for(i=0; i<n; ++i)
        {
        num[i]=s[i]-'0';
        }
        while(*(num.end()-1)%2==0)
        {
            auto it=num.end()-1;
            num.erase(it);
        }
        long long sum=0;
        if(num.size()!=0)
        {
            for(i=0; i<n; ++i) sum+=num[i];
            while((sum%2)!=0)
            {
                sum-=*num.begin();
                num.erase(num.begin());

            }
            if(num.size()!=0)
            {
                for(i=0; i<(int)num.size(); ++i)
                {   if(num[i]!=0)
                     cout<<num[i];
                }
                cout<<endl;
            }
            else
                cout<<"-1"<<endl;
        }
        else
            cout<<"-1"<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t; cin>>t;
    while(t--)
    {
        int n,i; cin>>n;
        string s; cin>>s;
        vector <int> num(n);
        for(i=0; i<n; ++i)
        {
        num[i]=s[i]-'0';
        }
        while(*(num.end()-1)%2==0)
        {
            auto it=num.end()-1;
            num.erase(it);
        }
        long long sum=0;
        if(num.size()!=0)
        {
            for(i=0; i<n; ++i) sum+=num[i];
            while((sum%2)!=0)
            {
                sum-=*num.begin();
                num.erase(num.begin());

            }
            if(num.size()!=0)
            {
                for(i=0; i<(int)num.size(); ++i) cout<<num[i];
                cout<<endl;
            }
            else
                cout<<"-1"<<endl;
        }
        else
            cout<<"-1"<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t; cin>>t;
    while(t--)
    {
        int n,i; cin>>n;
        string s; cin>>s;
        vector <int> num(n);
        for(i=0; i<n; ++i)
        {
        num[i]=s[i]-'0';
        }
        if(num.size()==1)
        {
            if(num[0]%2!=0)
             cout<<num[0]<<endl;
            else
             cout<<"-1"<<endl;

            continue;
        }
        while(*(num.end()-1)%2==0)
        {
            auto it=num.end()-1;
            num.erase(it);
        }
        long long sum=0;
        if(num.size()!=0)
        {
            for(i=0; i<n; ++i) sum+=num[i];
            while((sum%2)!=0)
            {
                sum-=*num.begin();
                num.erase(num.begin());

            }
            if(num.size()!=0)
            {
                for(i=0; i<(int)num.size(); ++i)
                {   if(num[i]!=0)
                     cout<<num[i];
                }
                cout<<endl;
            }
            else
                cout<<"-1"<<endl;
        }
        else
            cout<<"-1"<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define ull unsigned long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t; cin>>t;
    while(t--)
    {
        ull n,i; cin>>n;
        string s; cin>>s;
        vector <int> num(n);
        for(i=0; i<n; ++i)
        {
        num[i]=s[i]-'0';
        }
        for(i=0; i<n; ++i) cout<<num[i];
        cout<<endl;
        while(*(num.end()-1)%2==0)
        {
            auto it=num.end()-1;
            num.erase(it);
        }
        long long sum=0;
        if(num.size()!=0)
        {
            for(i=0; i<n; ++i) sum+=num[i];
            while((sum%2)!=0)
            {
                sum-=*num.begin();
                num.erase(num.begin());

            }
            if(num.size()!=0)
            {
                for(i=0; i<num.size(); ++i) cout<<num[i];
                cout<<endl;
            }
            else
                cout<<"-1"<<endl;
        }
        else
            cout<<"-1"<<endl;
    }
    return 0;
}


#pragma  warning (disable:4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<utility>
#include<iomanip>
#include<set>
using  namespace std;
typedef long long ll;

int main()
{
	int t,n,sum;
	char a[5001];
	cin >> t;
	for (int i = 0; i < t; i++)
	{
		cin >> n; sum = 0;
		for (int j = 0; j < n; j++)
		{
			cin >> a[j];
			sum += a[j]-'0';
		}
		if (sum % 2 == 0 && a[n - 1] % 2 != 0)
		{
			for (int j = 0; j < n; j++)
				cout << a[j];
			cout << endl;
		}
		if (sum % 2 == 0 && a[n-1] % 2 == 0)
		{
			int s = 0;
			for (int j = 0; j < n; j++)
			{
				if ((a[j] - '0') % 2 == 1)
					s++;
			}
			if (s == 0) cout << -1 << endl;
			else
			{
				for (int j = 0; j < n; j++)
				{
					cout << a[j];
					if ((a[j] - '0') % 2 != 0) s--;
					if (s == 0) break;
				}
				cout << endl;
			}
		}
		if (sum % 2 != 0 && a[n-1]% 2 == 0)
		{
			int s = 0;
			for (int j = 0; j < n; j++)
			{
				if ((a[j] - '0') % 2 != 0)
					s++;
			}
			if (s == 1) cout << -1 << endl;
			else
			{
				for (int j = 0; j < n; j++)
				{
					cout << a[j];
					if ((a[j] - '0') % 2 != 0) s--;
					if (s == 1) break;
				}
				cout << endl;
			}
		}
		if (sum % 2 != 0 && a[n-1] % 2 != 0)
		{
			int flag = 1;
			for (int j = 0; j < n-1; j++)
			{
				if ((a[j]-'0' )% 2 == 1 && flag == 1)
				{
					flag = 0;
					a[j] ='a';
				}
			}
			if (flag == 1) cout << "-1" << endl;
			else
			{
				for (int j = 0; j < n ; j++)
				{
					if (a[j] == 'a') continue;
					cout << a[j];
				}
				cout << endl;
			}
		}
	}
}


#pragma  warning (disable:4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<utility>
#include<iomanip>
#include<set>
using  namespace std;
typedef long long ll;

int main()
{
	int t,n,sum,sum1;
	char a[5001];
	cin >> t;
	for (int i = 0; i < t; i++)
	{
		cin >> n; sum = 0; sum1 = 0;
		for (int j = 0; j < n; j++)
		{
			cin >> a[j];
			sum1 *= 10;
			sum += a[j]-'0';
			sum1 += a[j]-'0';
		}
		if (sum % 2 == 0 && sum1 % 2 != 0) cout << sum1 << endl;
		if (sum % 2 == 0 && sum1 % 2 == 0)
		{
			int s = 0;
			for (int j = 0; j < n; j++)
			{
				if (a[j] % 2 == 1)
					s++;
			}
			if (s == 0) cout << -1 << endl;
			else
			{
				for (int j = 0; j < n; j++)
				{
					cout << a[j];
					if (a[j] % 2 != 0) s--;
					if (s == 0) break;
				}
				cout << endl;
			}
		}
		if (sum % 2 != 0 && sum1 % 2 == 0)
		{
			int flag = 1;
			for (int j = 0; j < n; j++)
			{
				if ((a[j]-'0') % 2 == 1 && flag == 1)
				{
					flag = 0;
					continue;
				}
				cout << a[j];
			}
			cout << endl;
		}
		if (sum % 2 != 0 && sum1 % 2 != 0)
		{
			int flag = 1;
			for (int j = 0; j < n-1; j++)
			{
				if ((a[j]-'0' )% 2 == 1 && flag == 1)
				{
					flag = 0;
					a[j] ='a';
				}
			}
			if (flag == 1) cout << "-1" << endl;
			else
			{
				for (int j = 0; j < n ; j++)
				{
					if (a[j] == 'a') continue;
					cout << a[j];
				}
				cout << endl;
			}
		}
	}
}


#pragma  warning (disable:4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<utility>
#include<iomanip>
#include<set>
using  namespace std;
typedef long long ll;

int main()
{
	int t,n,sum;
	char a[5001];
	cin >> t;
	for (int i = 0; i < t; i++)
	{
		cin >> n; sum = 0;
		for (int j = 0; j < n; j++)
		{
			cin >> a[j];
			sum += a[j]-'0';
		}
		if (sum % 2 == 0 && a[n - 1] % 2 != 0)
		{
			for (int j = 0; j < n; j++)
				cout << a[j];
			cout << endl;
		}
		if (sum % 2 == 0 && a[n-1] % 2 == 0)
		{
			int s = 0;
			for (int j = 0; j < n; j++)
			{
				if ((a[j] - '0') % 2 == 1)
					s++;
			}
			if (s == 0) cout << -1 << endl;
			else
			{
				for (int j = 0; j < n; j++)
				{

					cout << a[j];
					if ((a[j] - '0') % 2 != 0) s--;
					if (s == 0) break;
				}
				cout << endl;
			}
		}
		if (sum % 2 != 0 && a[n-1]% 2 == 0)
		{
			int s = 0;
			for (int j = 0; j < n; j++)
			{
				if ((a[j] - '0') % 2 != 0)
					s++;
			}
			if (s == 1) cout << "-1" << endl;
			else
			{
				for (int j = 0; j < n; j++)
				{
					cout << a[j];
					if ((a[j] - '0') % 2 != 0) s--;
					if (s == 1) break;
				}
				cout << endl;
			}
		}
		if (sum % 2 != 0 && a[n-1] % 2 != 0)
		{
			int flag = 1;
			for (int j = n-2; j >=0; j--)
			{
				if ((a[j]-'0' )% 2 == 1 && flag == 1)
				{
					flag = 0;
					a[j] ='a';
				}
			}
			if (flag == 1) cout << "-1" << endl;
			else
			{
				for (int j = 0; j < n ; j++)
				{
					if (a[j] == 'a') continue;
					cout << a[j];
				}
				cout << endl;
			}
		}
	}
}


#pragma  warning (disable:4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<utility>
#include<iomanip>
#include<set>
using  namespace std;
typedef long long ll;

int main()
{
	int t,n,sum,sum1;
	char a[5001];
	cin >> t;
	for (int i = 0; i < t; i++)
	{
		cin >> n; sum = 0; sum1 = 0;
		for (int j = 0; j < n; j++)
		{
			cin >> a[j];
			sum1 *= 10;
			sum += a[j]-'0';
			sum1 += a[j]-'0';
		}
		if (sum % 2 == 0 && sum1 % 2 != 0) cout << sum1 << endl;
		if (sum % 2 == 0 && sum1 % 2 == 0)
		{
			int s = 0;
			for (int j = 0; j < n; j++)
			{
				if ((a[j] - '0') % 2 == 1)
					s++;
			}
			if (s == 0) cout << -1 << endl;
			else
			{
				for (int j = 0; j < n; j++)
				{
					cout << a[j];
					if ((a[j] - '0') % 2 != 0) s--;
					if (s == 0) break;
				}
				cout << endl;
			}
		}
		if (sum % 2 != 0 && sum1 % 2 == 0)
		{
			int s = 0;
			for (int j = 0; j < n; j++)
			{
				if ((a[j] - '0') % 2 != 0)
					s++;
			}
			if (s == 1) cout << -1 << endl;
			else
			{
				for (int j = 0; j < n; j++)
				{
					cout << a[j];
					if ((a[j] - '0') % 2 != 0) s--;
					if (s == 1) break;
				}
				cout << endl;
			}
		}
		if (sum % 2 != 0 && sum1 % 2 != 0)
		{
			int flag = 1;
			for (int j = 0; j < n-1; j++)
			{
				if ((a[j]-'0' )% 2 == 1 && flag == 1)
				{
					flag = 0;
					a[j] ='a';
				}
			}
			if (flag == 1) cout << "-1" << endl;
			else
			{
				for (int j = 0; j < n ; j++)
				{
					if (a[j] == 'a') continue;
					cout << a[j];
				}
				cout << endl;
			}
		}
	}
}


#pragma  warning (disable:4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<utility>
#include<iomanip>
#include<set>
using  namespace std;
typedef long long ll;

int main()
{
	int t,n,sum,sum1;
	char a[5001];
	cin >> t;
	for (int i = 0; i < t; i++)
	{
		cin >> n; sum = 0; sum1 = 0;
		for (int j = 0; j < n; j++)
		{
			cin >> a[j];
			sum1 *= 10;
			sum += a[j]-'0';
			sum1 += a[j]-'0';
		}
		if (sum % 2 == 0 && sum1 % 2 != 0) cout << sum1 << endl;
		if (sum % 2 == 0 && sum1 % 2 == 0)
		{
			int s = 0;
			for (int j = 0; j < n; j++)
			{
				if (a[j] % 2 == 1)
					s++;
			}
			if (s == 0) cout << -1 << endl;
			else
			{
				for (int j = 0; j < n; j++)
				{
					cout << a[j];
					if (a[j] % 2 != 0) s--;
					if (s == 0) break;
				}
				cout << endl;
			}
		}
		if (sum % 2 != 0 && sum1 % 2 == 0)
		{
			int flag = 1;
			for (int j = 0; j < n; j++)
			{
				if ((a[j]-'0') % 2 == 1 && flag == 1)
				{
					flag = 0;
					continue;
				}
				cout << a[j];
			}
			cout << endl;
		}
		if (sum % 2 != 0 && sum1 % 2 != 0)
		{
			int flag = 1;
			for (int j = 0; j < n; j++)
			{
				if ((a[j]-'0' )% 2 == 1 && flag == 1)
				{
					flag = 0;
					a[j] ='a';
				}
			}
			if (flag == 1) cout << "-1" << endl;
			else
			{
				for (int j = 0; j < n ; j++)
				{
					if (a[j] == 'a') continue;
					cout << a[j];
				}
				cout << endl;
			}
		}
	}
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<string.h>
#include<cstring>
#include<algorithm>
using namespace std;
int dp[3005];
int main() {
    ios::sync_with_stdio(false);
    string str;
    int t, n,sum;
    cin >> t;
    for (int o = 0; o < t; o++)
    {
        memset(dp, 0, 3005 * sizeof(int));
        sum = 0;
        cin >> n;
        cin >> str;
        if (n == 1) { cout << -1 << endl; continue; }
        for (int i = n-1; i >= 0; i--)
        {
            sum += str[i] - '0';//和
            if ((str[i] - '0') % 2 != 0)dp[i] = dp[i + 1] + 1;//在这个数之前的奇数个数（含自身）
            else dp[i] = dp[i+1];
        }
        if (sum % 2 == 0)//和为偶数
        {
            if (dp[n-1]==1)cout << str << endl;//个位奇数
            else {//删去若干个偶数 或 2k个奇数
                int pos = 0;
                for (; pos < n; pos++)
                {
                    if (dp[pos] % 2 != 0 && (str[pos] - '0') % 2 != 0)break;
                }
                if (pos == n)cout << -1<<endl;
                else {
                    for (int j = 0; j <= pos; j++)
                    {
                        cout << str[j];
                    }
                    cout << endl;
                }
            }
        }
        else {//和为奇数，需要删除2k+1个奇数 和 任意偶数
            int pos = 0;
            for (; pos < n; pos++)
            {
                if (dp[pos] % 2 == 0 && (str[pos] - '0') % 2 != 0)break;
            }
            if (pos == n)cout << -1<<endl;
            else {
                for (int j = 0; j <= pos; j++)
                {
                    cout << str[j];
                }
                cout << endl;
            }
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<string.h>
#include<cstring>
#include<string>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int dp[3005];
int main() {
    ios::sync_with_stdio(false);
    string str;
    int t, n,sum;
    cin >> t;
    for (int o = 0; o < t; o++)
    {
        memset(dp, 0, 3005 * sizeof(int));
        sum = 0;
        cin >> n;
        cin >> str;
        if (n == 1) { cout << -1 << endl; continue; }
        for (int i = n-1; i >= 0; i--)
        {
            sum += str[i] - '0';//和
            if ((str[i] - '0') % 2 != 0)dp[i] = dp[i + 1] + 1;//在这个数之前的奇数个数（含自身）
            else dp[i] = dp[i+1];
        }
        if (sum % 2 == 0)//和为偶数
        {
            if (dp[n-1]==1)cout << str << endl;//个位奇数
            else {//删去若干个偶数 或 2k个奇数
                int pos = 0;
                for (; pos < n; pos++)
                {
                    if (dp[pos] % 2 != 0 && (str[pos] - '0') % 2 != 0)break;
                }
                if (pos == n)cout << -1<<endl;
                else {
                    for (int j = 0; j <= pos; j++)
                    {
                        cout << str[j];
                    }
                    cout << endl;
                }
            }
        }
        else {//和为奇数，需要删除2k+1个奇数 和 任意偶数
            int pos = 0;
            for (; pos < n; pos++)
            {
                if (dp[pos] % 2 == 0 && (str[pos] - '0') % 2 != 0)break;
            }
            if (pos == n)cout << -1<<endl;
            else {
                for (int j = 0; j <= pos; j++)
                {
                    cout << str[j];
                }
                cout << endl;
            }
        }
    }
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<fstream>
#include<queue>
#include<iostream>
#include<unordered_map>
#include<math.h>
#include<stack>
#include <numeric>
#include<iomanip>
#include<unordered_set>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 3e5 + 5;
const int maxm = 305;
ll arr[maxn];
ll arr1[maxn];
ll sum[maxn];
ll index[maxn];
const ll mod = 1e9 + 7;
ll n, m, k, q, D, H, h, z, p;
string s1, s2;
int dirx[] = { 0,1,0,-1 };
int diry[] = { 1, 0, -1, 0 };
ll gcd(ll a, ll b)
{
	ll t;
	while (b)
	{
		t = a;
		a = b;
		b = t % b;
	}
	return a;
}
ll par[maxn];
void init() {
	for (int i = 0; i < maxn; i++)
		par[i] = i;
}
void init(int n) {
	for (int i = 0; i < n + 10; i++)
		par[i] = i;
}
ll find(int i) {
	if (par[i] != i) {
		return par[i] = find(par[i]);
	}
	else
		return i;
}
void merge(int x, int y) {
	par[find(x)] = par[find(y)];
}
ll presum[100];
bool isVowel(char c) {
	if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
		return true;
	else
		return false;
};

vector<int> get_pi(const string s) {
	int n = s.length();
	vector<int> pi(n);
	int k = 0;
	for (int i = 1; i < n; i++) {
		while (k > 0 && s[i] != s[k])
			k = pi[k - 1];
		if (s[i] == s[k])
			k++;
		pi[i] = k;
	}
	return pi;
}

int lowbit(int x) {
	return x & (-x);
}

void update(int x, int delta) {
	while (x <= n) {
		sum[x] += delta;
		x += lowbit(x);
	}
}

int query(int x) {
	int ans = 0;
	while (x > 0) {
		ans += sum[x];
		x -= lowbit(x);
	}
	return ans;
}
ll a, b, c, d,k1,k2;
string s;
ll x, y, t;

int main() {
	cin >> t;
	while (t--) {
		cin >> n;
		cin >> s;
		int i = s.length() - 1;
		bool ok = true;
		while (i >= 0) {
			int x = s[i] - '0';
			if (x % 2 == 1) {
				break;
			}
			else {
				i--;
			}
		}
		if (i < 0) {
			cout << -1 << endl;
			continue;
		}
		int total = 0;
		for (int j = 0; j <= i; j++) {
			int x = s[j] - '0';
			total += x;
		}
		if (total % 2 == 0) {
			cout << s.substr(0, i + 1) << endl;
			continue;
		}
		else {
			int del = -1;
			for (int j = 0; j < i; j++) {
				int x = s[j] - '0';
				if (x % 2 == 1) {
					del = j;
					break;
				}
			}
			if (del == -1) {
				cout << -1 << endl;
			}
			else {
				for (int j = 0; j <= i; j++) {
					if (j != del) {
						cout << s[j];
					}
				}
				cout << endl;
			}
		}
	}

}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<fstream>
#include<queue>
#include<iostream>
#include<unordered_map>
#include<math.h>
#include<stack>
#include <numeric>
#include<iomanip>
#include<unordered_set>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 3e5 + 5;
const int maxm = 305;
ll arr[maxn];
ll arr1[maxn];
ll sum[maxn];
ll index[maxn];
const ll mod = 1e9 + 7;
ll n, m, k, q, D, H, h, z, p;
string s1, s2;
int dirx[] = { 0,1,0,-1 };
int diry[] = { 1, 0, -1, 0 };
ll gcd(ll a, ll b)
{
	ll t;
	while (b)
	{
		t = a;
		a = b;
		b = t % b;
	}
	return a;
}
ll par[maxn];
void init() {
	for (int i = 0; i < maxn; i++)
		par[i] = i;
}
void init(int n) {
	for (int i = 0; i < n + 10; i++)
		par[i] = i;
}
ll find(int i) {
	if (par[i] != i) {
		return par[i] = find(par[i]);
	}
	else
		return i;
}
void merge(int x, int y) {
	par[find(x)] = par[find(y)];
}
ll presum[100];
bool isVowel(char c) {
	if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
		return true;
	else
		return false;
};

vector<int> get_pi(const string s) {
	int n = s.length();
	vector<int> pi(n);
	int k = 0;
	for (int i = 1; i < n; i++) {
		while (k > 0 && s[i] != s[k])
			k = pi[k - 1];
		if (s[i] == s[k])
			k++;
		pi[i] = k;
	}
	return pi;
}

int lowbit(int x) {
	return x & (-x);
}

void update(int x, int delta) {
	while (x <= n) {
		sum[x] += delta;
		x += lowbit(x);
	}
}

int query(int x) {
	int ans = 0;
	while (x > 0) {
		ans += sum[x];
		x -= lowbit(x);
	}
	return ans;
}
ll a, b, c, d,k1,k2;
string s;
ll x, y, t;

int main() {
	cin >> t;
	while (t--) {
		cin >> n;
		cin >> s;
		int i = s.length() - 1;
		bool ok = true;
		while (i >= 0) {
			int x = s[i] - '0';
			if (x % 2 == 1) {
				break;
			}
			else {
				i--;
			}
		}
		if (i < 0) {
			cout << -1 << endl;
			continue;
		}
		int total = 0;
		for (int j = 0; j <= i; j++) {
			int x = s[j] - '0';
			total += x;
		}
		if (total % 2 == 0) {
			cout << s.substr(0, i + 1) << endl;
			continue;
		}
		else {
			int del = -1;
			for (int j = 0; j < i; j++) {
				int x = s[j] - '0';
				if (x % 2 == 1) {
					del = j;
					break;
				}
			}
			if (del == -1) {
				cout << -1 << endl;
			}
			else {
				bool start = true;
				for (int j = 0; j <= i; j++) {
					if (start&&s[j] == '0'||j==del) {
						continue;
					}
					start = false;
					if (j != del) {
						cout << s[j];
					}
				}
				cout << endl;
			}
		}
	}

}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <functional>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	int t;
	cin >> t;
	while (t--)
	{
		int n;
		string s;
		cin >> n >> s;
		int odd = 0;
		for (int i = 0; i < n; i++)
			if ((s[i] - '0') & 1)
				odd++;

		if (n == 1 || odd == 0 || odd == 1) //the nomber can't be eben
		{
			cout << -1 << endl;
			continue;
		}
		else if (!(odd & 1) && ((s[n - 1] - '0') & 1)) //the nomber is eben
		{
			cout << s << endl;
			continue;
		}
		else if (!(odd & 1) && !((s[n - 1] - '0') & 1))
		{
			for (int i = n - 1; !((s[i] - '0') & 1); i--)
				s.erase(i, i + 1);
		}
		else if ((odd & 1) && ((s[n - 1] - '0') & 1))
		{
			for (int i = 0; i < n; i++)
				if ((s[i] - '0') & 1)
				{
					s.erase(i, i + 1);
					break;
				}
		}
		else
		{
			for (int i = n - 1; !((s[i] - '0') & 1); i--)
				s.erase(i, i + 1);

			for (int i = 0; i < n; i++)
				if ((s[i] - '0') & 1)
				{
					s.erase(i, i + 1);
					break;
				}
		}
		while (s[0] == '0')
			s.erase(0, 1);
		cout << s << endl;
	}
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <functional>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	int t;
	cin >> t;
	while (t--)
	{
		int n;
		string s;
		cin >> n >> s;
		int odd = 0;
		for (int i = 0; i < n; i++)
			if ((s[i] - '0') & 1)
				odd++;

		if (n == 1 || odd == 0 || odd == 1)
		{
			cout << -1 << endl;
			continue;
		}
		else if (!(odd & 1) && ((s[n - 1] - '0') & 1))
		{
			cout << s << endl;
			continue;
		}
		else if (!(odd & 1))
		{
			for (int i = n - 1;; i--)
			{
				if ((s[i] - '0') & 1) break;
				s.erase(i, i + 1);
			}
		}
		else if ((odd & 1) && ((s[n - 1] - '0') & 1))
		{
			for (int i = 0; i < n; i++)
				if ((s[i] - '0') & 1)
				{
					s.erase(i, i + 1);
					break;
				}
		}
		else
		{
			for (int i = n - 1;; i--)
			{
				if ((s[i] - '0') & 1) break;
				s.erase(i, i + 1);
			}
			for (int i = 0; i < n; i++)
				if ((s[i] - '0') & 1)
				{
					s.erase(i, i + 1);
					break;
				}
		}
		while (s[0] == '0')
			s.erase(0, 1);
		cout << s << endl;
	}
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <functional>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	int t;
	cin >> t;
	while (t--)
	{
		int n;
		string s;
		cin >> n >> s;
		int odd = 0;
		for (int i = 0; i < n; i++)
			if ((s[i] - '0') & 1)
				odd++;

		if (odd == 0 || odd == 1)
			cout << -1 << endl;

		else if (!(odd & 1) && ((s[n - 1] - '0') & 1))
			cout << s << endl;

		else if (!(odd & 1))
		{
			for (int i = n - 1;; i--)
			{
				if ((s[i] - '0') & 1) break;
				s.erase(i, i + 1);
			}
			cout << s << endl;
		}
		else if ((odd & 1) && ((s[n - 1] - '0') & 1))
		{
			for (int i = 0; i < n; i++)
				if ((s[i] - '0') & 1)
				{
					s.erase(i, i + 1);
					break;
				}
			if (s[0] == '0')
				s.erase(0, 1);
			cout << s << endl;
		}
		else
		{
			for (int i = n - 1;; i--)
			{
				if ((s[i] - '0') & 1) break;
				s.erase(i, i + 1);
			}
			for (int i = 0; i < n; i++)
				if ((s[i] - '0') & 1)
				{
					s.erase(i, i + 1);
					break;
				}
			if (s[0] == '0')
				s.erase(0, 1);
			cout << s << endl;
		}
	}
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <functional>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	int t;
	cin >> t;
	while (t--)
	{
		int n, cnt = 0;
		string s, ans = "";
		cin >> n >> s;
		for (int i = 0; i < n && cnt < 2; i++)
			if ((s[i] - '0') & 1)
				ans += s[i], cnt++;
		(cnt == 2) ? cout << ans << '\n' : cout << -1 << '\n';
	}
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <functional>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	int t;
	cin >> t;
	while (t--)
	{
		int n;
		string s;
		cin >> n >> s;
		int odd = 0;
		for (int i = 0; i < n; i++)
			if ((s[i] - '0') & 1)
				odd++;

		if (n == 1 || odd == 0 || odd == 1)
			cout << -1 << endl;

		else if (!(odd & 1) && ((s[n - 1] - '0') & 1))
			cout << s << endl;

		else if (!(odd & 1))
		{
			for (int i = n - 1;; i--)
			{
				if ((s[i] - '0') & 1) break;
				s.erase(i, i + 1);
			}
			cout << s << endl;
		}
		else if ((odd & 1) && ((s[n - 1] - '0') & 1))
		{
			for (int i = 0; i < n; i++)
				if ((s[i] - '0') & 1)
				{
					s.erase(i, i + 1);
					break;
				}
			if (s[0] == '0')
				s.erase(0, 1);
			cout << s << endl;
		}
		else
		{
			for (int i = n - 1;; i--)
			{
				if ((s[i] - '0') & 1) break;
				s.erase(i, i + 1);
			}
			for (int i = 0; i < n; i++)
				if ((s[i] - '0') & 1)
				{
					s.erase(i, i + 1);
					break;
				}
			if (s[0] == '0')
				s.erase(0, 1);
			cout << s << endl;
		}
	}
}


#include<bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;

const int N = 500 * 1000 * 10, MASK = (1 << 22) + 10, inf = 1e9;
int n, dp[MASK], sz[N], st[N], en[N], Xor[N], h[N], ver[N], ans[N], timee;
vector<int> adj[N];

void dfs(int v) {
	ver[timee] = v;
	st[v] = timee++;
	sz[v] = 1;
	for (auto u: adj[v]) {
		dfs(u);
		sz[v] += sz[u];
	}
	en[v] = timee;
}

void dfs_sack(int v, bool keep = false) {
	int mx = -1, Bigchild = -1;
	for (auto u: adj[v])
		if (sz[u] > mx) {
			mx = sz[u];
			Bigchild = u;
		}
	for (auto u: adj[v])
		if (u ^ Bigchild)
			dfs_sack(u, 0);
	if (~Bigchild)
		dfs_sack(Bigchild, 1);
	for (auto u: adj[v])
		if (u ^ Bigchild) {
			for (int i = st[u]; i < en[u]; i++) {
				for (int j = 0; j < 22; j++)
					ans[v] = max(ans[v], h[i] + dp[Xor[v] ^ Xor[i] ^ (1 << j)] - 2 * h[v]);
				ans[v] = max(ans[v], h[i] + dp[Xor[v] ^ Xor[i]] - 2 * h[v]);
				dp[Xor[i]] = max(dp[Xor[i]], h[i]);
			}
		}
	for (int j = 0; j < 22; j++)
		ans[v] = max(ans[v], dp[Xor[v] ^ (1 << j)] - h[v]);
	ans[v] = max(ans[v], dp[Xor[v]] - h[v]);
	dp[Xor[v]] = max(dp[Xor[v]], h[v]);
	if (!keep)
		for (int i = st[v]; i < en[v]; i++)
			dp[Xor[ver[i]]] = -inf;

}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i < n; i++) {
		int p;
		char c;
		cin >> p >> c;
		h[i] = h[--p] + 1;
		Xor[i] = Xor[p] ^ (1 << (c - 'a'));
		adj[p].push_back(i);
	}
	fill(dp, dp + MASK, -inf);
	dfs(0);
	dfs_sack(0);
	for (int i = 0; i < n; i++)
		cout << ans[i] << " ";
	return cout << "\n", 0;
}