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

int main()
{

    ios_base::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--)
    {
        long long int ar[150];
        memset(ar,0,sizeof(ar));
        string s1,s2;
        cin>>s1;
        int i=0,k;
        while(s1[i]!='\0')
        {
            k=s1[i];
            ar[k]++;
            i++;
        }
        for(i=97;i<=125;i++)
        {
            if(ar[i]!=0 && ar[i]%2!=0)
            {
                char c=i;
                cout<<c;
            }
        }
        cout<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
#include <cstring>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int q;
    cin>>q;
    while (q--){
        string s,t;
        cin>>s;
        int a[26]={0};
        int c=0;
        for (int i=0;i<s.length()-1;i++){
            if (i==s.length()-1||s[i]!=s[i+1]){
                c++;
                if (c%2)
                    a[s[i]-'a']=1;
                c=0;
            }
            else
                c++;
        }
        if (s.size()>1&&s[s.length()-2]!=s.back()){
            a[s.back()-'a']=1;
        }
        for (int i=0;i<26;i++)
        {
            if (a[i]){
                t+=((char)(i+'a'));
            }
        }
        cout<<t<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#include <cstring>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int q;
    cin>>q;
    while (q--){
        string s,t;
        cin>>s;
        int a[26]={0};
        int c=0;
        for (int i=0;i<s.length();i++){
            if (i==s.length()-1||s[i]!=s[i+1]){
                c++;
                if (c%2)
                    a[s[i]-'a']=1;
                c=0;
            }
            else
                c++;
        }
        if (s.size()>1&&s[s.length()-2]!=s.back()){
            a[s.back()-'a']=1;
        }
        for (int i=0;i<26;i++)
        {
            if (a[i]){
                t+=((char)(i+'a'));
            }
        }
        cout<<t<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#include <cstring>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int q;
    cin>>q;
    while (q--){
        string s,t;
        cin>>s;
        int a[26]={0};
        int c=0;
        for (int i=0;i<s.length()-1;i++){
            if (s[i]!=s[i+1]){
                c++;
                if (c%2)
                    a[s[i]-'a']=1;
                c=0;
            }
            else
                c++;
        }
        if (s[s.length()-2]!=s.back()){
            a[s.back()-'a']=1;
        }
        for (int i=0;i<26;i++)
        {
            if (a[i]){
                t+=((char)(i+'a'));
            }
        }
        cout<<t<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#include <cstring>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int q;
    cin>>q;
    while (q--){
        string s,t;
        cin>>s;
        int a[26]={0};
        for (int i=0;i<s.length();i++){
            a[s[i]-'a']++;
        }
        for (int i=0;i<26;i++)
        if (a[i]%2){
            t+=(char('a'+i));
        }
        cout<<t<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#include <cstring>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int q;
    cin>>q;
    while (q--){
        string s,t;
        cin>>s;
        int a[26]={0};
        int c=0;
        for (int i=0;i<s.length()-1;i++){
            if (i==s.length()-1||s[i]!=s[i+1]){
                c++;
                if (c%2)
                    a[s[i]-'a']=1;
                c=0;
            }
            else
                c++;
        }
        if (s.size()>1&&s[s.length()-2]!=s.back()){
            a[s.back()-'a']=1;
        }
        if (s.size()==1)
            a[s.back()-'a']=1;
        for (int i=0;i<26;i++)
        {
            if (a[i]){
                t+=((char)(i+'a'));
            }
        }
        cout<<t<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
ll n,t ;
int main()
{

    /// freopen("output.txt", "w+", stdout);
    cin>>t;

    while(t--){

    	 string s;
    	 cin>>s;
    	 map<char,ll>m;
    	 for(int i=0; i<s.size() ; i++){

    	 	 m[s[i]]++;
    	 }
    	 for(auto it:m){

    	 	if(it.second%2){
    	 		cout<<(char)it.first;
    	 	}
    	 }
    	 cout<<endl;
    }

  return 0;
}

///author-joydip007x         ///
///Time&Date-Whenever i submit///


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
ll n,t ;
int main()
{

    cin>>t;

    while(t--){

    	 string s;
    	 cin>>s;
    	 for(int i='a' ;i <='z' ; i++){

             if(s.find(i)==string::npos) continue;

             int l=0;
             if(s[0]==i){

             	  int ind=1;
             	  while(ind<s.size() && s[ind]==i)ind++;
             	  if(ind%2) l=1;
             }
             if(s.back()==i){

             	int ind=s.size()-2;
             	int cnt=0;
             	while(ind!=-1 && s[ind]==i) ind--,cnt++;
             	if(cnt%2==0) l=1;
             }
             for(int j=1; j+1<s.size();j++){

             	if( s[j]==i && s[j]!=s[j-1] && s[j]!=s[j+1]){

             		l=1;break;
             	}
             }
             if(l)
             	cout<<char(i);
    	 }
    	 cout<<endl;

    }

  return 0;
}

///author-joydip007x         ///
///Time&Date-Whenever i submit///


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
ll n,t ;
int main()
{

    cin>>t;
    while(t--){

    	 string s;
    	 cin>>s;
    	 for(int i='a' ;i <='z' ; i++){

             if(s.find(i)==string::npos) continue;
             int l=0;
             if(s[0]==i){

             	  int ind=1;
             	  while(ind<s.size() && s[ind]==i)ind++;
             	  if(ind%2) l=1;
             }
             if(s.back()==i){

             	int ind=s.size()-2;
             	int cnt=1;
             	while(ind!=-1 && s[ind]==i) ind--,cnt++;
             	if(cnt%2) l=1;
             }
             int cnt=0;
             for(int j=0; j+1<s.size();j++){

             	if( s[j]==i && s[j]==s[j+1] ){
             		cnt++;
             	}
             	else{

                    if(cnt%2==0 && cnt>0) l=1;
             		cnt=0;
             	}
             }
              for(int j=1; j+1<s.size();j++){

             	if( s[j]==i && s[j]!=s[j-1] && s[j]!=s[j+1]){

             		l=1;
             		break;
             	}
             }
             if(l)cout<<char(i);
    	 }
    	 cout<<endl;

    }

  return 0;
}

///author-joydip007x         ///
///Time&Date-Whenever i submit///


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
ll n,t ;
int main()
{

    /// freopen("output.txt", "w+", stdout);
    cin>>t;

    while(t--){

    	 string s;
    	 cin>>s;
    	 for(int i='a' ;i <='z' ; i++){

              if(s.find(i)==string::npos)continue;
              string x;x.pb(char(i));x.pb(x.back());

              if(s.find(x)==string::npos){
              	cout<<char(i);
              }

    	 }
    	 cout<<endl;

    }

  return 0;
}

///author-joydip007x         ///
///Time&Date-Whenever i submit///


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
ll n,t ;
int main()
{

    cin>>t;

    while(t--){

    	 string s;
    	 cin>>s;
    	 for(int i='a' ;i <='z' ; i++){

             int l=0;
             if(s[0]==i){

             	  int ind=1;
             	  while(ind<s.size() && s[ind]==i)ind++;
             	  if(ind%2) l=1;
             }
             if(s.back()==i){

             	int ind=s.size()-2;
             	int cnt=1;
             	while(ind!=-1 && s[ind]==i) ind--,cnt++;
             	if(cnt%2) l=1;
             }
             for(int j=1; j+1<s.size();j++){

             	if( s[j]==i && s[j]!=s[j-1] && s[j]!=s[j+1]){

             		l=1;
             		break;
             	}
             }
             if(l)cout<<char(i);
    	 }
    	 cout<<endl;

    }

  return 0;
}

///author-joydip007x         ///
///Time&Date-Whenever i submit///


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;

    cin >> n;

    string letters;

    vector<char> S;

    for (int i = 0; i < n; i++) {
        cin >> letters;

        if (letters.length() == 1) {
            cout << letters << endl;
            continue;
        }

        int c = 0;
        for (c = 0; c < letters.length()-1; c++) {
           if (letters[c] == letters[c + 1]) {
               c++;
           } else {
               S.push_back(letters[c]);
           }
        }
        if (c == letters.length() - 1) {
            S.push_back(letters.back());
        }

        sort(S.begin(), S.end());

        int k = -1;

        for (int j = 0; j < S.size(); j++) {
            if (j == 0 || S[k] != S[j]) {
                k++;
            } else {
                while (j < S.size() && S[k] == S[j]) {
                    j++;
                }
                if (j < S.size()) {
                    swap(S[k++], S[j]);
                }

            }
        }

        S.resize(k  +1 );

        for (auto &x : S) {
            cout << x;
        }

        cout << endl;
        S.clear();

    }

    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, last = 0;
    string letters;

    cin >> n;

    vector<char> S;

    for (int i = 0; i < n; i++) {
        cin >> letters;

        letters += ' ';

        for (int j = 0; j < letters.length() - 1; j++) {
            if (letters[j] == letters[j + 1]) {
                j++;
            } else {
                S.push_back(letters[j]);
            }
        }

        sort(S.begin() + last, S.end());

        for (int j = last; j < S.size(); j++) {
            if (j == last || S[last] != S[j]) {
                cout << S[j];
                last = j;
            }
        }

        cout << endl;
        last++;
    }

    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, last = 0;
    string letters;

    cin >> n;

    vector<char> S;

    for (int i = 0; i < n; i++) {
        cin >> letters;

        letters += ' ';

        for (int j = 0; j < letters.length() - 1; j++) {
            if (letters[j] == letters[j + 1]) {
                j++;
            } else {
                S.push_back(letters[j]);
            }
        }

        sort(S.begin(), S.end());

        for (int j = 0; j < S.size(); j++) {
            if (j == 0 || S[last] != S[j]) {
                cout << S[j];
                last = j;
            }
        }

        cout << endl;
        S.clear();

    }

    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;

    cin >> n;

    string letters;

    vector<char> S;

    for (int i = 0; i < n; i++) {
        cin >> letters;

        if (letters.length() > 1) {

        for (int j = 0; j < letters.length()-1; j++) {
           if (letters[j] == letters[j + 1]) {
               j++;
           } else {
               S.push_back(letters[j]);
           }
        }
        if (letters[letters.length() - 2] != letters[letters.length() - 1]) {
            S.push_back(letters.back());
        }

        sort(S.begin(), S.end());

        int k = -1;

        for (int j = 0; j < S.size(); j++) {
            if (j == 0 || S[k] != S[j]) {
                cout << S[j];
                k++;
            } else {
                while (j < S.size() && S[k] == S[j]) {
                    j++;
                }
                j--;
            }
        }

        cout << endl;
        S.clear();
        } else {
            cout << letters << endl;
        }

    }

    return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;

    cin >> n;

    string letters;

    for (int i = 0; i < n; i++) {
        int chars[26] = { 0 };
        cin >> letters;

        for (auto &l : letters) {
            chars[l - 'a']++;
        }

        for (int j = 0; j < 26; j++) {
            if (chars[j] && chars[j] & 1) {
                cout << (char)(j + 'a');
            }
        }
        cout << endl;
    }

    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;

    cin >> n;

    string letters;

    vector<char> S;

    for (int i = 0; i < n; i++) {
        cin >> letters;

        if (letters.length() == 1) {
            cout << letters << endl;
            continue;
        }

        int c = 0;
        for (c = 0; c < letters.length()-1; c++) {
           if (letters[c] == letters[c + 1]) {
               c++;
           } else {
               S.push_back(letters[c]);
           }
        }
        if (c == letters.length() - 1) {
            S.push_back(letters.back());
        }

        sort(S.begin(), S.end());

        int k = -1;

        for (int j = 0; j < S.size(); j++) {
            if (j == 0) {
                k++;
            } else if (S[k] == S[j]) {
                while (S[k] == S[j]) {
                    j++;
                }
                swap(S[k++], S[j]);
            }
        }

        for (auto &x : S) {
            cout << x;
        }

        cout << endl;
        S.clear();

    }

    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;

    cin >> n;

    string letters;

    vector<char> S;

    for (int i = 0; i < n; i++) {
        cin >> letters;

        if (letters.length() == 1) {
            cout << letters << endl;
            continue;
        }

        int c = 0;
        for (c = 0; c < letters.length()-1; c++) {
           if (letters[c] == letters[c + 1]) {
               c++;
           } else {
               S.push_back(letters[c]);
           }
        }
        if (c == letters.length() - 1) {
            S.push_back(letters.back());
        }

        sort(S.begin(), S.end());

        int last  = -1;

        for (int j = 0; j < S.size(); j++) {
            if (last >= 0 && S[j] == S[last]) {
                continue;
            } else {
                last++;
                S[last] = S[j];
            }
        }

        S.resize(last + 1 );

        for (auto &x : S) {
            cout << x;
        }

        cout << endl;
        S.clear();

    }

    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, last = 0;
    string letters;

    cin >> n;

    vector<char> S;

    for (int i = 0; i < n; i++) {
        cin >> letters;

        letters += ' ';

        for (int j = 0; j < letters.length() - 1; j++) {
            if (letters[j] == letters[j + 1]) {
                j++;
            } else {
                S.push_back(letters[j]);
            }
        }

        sort(S.begin(), S.end());

        for (int j = last; j < S.size(); j++) {
            if (j == last || S[last] != S[j]) {
                cout << S[j];
                last = j;
            }
        }

        cout << endl;
    }

    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    string letters;

    cin >> n;

    vector<char> S;

    for (int i = 0; i < n; i++) {
        cin >> letters;

        letters += ' ';

        for (int j = 0; j < letters.length() - 1; j++) {
            if (letters[j] == letters[j + 1]) {
                j++;
            } else {
                S.push_back(letters[j]);
            }
        }

        sort(S.begin(), S.end());

        int last = -1;

        for (int j = 0; j < S.size(); j++) {
            if (j == 0 || S[last] != S[j]) {
                cout << S[j];
                last = j;
            }
        }

        cout << endl;
        S.clear();

    }

    return 0;
}


#include <iostream>
using namespace std;
int main() {
  int n,k=0,a[26];
  cin>>n;
  string s;
  for(int q=1;q<=n;q++){
    cin>>s;
    for(int i=0;i<26;i++){
      a[i]=0;
    }
    for(int i=0;i<s.size();i++){
        k=i;
      while(s[k]==s[1+k] && k+1<s.size()){
          k++;
      }
      if((k-i)%2==0)a[s[i]-'a']=1;
      i=k;
    }
    for(int i=0;i<26;i++){
      if(a[i]>0)cout<<(char)('a'+i);
    }
    cout<<endl;
  }
  return 0;
}


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

void ans(string s)
{
    set<char>c;
    for(int i=0;i<s.lenght();i++){
        if(c.find(s[i])!=c.end()){
            c.insert(s[i]);
        }
        else{
            c.erase(s[i]);
        }
    }
    auto it=c.begin;
    for(;it!=c.end;it++){
        cout<<*it;
    }
    return;
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        ans(s);
    }
    return 0;
}


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

void ans(string s)
{
    int a[27]=0;
    for(int i=0;i<s.length();i++){
        a[s[i]-96]++;
    }
    int cnt=0;
    string res;
    for(int i=0;i<27;i++){
        if(a[i]%2==1){
            res+=char('a'+i-1);
        }
    }
    cout<<res<<endl;
    return;
}
int main()
{
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        string s;
        cin>>s;
        ans(s);
    }
    return 0;
}


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

                void ans(string s)
                {
                    set<char>c;
                    for(int i=0;i<s.length();i++){
                        if(c.find(s[i])!=c.end()){
                            c.insert(s[i]);
                        }
                        else{
                            c.erase(s[i]);
                        }
                    }
                    set<char>::iterator it=c.begin();
                    for(;it!=c.end();it++){
                        cout<<*it;
                    }
                    return;
                }
                int main()
                {
                    int n;
                    cin>>n;
                    for(int i=0;i<n;i++){
                        string s;
                        cin>>s;
                        ans(s);
                    }
                    return 0;
                }


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

    void ans(string s)
    {
        set<char>c;
        for(int i=0;i<s.length();i++){
            if(c.find(s[i])!=c.end()){
                c.insert(s[i]);
            }
            else{
                c.erase(s[i]);
            }
        }
        auto it=c.begin;
        for(;it!=c.end;it++){
            cout<<*it;
        }
        return;
    }
    int main()
    {
        int n;
        cin>>n;
        for(int i=0;i<n;i++){
            string s;
            cin>>s;
            ans(s);
        }
        return 0;
    }


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

        void ans(string s)
        {
            set<char>c;
            for(int i=0;i<s.length();i++){
                if(c.find(s[i])!=c.end()){
                    c.insert(s[i]);
                }
                else{
                    c.erase(s[i]);
                }
            }
            auto it=c.begin;
            for(;it!=c.end();it++){
                cout<<*it;
            }
            return;
        }
        int main()
        {
            int n;
            cin>>n;
            for(int i=0;i<n;i++){
                string s;
                cin>>s;
                ans(s);
            }
            return 0;
        }


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set_pll tree <pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree <ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//query 1 order_of_key (k) : Number of items strictly smaller than k .
//query 2 find_by_order(k) : K-th element in the set (counting from zero).
//less<ll> means query 1 will return numbers strictly less than k
//greater<ll> means query 1 will return numbers strictly greater than k
#define		pb				push_back
#define		pf				push_front
#define		MOD				1000000007
#define		popb			pop_back
#define		popf			pop_front
#define		len(x)			x.size()
#define		MAXN			100001
#define		mp				make_pair
#define		endl			'\n'
#define		ff				first
#define		ss				second
#define		tt				third
#define		mapcl			map<char,ll>
#define		mapll			map<ll,ll>
#define		cmp				complex<double>
#define		pi				3.141592653589793238462643383279502884197169399375105820974944592307816406286
#define		inf				LLONG_MAX
#define		flush			fflush(stdout)
#define		vll				vector<ll>
#define		all(v)			v.begin(),v.end()
#define		fr(i,z,n)		for(ll i=z;i<n;i++)
#define		sqrt			sqrtl
#define		cbrt			cbrtl
typedef		long long		ll;
typedef		pair<ll,ll>		pll;
typedef		long double		ld;
ll 			power(ll a,ll b,ll mod)			{if(b==0)return 1;ll tmp=power(a,b/2,mod);tmp=(tmp*tmp)%mod;if(b&1)tmp=(tmp*a)%mod;return tmp;}
bool		coll(pll p1,pll p2,pll p3)		{if((p3.ss-p2.ss)*(p2.ff-p1.ff)==(p2.ss-p1.ss)*(p3.ff-p2.ff))return true;else return false;}
void		print(auto x)					{cout<<x<<endl;}
void		pv(vector<auto> v)				{for(ll i=0;i<(ll)v.size();i++)cout<<v[i]<<" ";cout<<endl;}
void		pv1(vector<auto> v)				{for(ll i=1;i<(ll)v.size();i++)cout<<v[i]<<" ";cout<<endl;}
void		pset(set<auto> v)				{for(auto x:v)cout<<x<<" ";cout<<endl;}
void		pvsl(vector<auto> v)			{for(ll i=0;i<(ll)v.size();i++)cout<<v[i]<<" ";}
void		in(vector<auto> &v, ll n)		{v.resize(n);for(ll i=0;i<n;i++)cin>>v[i];}
void		in1(vector<auto> &v, ll n)		{v.resize(n+1);for(ll i=1;i<=n;i++)cin>>v[i];v[0]=0;}
void		sortv(auto &v)					{sort(v.begin(),v.end());}
void		fast()							{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
double		dist2d(pll a,pll b)				{ll x=abs(a.ff-b.ff);ll y=abs(a.ss-b.ss);return (sqrt((x*x)+(y*y)));}
//all variables and functions below this line
int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		string s;
		cin>>s;
		ll cnt=1;
		char tmp=s[0];
		set<char> ans;
		for(ll i=1;i<s.size();i++)
		{
			if(s[i]==tmp)
			{
				cnt++;
			}
			else
			{
				if(cnt&1)
				ans.insert(tmp);
				cnt=1;
				tmp=s[i];
			}
		}
		if(cnt&1)
		ans.insert(tmp);
		for(char x:ans)
		cout<<x;
		cout<<endl;
	}
}


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

void ans(string s)
{
    int arr[26]={0};
    for(int i=0;i<s.length();i++){
        arr[s[i]-97]++;
    }
    string t;
    for(int i=0;i<26;i++){
        if(arr[i]%2==1){
            t+=('a'+i);
        }
    }
    cout<<t;
}
int main()
{
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        string t;
        cin>>t;
        ans(t);
        cout<<endl;
    }
    return 0;
}


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

void ans(string s)
{
    set<char>c;
    c.insert(s[0]);
    for(int i=1;i<s.length();i++){
        if(c.find(s[i])!=c.end()){
            c.insert(s[i]);
        }
        else{
            c.erase(s[i]);
        }
    }
    set<char>::iterator it;
    for(it=c.begin();it!=c.end();it++){
        cout<<*it;
    }
    cout<<endl;
    return ;
}
int main()
{
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        string s;
        cin>>s;
        ans(s);
    }
    return 0;
}


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

    typedef long long ll;
    typedef unsigned long long ull;
    typedef long double ld;

    int main() {
    	ios_base::sync_with_stdio(false);
    	cin.tie(nullptr);
    	cout.tie(nullptr);
    	cerr.tie(nullptr);

    	int q;
    	cin >> q;
    	while (q--) {
    		string s;
    		cin >> s;
    		int n = s.size();
    		set<char> ok;
    		char last = 0;
    		int streak = 0;
    		for (int i=0; i<n; i++) {
    			if (s[i] == last)
    				streak++;
    			else {
    				if (streak % 2)
    					ok.insert(last);
    				streak = 1;
    				last = s[i];
    			}
    		}
    		if (streak % 2)
    			ok.insert(last);
    		for (char c : ok)
    			cout << c;
    		cout << '\n';
    	}
    }


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

void ans(string s)
{
    int a[27]={0};
    for(int i=0;i<s.length();i++){
        a[s[i]-96]++;
    }
    int cnt=0;
    string res;
    for(int i=0;i<27;i++){
        if(a[i]%2==1){
            res+=char('a'+i-1);
        }
    }
    cout<<res<<endl;
    return;
}
int main()
{
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        string s;
        cin>>s;
        ans(s);
    }
    return 0;
}


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

    void ans(string s)
    {
        set<char>c;
        c.insert(s[0]);
        for(int i=1;i<s.length();i++){
            if(c.find(s[i])==c.end()){
                c.insert(s[i]);
            }
            else{
                c.erase(s[i]);
            }
        }
        set<char>::iterator it;
        for(it=c.begin();it!=c.end();it++){
            cout<<*it;
        }
        cout<<endl;
        return ;
    }
    int main()
    {
        int t;
        cin>>t;
        for(int i=0;i<t;i++){
            string s;
            cin>>s;
            ans(s);
        }
        return 0;
    }


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

            void ans(string s)
            {
                set<char>c;
                for(int i=0;i<s.length();i++){
                    if(c.find(s[i])!=c.end()){
                        c.insert(s[i]);
                    }
                    else{
                        c.erase(s[i]);
                    }
                }
                set<char>::iterator it=c.begin;
                for(;it!=c.end();it++){
                    cout<<*it;
                }
                return;
            }
            int main()
            {
                int n;
                cin>>n;
                for(int i=0;i<n;i++){
                    string s;
                    cin>>s;
                    ans(s);
                }
                return 0;
            }


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

                    void ans(string s)
                    {
                        set<char>c;
                        for(int i=0;i<s.length();i++){
                            if(c.find(s[i])!=c.end()){
                                c.insert(s[i]);
                            }
                            else{
                                c.erase(s[i]);
                            }
                        }
                        set<char>::iterator it;
                        for(it=c.begin();it!=c.end();it++){
                            cout<<*it;
                        }
                        return;
                    }
                    int main()
                    {
                        int n;
                        cin>>n;
                        for(int i=0;i<n;i++){
                            string s;
                            cin>>s;
                            ans(s);
                        }
                        return 0;
                    }


#include <bits/stdc++.h>

using namespace std;

int main()
{
  int ques;
  string s, answer;
  cin >> ques;
  while(ques--)
  {
    cin >> s;
    int index = 0;
    //false means broken
    bool last_state = false;
    answer = "";
    if(s.length() == 1)
      answer = s;
    while(index < s.length() - 1)
    {
      if(s[index] == s[index + 1])
      {
        index = index + 2;
      }
      else
      {
        answer += s[index];
        if(index == s.length() - 2 )
        {
          last_state = true;
        }
        index++;
      }
      if(index == s.length() - 1)
        last_state = true;
    }
    if(last_state == true)
      answer += s[s.length() - 1];
    sort(answer.begin(), answer.end());
    cout << answer << endl;

  }
  return 0;
}


#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
  int ques;
  string s, answer;
  cin >> ques;
  while(ques--)
  {
    cin >> s;
    int index = 0;
    //false means broken
    bool last_state = false;
    answer = "";
    if(s.length() == 1)
      answer = s;
    while(index < s.length() - 1)
    {
      if(s[index] == s[index + 1])
      {
        index = index + 2;
      }
      else
      {
        if(answer.find(s[index]) == -1)
          answer += s[index];
        if(index == s.length() - 2 )
        {
          last_state = true;
        }
        index++;
      }
      if(index == s.length() - 1)
        last_state = true;
    }
    if(last_state == true)
    {
      if(answer.find(s[index]) == -1)
        answer += s[s.length() - 1];
    }

    sort(answer.begin(), answer.end());
    cout << answer << endl;

  }
  return 0;
}


#include <iostream>
#include <map>
#include <string>

using namespace std;

int main()
{
  int ques;
  string s;
  cin >> ques;
  while(ques--)
  // value : 2 confirm not broken, 1 maybe not broken, 0 broken
  {
    map<char,int> broken;
    int index = 0;
    char current, prev = NULL;
    cin >> s;
    while(index != s.length())
    {
      current = s[index];
      if(broken.find(current) == broken.end())
      {
        broken.insert(pair<char, int>(current, 1));
      }
      if(broken[current] != 2)
        broken[current] = 1;
      if(current == prev && broken[prev] != 2)
      {
        broken[current] = 0;
      }
      else if(broken[prev] != 0 && current != prev)
      {
        broken[prev] = 2;
      }
      if(index ==  s.length() - 1 && broken[current] == 1)
      {
        broken[current] = 2;
      }
      prev = current;
      index++;
    }
    for(auto it = broken.begin(); it != broken.end(); it++)
    {
      if(it -> second == 2)
        cout << it -> first;
    }
    cout << endl;
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
  int ques;
  string s, answer;
  cin >> ques;
  while(ques--)
  {
    cin >> s;
    int index = 0;
    //false means broken
    bool last_state = false;
    answer = "";
    if(s.length() == 1)
      answer = s;
    while(index < s.length() - 1)
    {
      if(s[index] == s[index + 1])
      {
        index = index + 2;
      }
      else
      {
        if(answer.find(s[index]) == -1)
          answer += s[index];
        if(index == s.length() - 2 )
        {
          last_state = true;
        }
        index++;
      }
      if(index == s.length() - 1)
        last_state = true;
    }
    if(last_state == true)
    {
      if(answer.find(s[index]) == -1)
        answer += s[s.length() - 1];
    }

    sort(answer.begin(), answer.end());
    cout << answer << endl;

  }
  return 0;
}


#include <iostream>
#include <map>
#include <string>

using namespace std;

int main()
{
  int ques;
  string s;
  cin >> ques;
  while(ques--)
  // value : 2 confirm not broken, 1 maybe not broken, 0 broken
  {
    map<char,int> broken;
    int index = 0;
    char current, prev = NULL;
    cin >> s;
    while(index != s.length())
    {
      current = s[index];
      if(broken.find(current) == broken.end())
      {
        broken.insert(pair<char, int>(current, 1));
      }
      if(broken[current] != 2)
        broken[current] = 1;
      if(current == prev && broken[prev] != 2)
      {
        broken[current] = 0;
      }
      else if(broken[prev] != 0 && current != prev)
      {
        broken[prev] = 2;
      }
      else if(index ==  s.length() - 1)
        broken[current] = 2;
      prev = current;
      index++;
    }
    for(auto it = broken.begin(); it != broken.end(); it++)
    {
      if(it -> second == 2)
        cout << it -> first;
    }
    cout << endl;
  }
  return 0;
}


#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
  int ques;
  string s, answer;
  cin >> ques;
  while(ques--)
  {
    cin >> s;
    int index = 0;
    //false means broken
    bool last_state = false;
    answer = "";
    if(s.length() == 1)
      answer = s;
    while(index < s.length() - 1)
    {
      if(s[index] == s[index + 1])
      {
        index = index + 2;
      }
      else
      {
        answer += s[index];
        if(index == s.length() - 2 )
        {
          last_state = true;
        }
        index++;
      }
      if(index == s.length() - 1)
        last_state = true;
    }
    if(last_state == true)
      answer += s[s.length() - 1];
    sort(answer.begin(), answer.end());
    cout << answer << endl;

  }
  return 0;
}


#include <bits/stdc++.h>
typedef long long Long;

#define MAX 100001

#define PB push_back
#define MP make_pair
#define FF first
#define SS second

#define PII pair<int, int>
#define VI vector<int>

#define FOR(a, n) for(int i=a;i<n;i++)
#define FORn(a, n) for(int i=a;i<=n;i++)

#define mm(a, n) memset(a, n, sizeof(a))

#define PF printf
#define PC putchar
#define GC getchar

#define printCase cout<<"Case "<<i<<": "
#define printCaseC PF("Case %d: ", i)

#define II() ({int a; scanf("%d", &a); a;})
#define LI() ({Long a; scanf("%I64d", &a); a;})
#define DI() ({double a; scanf("%lf", &a); a;})

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
//double pi=atan(1)*4;

using namespace std;
void solve()
{
    string a;
    cin>>a;
    int valid[256]={0};
    for(int i=0; i<a.size(); )
    {
        int j=i+1;
        for(    ;a[j]==a[i]; j++) {}
        if((j-i)%2)
            valid[a[i]]=1;
        i=j;
    }
    FORn('a', 'z')
        if(valid[i])
            cout<<(char)i;
     cout<<endl;
}
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else
    #endif
    /* *******Bismillahir Rahmanir Rahim **** */
    FastIO;
    int t;
    cin>>t;
    // t=1;
    FORn(1, t)
    {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
typedef long long Long;

#define MAX 100001

#define PB push_back
#define MP make_pair
#define FF first
#define SS second

#define PII pair<int, int>
#define VI vector<int>

#define FOR(a, n) for(int i=a;i<n;i++)
#define FORn(a, n) for(int i=a;i<=n;i++)

#define mm(a, n) memset(a, n, sizeof(a))

#define PF printf
#define PC putchar
#define GC getchar

#define printCase cout<<"Case "<<i<<": "
#define printCaseC PF("Case %d: ", i)

#define II() ({int a; scanf("%d", &a); a;})
#define LI() ({Long a; scanf("%I64d", &a); a;})
#define DI() ({double a; scanf("%lf", &a); a;})

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
//double pi=atan(1)*4;

using namespace std;
void solve()
{
    string a;
    cin>>a;
    int cnt[256]={0};
    for(int i=0; i<a.size(); i++)
        cnt[a[i]]++;
    // cout<<cnt['b']<<endl;
    for(int i=0; i<a.size();)
    {
        if(cnt[a[i]]%2==0)
        {
            if(a[i+1]!=a[i])
            {
                cnt[a[i]]=1;

            }
            else
                cnt[a[i]]=0;
            i+=2;
        }
        else
            i++;
    }
    FORn('a', 'z')
        if(cnt[i]%2)
            cout<<(char)i;
     cout<<endl;
}
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else
    #endif
    /* *******Bismillahir Rahmanir Rahim **** */
    FastIO;
    int t;
    cin>>t;
    // t=1;
    FORn(1, t)
    {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
typedef long long Long;

#define MAX 100001

#define PB push_back
#define MP make_pair
#define FF first
#define SS second

#define PII pair<int, int>
#define VI vector<int>

#define FOR(a, n) for(int i=a;i<n;i++)
#define FORn(a, n) for(int i=a;i<=n;i++)

#define mm(a, n) memset(a, n, sizeof(a))

#define PF printf
#define PC putchar
#define GC getchar

#define printCase cout<<"Case "<<i<<": "
#define printCaseC PF("Case %d: ", i)

#define II() ({int a; scanf("%d", &a); a;})
#define LI() ({Long a; scanf("%I64d", &a); a;})
#define DI() ({double a; scanf("%lf", &a); a;})

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
//double pi=atan(1)*4;

using namespace std;
void solve()
{
    string x;
    cin>>x;
    int ok[256]={0};
    for(int i=1; i< x.size(); i+=2)
    {
        if(x[i]!=x[i-1])
//            ok[x[i]]=0;
//        else
            ok[x[i]]=1, ok[x[i-1]]=1;
    }
    if(x.size()%2)
    {
        ok[x[x.size()-1]]=1;
    }
    FORn('a', 'z')
        if(ok[i])
            cout<<(char)i;
    cout<<endl;
}
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else
    #endif
    /* *******Bismillahir Rahmanir Rahim **** */
     FastIO;
    int t;
    cin>>t;
//    t=1;
    FORn(1, t)
    {
        //printCase;
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
typedef long long Long;

#define MAX 100001

#define PB push_back
#define MP make_pair
#define FF first
#define SS second

#define PII pair<int, int>
#define VI vector<int>

#define FOR(a, n) for(int i=a;i<n;i++)
#define FORn(a, n) for(int i=a;i<=n;i++)

#define mm(a, n) memset(a, n, sizeof(a))

#define PF printf
#define PC putchar
#define GC getchar

#define printCase cout<<"Case "<<i<<": "
#define printCaseC PF("Case %d: ", i)

#define II() ({int a; scanf("%d", &a); a;})
#define LI() ({Long a; scanf("%I64d", &a); a;})
#define DI() ({double a; scanf("%lf", &a); a;})

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
//double pi=atan(1)*4;

using namespace std;

void solve()
{
    string x;
    cin>>x;
    int cnt[256]={0};
    FOR(0, x.size())
        cnt[x[i]]++;
    FORn('a', 'z')
        if(cnt[i]%2)
            cout<<(char)i;
    cout<<endl;
}
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else
    #endif
    /* *******Bismillahir Rahmanir Rahim **** */
     FastIO;
    int t;
    cin>>t;
//    t=1;
    FORn(1, t)
    {
        //printCase;
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
typedef long long Long;

#define MAX 100001

#define PB push_back
#define MP make_pair
#define FF first
#define SS second

#define PII pair<int, int>
#define VI vector<int>

#define FOR(a, n) for(int i=a;i<n;i++)
#define FORn(a, n) for(int i=a;i<=n;i++)

#define mm(a, n) memset(a, n, sizeof(a))

#define PF printf
#define PC putchar
#define GC getchar

#define printCase cout<<"Case "<<i<<": "
#define printCaseC PF("Case %d: ", i)

#define II() ({int a; scanf("%d", &a); a;})
#define LI() ({Long a; scanf("%I64d", &a); a;})
#define DI() ({double a; scanf("%lf", &a); a;})

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
//double pi=atan(1)*4;

using namespace std;
int iscons(string x, char y)
{
    int ret=0;
    string ch;
    ch.PB(y);
    for(int i=1; i<x.size(); i++)
    {
        if(x[i]==y)
        {
            if(x[i]==x[i-1])
                ret=1;
            else if(x[i]==x[i+1])
                ret=1, i++;
            else return 0;
        }
    }
    return ret;
}
void solve()
{
    string x;
    cin>>x;
    int cnt[256]={0};
    FOR(0, x.size())
        cnt[x[i]]++;
    FORn('a', 'z')
        if(cnt[i]%2)
            cout<<(char)i;
        else if(cnt[i]>1 && cnt[i]%2==0)
        {
            if(!iscons(x, i))
                cout<<(char)i;
        }
    cout<<endl;
}
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else
    #endif
    /* *******Bismillahir Rahmanir Rahim **** */
     FastIO;
    int t;
    cin>>t;
//    t=1;
    FORn(1, t)
    {
        //printCase;
        solve();
    }
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		string s;
		cin>>s;
		string res="";
		for(int i=0;i<s.size();i++)
		{
			if(s[i]==s[i+1])
			{
				i++;
			}
			else
			{
				res+=s[i];
			}
		}
		int n=res.size();
		sort(res.begin(),res.end());
		cout<<res<<endl;
		cout<<endl;
	}
}


#include<iostream>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		string s;
		cin>>s;
		for(int i=0;i<s.size();i++)
		{
			if(s[i]==s[i+1])
			{
				i++;
			}
			else
			{
				cout<<s[i];
			}
		}
		cout<<endl;
	}
}


#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		string s;
		cin>>s;
		string res="";
		for(int i=0;i<s.size();i++)
		{
			if(s[i]==s[i+1])
			{
				i++;
			}
			else
			{
				res+=s[i];
			}
		}
		int n=res.size();
		sort(res.begin(),res.end());
		cout<<res<<endl;
	//	cout<<endl;
	}
}


#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		string s;
		cin>>s;
		set<char> st;
		for(int i=0;i<s.size();i++)
		{
			if(s[i]==s[i+1])
			{
				i++;
			}
			else
			{
				st.insert(s[i]);
			}
		}
		for(auto x:s)
		cout<<x;

		cout<<endl;
	}
}


#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		string s;
		cin>>s;
		set<char> st;
		for(int i=0;i<s.size();i++)
		{
			if(s[i]==s[i+1])
			{
				i++;
			}
			else
			{
				st.insert(s[i]);
			}
		}
		for(auto x:st)
		cout<<x;

		cout<<endl;
	}
}


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

int main()
{
    int t,l,i,j,n;
    string s;
    cin>>t;
    while(t--)
    {
        getchar();
        cin>>s;
        l=s.size();
        if(l==1)
        {

            cout<<s[0];
        }
        else if(l%2==0)
        {
            string a;
            for(i=0;i<l-1;i+=2)
            {
               if(s[i]!=s[i+1])
               {
                   a+=s[i];
                   a+=s[i+1];

               }
            }
            sort(a.begin(),a.end());
            int l1=a.size();
            for(i=0;i<l1;i++)
            {
               cout<<a[i];
            }
        }
        else if(l%2!=0)
        {
            string a;
            for(i=0;i<l-2;i+=2)
            {
               if(s[i]!=s[i+1])
               {
                   a+=s[i];
                   a+=s[i+1];

               }
            }
            a+=s[l-1];
            int l1=a.size();
            sort(a.begin(),a.end());

            for(i=0;i<l1;i++)
            {
               cout<<a[i];
            }
        }
        cout<<endl;
    }

    return 0;
}


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

int main()
{
    int t,l,i,j,n,f;
    string s;
    cin>>t;
    while(t--)
    {
        getchar();
        cin>>s;
        l=s.size();
        f=0;
        if(l==1)
        {

            cout<<s[0];
        }
        else if(l%2==0)
        {
            string a;
            for(i=0;i<l-1;i+=2)
            {
               if(s[i]!=s[i+1])
               {
                   a+=s[i];
                   a+=s[i+1];
                    f=1;
               }
            }
            sort(a.begin(),a.end());
            int l1=a.size();
            if(f==1)
            {
            for(i=0;i<l1;i++)
            {
               cout<<a[i];
            }
            }
        }
        else if(l%2!=0)
        {
            string a;
            for(i=0;i<l-2;i+=2)
            {
               if(s[i]!=s[i+1])
               {
                   a+=s[i];
                   a+=s[i+1];
                    f=1;
               }
            }
            a+=s[l-1];
            f=1;
            int l1=a.size();
            sort(a.begin(),a.end());
            if(f==1&&l1>0)
            {
            for(i=0;i<l1;i++)
            {
               cout<<a[i];
            }
            }
        }
        cout<<endl;
    }

    return 0;
}


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

int main()
{
    int t,l,i,j,n,f;
    string s;
    cin>>t;
    while(t--)
    {
        getchar();
        cin>>s;
        l=s.size();
        f=0;
        if(l==1)
        {

            cout<<s[0];
        }
        else if(l%2==0)
        {
            string a;
            for(i=0;i<l-1;)
            {
               if(s[i]!=s[i+1])
               {
                   a+=s[i];
                   i++;

                    f=1;
               }
               else
                i+=2;
            }
            if(i==l-1)
            a+=s[l-1];
            sort(a.begin(),a.end());
            int l1=a.size();
            if(f==1)
            {
            for(i=0;i<l1;i++)
            {
               cout<<a[i];
            }
            }
        }
        else if(l%2!=0)
        {
            string a;
            for(i=0;i<l-1;)
            {
               if(s[i]!=s[i+1])
               {
                   a+=s[i];
                   i++;

                    f=1;
               }
               else
                i+=2;
            }
            a+=s[l-1];
                f=1;
            int l1=a.size();
            sort(a.begin(),a.end());
            if(f==1)
            {
            for(i=0;i<l1;i++)
            {
               cout<<a[i];
            }
            }

        }
        cout<<endl;
    }

    return 0;
}


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

int main()
{
    int t,l,i,j,n,f;
    string s;
    cin>>t;
    while(t--)
    {
        getchar();
        cin>>s;
        l=s.size();
        f=0;
        if(l==1)
        {

            cout<<s[0];
        }
        else if(l%2==0)
        {
            string a;
            for(i=0;i<l-1;)
            {
               if(s[i]!=s[i+1])
               {
                   a+=s[i];
                   i++;

                    f=1;
               }
               else
                i+=2;
            }
            if(i==l-1)
            a+=s[l-1];
            sort(a.begin(),a.end());
            int l1=a.size();
            if(f==1)
            {
            for(i=0;i<l1;i++)
            {
               cout<<a[i];
            }
            }
        }
        else if(l%2!=0)
        {
            string a;
            for(i=0;i<l-1;)
            {
               if(s[i]!=s[i+1])
               {
                   a+=s[i];
                   i++;

                    f=1;
               }
               else
                i+=2;
            }
            if(i==l-1)
            a+=s[l-1];
                f=1;
            int l1=a.size();
            sort(a.begin(),a.end());
            if(f==1)
            {
            for(i=0;i<l1;i++)
            {
               cout<<a[i];
            }
            }

        }
        cout<<endl;
    }

    return 0;
}


#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

#define vi vector<int>
#define ll long long
#define vll vector<ll>
#define vc vector<char>
#define vb vector<bool>
using namespace std;

int main()
{
	int n;
	cin >> n;
	string arr;
	for (int o = 0; o < n; o++)
	{
		cin >> arr;
		if (arr.length() == 1)
		{
			cout << arr << endl;
			continue;
		}
		vb otv(26, false);
		int k = 1;
		for (int i = 1; i < arr.length(); i++)
		{
			k = 1;
			if (arr[i] == arr[i - 1])
			{
				k++;
				i++;
			}
			if (k % 2 == 1)
			{
				otv[arr[i - 1] - 'a'] = true;
			}
		}
		if (arr[arr.length() - 1] != arr[arr.length() - 2])
		{
			otv[arr[arr.length() - 1] - 'a'] = true;
		}
		for (int j = 0; j < 26; j++)
		{
			if (otv[j])
			{
				cout << char('a' + j);
			}
		}
		cout << endl;
	}

}

/* Tue Dec 17 2019 17:42:10 GMT+0300 (MSK) */


#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

#define vi vector<int>
#define ll long long
#define vll vector<ll>
#define vc vector<char>
#define vb vector<bool>
using namespace std;

int main()
{
	int n;
	cin >> n;
	string arr;
	for (int o = 0; o < n; o++)
	{
		cin >> arr;
		if (arr.length() == 1)
		{
			cout << arr;
			continue;
		}
		vb otv(26, false);
		int k = 1;
		for (int i = 1; i < arr.length(); i++)
		{
			k = 1;
			if (arr[i] == arr[i - 1])
			{
				k++;
				i++;
			}
			if (k % 2 == 1)
			{
				otv[arr[i - 1] - 'a'] = true;
			}
		}
		if (arr[arr.length() - 1] != arr[arr.length() - 2])
		{
			otv[arr[arr.length() - 1] - 'a'] = true;
		}
		for (int j = 0; j < 26; j++)
		{
			if (otv[j])
			{
				cout << char('a' + j);
			}
		}
		cout << endl;
	}

}

/* Tue Dec 17 2019 17:39:39 GMT+0300 (MSK) */


#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

#define vi vector<int>
#define ll long long
#define vll vector<ll>
#define vc vector<char>
#define vb vector<bool>
using namespace std;

int main()
{
	int n;
	cin >> n;
	string arr;
	for (int o = 0; o < n; o++)
	{
		cin >> arr;
		if (arr.length() == 1)
		{
			cout << arr << endl;
			continue;
		}
		vb otv(26, false);
		int k = 1, j;
		for (int i = 0; i < arr.length();)
		{
			k = 0, j = i;
			while (j < arr.length() && arr[i] == arr[j])
			{
				k++;
				j++;
			}

			if (k % 2 == 1)
			{
				otv[arr[i] - 'a'] = true;
			}
			i = j;
		}
		for (int j = 0; j < 26; j++)
		{
			if (otv[j])
			{
				cout << char('a' + j);
			}
		}
		cout << endl;
	}

}

/* Tue Dec 17 2019 18:14:09 GMT+0300 (MSK) */


#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

#define vi vector<int>
#define ll long long
#define vll vector<ll>
#define vc vector<char>
#define vb vector<bool>
using namespace std;

int main()
{
	int n;
	cin >> n;
	string arr;
	for (int o = 0; o < n; o++)
	{
		cin >> arr;
		if (arr.length() == 1)
		{
			cout << arr << endl;
			continue;
		}
		vb otv(26, false);
		int k = 1;
		for (int i = 1; i < arr.length(); i++)
		{
			k = 1;
			while (i<n && arr[i] == arr[i - 1])
			{
				k++;
				i++;
			}
			if (k % 2 == 1)
			{
				otv[arr[i - 1] - 'a'] = true;
			}
		}
		if (arr[arr.length() - 1] != arr[arr.length() - 2])
		{
			otv[arr[arr.length() - 1] - 'a'] = true;
		}
		for (int j = 0; j < 26; j++)
		{
			if (otv[j])
			{
				cout << char('a' + j);
			}
		}
		cout << endl;
	}

}

/* Tue Dec 17 2019 17:58:12 GMT+0300 (MSK) */


// ConsoleApplication206.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
//

#include "pch.h"

#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

#define vi vector<int>
#define ll long long
#define vll vector<ll>
#define vc vector<char>
#define vb vector<bool>
using namespace std;

int main()
{
	int n;
	cin >> n;
	string arr;
	for (int o = 0; o < n; o++)
	{
		cin >> arr;
		if (arr.length() == 1)
		{
			cout << arr << endl;
			continue;
		}
		vb otv(26, false);
		int k = 1;
		for (int i = 1; i < arr.length(); i++)
		{
			k = 1;
			while (i<n && arr[i] == arr[i - 1])
			{
				k++;
				i++;
			}
			if (k % 2 == 1)
			{
				otv[arr[i - 1] - 'a'] = true;
			}
		}
		if (arr[arr.length() - 1] != arr[arr.length() - 2])
		{
			otv[arr[arr.length() - 1] - 'a'] = true;
		}
		for (int j = 0; j < 26; j++)
		{
			if (otv[j])
			{
				cout << char('a' + j);
			}
		}
		cout << endl;
	}

}

/* Tue Dec 17 2019 17:57:25 GMT+0300 (MSK) */


#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main(){
	int n;
	string s;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> s;
		int k = 1;
		for (int j = 1; j < s.size(); j++){
			while (s[j] == s[j - 1]){
				k++;
				j++;
			}
			if (k % 2 != 0){
				for (int p = 0; p < j; p++)cout << s[p];
			}
		}
		cout << endl;
	}
	return 0;
}
/* Sun Dec 15 2019 10:52:00 GMT+0300 (MSK) */


#include<iostream>
using namespace std;

int main()
{
	int t;
	cin>>t;

	while(t--)
	{
		string s;
		cin>>s;
		int freq[124]={0},k=0;
		char res[26]="";
		for(int i=0;i<s.size();i++)
		{++freq[s[i]];}

		for(int i=0;i<s.size();i++)
		{
			if(freq[s[i]]>0&&freq[s[i]]%2!=0)
			{
			freq[s[i]]=0;
			res[k++]=s[i];	}
		}
		res[k]='\0';
		int f[124]={0};
		for(int i=0;i<k;i++)
		++f[res[i]];
		//if(res!="")
		for(int i=96;i<124;i++)
		{
			if(f[i]>0)
			printf("%c",i);
		}
		//else
		//cout<<res;
		cout<<endl;
	}
}


#include<iostream>
using namespace std;

int main()
{
	int t;
	cin>>t;

	while(t--)
	{
		string s;
		cin>>s;
		int freq[124]={0},k=0;
		char res[26]="";
		for(int i=0;i<s.size();i++)
		{++freq[s[i]];}

		for(int i=0;i<s.size();i++)
		{
			if(s[i]==s[i+1]&&freq[s[i]]%2==0&&freq[s[i]]>0)
			{
				freq[s[i]]=0;
			}
			else if(freq[s[i]]>0)
			{
			freq[s[i]]=0;
			res[k++]=s[i];	}
		}
		res[k]='\0';
		int f[124]={0};
		for(int i=0;i<k;i++)
		++f[res[i]];
		//if(res!="")
		for(int i=96;i<124;i++)
		{
			if(f[i]>0)
			printf("%c",i);
		}
		//else
		//cout<<res;
		cout<<endl;
	}
}


#include<iostream>
using namespace std;

int main()
{
	int t;
	cin>>t;

	while(t--)
	{
		string s;
		cin>>s;
		int freq[124]={0},k=0,count=0,j;
		char res[1000]="";
		for(int i=0;i<s.size();i++)
		++freq[s[i]];
		for(int i=0;i<s.size();i++)
		{
			count=0;
			for(j=i;j<s.size()&&s[i]==s[j];j++)
			{
				count++;
			}
			i=j-1;
			if(count%2!=0)
			res[k++]=s[i];
		}

		if(k>0)
		res[k]='\0';
		int f[124]={0};
		for(int i=0;i<k;i++)
		++f[res[i]];
		for(int i=96;i<124;i++)
		{
			if(f[i]>0)
			printf("%c",i);
		}
		//if(t!=0)
		cout<<endl;
	}
}


#include<iostream>
using namespace std;

int main()
{
	int t;
	cin>>t;

	while(t--)
	{
		string s;
		cin>>s;
		int freq[124]={0},k=0;
		char res[26]="";
		for(int i=0;i<s.size();i++)
		{++freq[s[i]];}

		for(int i=0;i<s.size();i++)
		{
		 	if(s[i]!=s[i+1]&&s[i]!=s[i-1])
			{
			freq[s[i]]=0;
			res[k++]=s[i];	}
		}
		res[k]='\0';
		int f[124]={0};
		for(int i=0;i<k;i++)
		++f[res[i]];
		//if(res!="")
		for(int i=96;i<124;i++)
		{
			if(f[i]>0)
			printf("%c",i);
		}
		//else
		//cout<<res;
		cout<<endl;
	}
}


#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<utility>
#include<string>
using namespace std;
int main(){
    int t{0};
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        vector<int> vec(26,-1);
        int n=s.length();
        for(int i=0;i<n;i++){
            int j;
            for(j=i+1;j<n;j++){
                if(s[j]!=s[i])
                break;
                if(s[j]==s[i])
                continue;
            }
           j--;
           if(j!=i){
               if((j-i+1)%2==0)
               vec[i]=0;
               i=j;
           }else
           vec[i]=-1;
        }
        for(int i=0;i<26;i++){
            if(vec[i]==-1)
            cout<<(char)(i+'a');
        }
        cout<<endl;
    }

    return 0;
}


#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<utility>
#include<string>
using namespace std;
int main(){
    int t{0};
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        vector<int> vec(26,-1);
        int n=s.length();
        for(int i=0;i<n;i++){
            int j;
            for(j=i+1;j<n;j++){
                if(s[j]!=s[i])
                break;
                if(s[j]==s[i])
                continue;
            }
           j--;
           if(j!=i){
               if((j-i+1)%2==0 && vec[(int)(s[i]-'a')]!=1)
               vec[(int)(s[i]-'a')]=0;
               else
               vec[(int)(s[i]-'a')]=1;
               i=j;
           }else
           vec[(int)(s[i]-'a')]=1;
        }
        for(int i=0;i<26;i++){
            if(vec[i]==1)
            cout<<(char)(i+'a');
        }
        cout<<endl;
    }

    return 0;
}


#include<iostream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<vector>
using namespace std;
int main(){
    int t{0};
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        int n=s.length();
        int arr[26]{0};
        for(int i=0;i<n;i++){
            arr[(int)(s[i]-'a')]++;
        }
        for(int i=0;i<26;i++){
            if(arr[i]!=0 && arr[i]%2!=0){
                cout<<i+'a';
            }
        }
        cout<<endl;
    }

    return 0;
}


#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<utility>
#include<string>
using namespace std;
int main(){
    int t{0};
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        vector<int> vec(26,-1);
        int n=s.length();
        for(int i=0;i<n;i++){
            int j;
            for(j=i+1;j<n;j++){
                if(s[j]!=s[i])
                break;
                if(s[j]==s[i])
                continue;
            }
           j--;
           if(j!=i){
               if((j-i+1)%2==0)
               vec[i]=0;
               i=j;
           }else
           vec[i]=1;
        }
        for(int i=0;i<26;i++){
            if(vec[i]==1)
            cout<<(char)(i+'a');
        }
        cout<<endl;
    }

    return 0;
}


#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<utility>
#include<string>
using namespace std;
int main(){
    int t{0};
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        vector<int> vec(26,-1);
        int n=s.length();
        for(int i=0;i<n;i++){
            int j;
            for(j=i+1;j<n;j++){
                if(s[j]!=s[i])
                break;
                if(s[j]==s[i])
                continue;
            }
           j--;
           if(j!=i){
               if((j-i+1)%2==0)
               vec[(int)(s[i]-'a')]=0;
               i=j;
           }else
           vec[(int)(s[i]-'a')]=1;
        }
        for(int i=0;i<26;i++){
            if(vec[i]==1)
            cout<<(char)(i+'a');
        }
        cout<<endl;
    }

    return 0;
}


#include<iostream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<vector>
using namespace std;
int main(){
    int t{0};
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        int n=s.length();
        int arr[26]{0};
        for(int i=0;i<n;i++){
            arr[(int)(s[i]-'a')]++;
        }
        for(int i=0;i<26;i++){
            if(arr[i]!=0 && arr[i]%2!=0){
                cout<<(char)(i+'a');
            }
        }
        cout<<endl;
    }

    return 0;
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces.C641
{
    class Pa
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            bool[] fw = Console.ReadLine().ToCharArray().Select(t => t == '>').ToArray();
            int[] steps = Console.ReadLine().Split(' ').Select((t, index) => int.Parse(t) * (fw[index] ? 1 : -1)).ToArray();
            bool[] visited = new bool[n];
            var valid = true;
            int pos = 0;
            while(pos >= 0 && pos < n && !visited[pos])
            {
                visited[pos] = true;
                pos += steps[pos];
            }
            if(pos >= 0 && pos < n)
            {
                Console.WriteLine("INFINITE");
            }
            else
            {
                Console.WriteLine("FINITE");
            }
            Console.ReadKey();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class TapeCell
    {
        public int JumpLength;
        public char JumpDirection;
        public bool StatusCheck = false;
        public TapeCell()
        {
            JumpLength = 0;
            JumpDirection = '.';
            StatusCheck = false;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            int tapeLength = int.Parse(Console.ReadLine());
            TapeCell[] tapeCellArray = new TapeCell[tapeLength];
            char[] DirectionArrayStr = Console.ReadLine().ToCharArray();
            string[] LengthArrayStr = Console.ReadLine().Split(' ');
            for (int i = 0; i < tapeLength; i++)
            {
                tapeCellArray[i] = new TapeCell();
                tapeCellArray[i].JumpDirection = DirectionArrayStr[i];
                tapeCellArray[i].JumpLength = int.Parse(LengthArrayStr[i]);
            }
            int currentCell = 0;
            bool Check = true;
            while (Check)
            {
                if (!tapeCellArray[currentCell].StatusCheck)
                {
                    tapeCellArray[currentCell].StatusCheck = true;
                    if (tapeCellArray[currentCell].JumpDirection == '>')
                    {
                        currentCell += tapeCellArray[currentCell].JumpLength;
                        if(currentCell>=tapeCellArray.Length || currentCell < 0)
                        {
                            break;
                        }
                    }
                    else
                    {
                        currentCell -= tapeCellArray[currentCell].JumpLength;
                        if (currentCell >= tapeCellArray.Length || currentCell < 0)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    Check = false;
                }
            }
            if (Check)
            {
                Console.WriteLine("FINITE");
            }
            else
            {
                Console.WriteLine("INFINITE");
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;

namespace Olymp
{
  public class ProblemSolver
  {
    private Tokenizer input;

    public void Solve()
    {
      int n = input.NextInt();
      string s = input.NextToken();
      int[] a = input.ReadIntArray(n);
      bool[] b = new bool[n];
      int pos = 0;
      b[0] = true;
      while (true)
      {
        if (s[pos] == '>')
        {
          pos += a[pos];
        }
        else
        {
          pos -= a[pos];
        }
        if (pos >= n || pos < 0)
        {
          Console.Write("FINITE");
          return;
        }
        if (b[pos])
        {
          Console.Write("INFINITE");
          return;
        }
        b[pos] = true;
      }
    }

    public ProblemSolver(TextReader input)
    {
      this.input = new Tokenizer(input);
    }
  }

  #region Service classes

  public class Tokenizer
  {
    private TextReader reader;

    public int NextInt()
    {
      var c = SkipWS();
      if (c == -1)
        throw new EndOfStreamException();
      bool isNegative = false;
      if (c == '-' || c == '+')
      {
        isNegative = c == '-';
        c = this.reader.Read();
        if (c == -1)
          throw new InvalidOperationException();
      }
      if (!char.IsDigit((char)c))
        throw new InvalidOperationException();
      int result = (char)c - '0';
      c = this.reader.Read();
      while (c > 0 && !char.IsWhiteSpace((char)c))
      {
        if (!char.IsDigit((char)c))
          throw new InvalidOperationException();
        result = result * 10 + (char)c - '0';
        c = this.reader.Read();
      }
      if (isNegative)
        result = -result;
      return result;
    }

    public string ReadLine()
    {
      return reader.ReadLine();
    }

    public long NextLong()
    {
      return long.Parse(this.NextToken());
    }

    public double NextDouble()
    {
      return double.Parse(this.NextToken(), CultureInfo.InvariantCulture);
    }

    public int[] ReadIntArray(int n)
    {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = NextInt();
      return a;
    }

    public long[] ReadLongArray(int n)
    {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = NextLong();
      return a;
    }

    public double[] ReadDoubleArray(int n)
    {
      double[] a = new double[n];
      for (int i = 0; i < n; i++)
        a[i] = NextDouble();
      return a;
    }

    public string NextToken()
    {
      var c = SkipWS();
      if (c == -1)
        return null;
      var sb = new StringBuilder();
      while (c > 0 && !char.IsWhiteSpace((char)c))
      {
        sb.Append((char)c);
        c = this.reader.Read();
      }
      return sb.ToString();
    }

    private int SkipWS()
    {
      int c = this.reader.Read();
      if (c == -1)
        return c;
      while (c > 0 && char.IsWhiteSpace((char)c))
        c = this.reader.Read();
      return c;
    }

    public Tokenizer(TextReader reader)
    {
      this.reader = reader;
    }
  }

  class Program
  {
    public static void Main(string[] args)
    {
      var solver = new ProblemSolver(Console.In);
      solver.Solve();
    }
  }

  #endregion
}


using System;
using System.Collections.Generic;
using System.Linq;

namespace deneme
{
    class Program
    {
       static void Main(string[] args)
       {
           try
            {
                int counter = 0;
                int sum = 0;
                int n = int.Parse(Console.ReadLine());
                string s = Console.ReadLine();
                int[] numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                if (s[0] == '<')
                {
                    Console.Write("FINITE");

                }
                else
                {
                    for (int i = 0; i < n; i++)
                    {
                        if (s[counter] == '>')
                        {
                            sum += numbers[counter];
                            counter += numbers[counter];
                        }
                        else
                        {
                            sum -= numbers[counter];
                            counter -= numbers[counter];
                        }
                    }
                    if (sum > s.Length || sum < 0)
                        Console.Write("FINITE");
                    else
                        Console.Write("INFINITE");
                }

                Console.ReadKey();
           }
           catch { }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;

namespace deneme
{
    class Program
    {
       static void Main(string[] args)
       {
           try
            {
                int counter = 0;
                int sum = 0;
                int n = int.Parse(Console.ReadLine());
                string s = Console.ReadLine();
                int[] numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                if (s[0] == '<')
                {
                    Console.Write("FINITE");

                }
                else
                {
                    for (int i = 0; i < n; i++)
                    {
                        if (s[counter] == '>')
                        {
                            sum += numbers[counter];
                            counter += numbers[counter];
                        }
                        else
                        {
                            sum -= numbers[counter];
                            counter -= numbers[counter];
                        }
                    }
                    if (sum > s.Length-1 || sum < 0)
                        Console.Write("FINITE");
                    else
                        Console.Write("INFINITE");
                }

                Console.ReadKey();
           }
           catch { }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;

namespace deneme
{
    class Program
    {
       static void Main(string[] args)
       {
           try
            {
                int counter = 0;
                int sum = 0;
                int n = int.Parse(Console.ReadLine());
                string s = Console.ReadLine();
                int[] numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                if (s[0] == '<')
                {
                    Console.Write("FINITE");

                }
                else
                {
                    for (int i = 0; i < n; i++)
                    {
                        if (s[counter] == '>')
                        {
                            sum += numbers[counter];
                            counter += numbers[counter];
                        }
                        else
                        {
                            sum -= numbers[counter];
                            counter -= numbers[counter];
                        }
                        if(sum<0 || sum>s.Length-1)
                        {
                            Console.Write("FINITE");
                            break;
                        }
                    }
                    if (sum >= 0 && sum<s.Length)
                        Console.Write("INFINITE");
                }

                Console.ReadKey();
           }
           catch { }
        }
    }
}


using System;
using System.Linq;

namespace TopCoder.Test.CodeForces
{
    public class Program641AX
    {
        public static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            string directions = Console.ReadLine();
            int[] lengths = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();

            bool isInfinite = SimulateJumps(n, directions, lengths);

            Console.WriteLine(isInfinite ? "INFINITE" : "FINITE");
        }

        public static bool SimulateJumps(int n, string directions, int[] lengths)
        {
            bool[] visited = new bool[n];
            visited[0] = true;

            for (int i = 0; ;)
            {
                int dir = directions[i] == '<' ? -1 : +1;
                int j = i + dir * lengths[i];

                if (j < 0 || j >= n)
                    return false;

                if (visited[j])
                    return true;

                visited[j] = true;
            }
        }
    }
}


using System;
using System.Linq;

namespace TopCoder.Test.CodeForces
{
    public class Program641A
    {
        public static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            string directions = Console.ReadLine();
            int[] lengths = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();

            bool isInfinite = SimulateJumps(n, directions, lengths);

            Console.WriteLine(isInfinite ? "INFINITE" : "FINITE");
        }

        public static bool SimulateJumps(int n, string directions, int[] lengths)
        {
            for (int i = 0, pos = 0; i < n; i++)
            {
                int dir = directions[i] == '<' ? -1 : +1;
                pos += dir * lengths[i];
                if (pos < 0 || pos >= n)
                    return false;
            }

            return true;
        }
    }
}


using System;
using System.Linq;

namespace TopCoder.Test.CodeForces
{
    public class Program641A
    {
        public static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            string directions = Console.ReadLine();
            int[] lengths = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();

            bool isInfinite = SimulateJumps(n, directions, lengths);

            Console.WriteLine(isInfinite ? "INFINITE" : "FINITE");
        }

        public static bool SimulateJumps(int n, string directions, int[] lengths)
        {
            bool[] visited = new bool[n];
            visited[0] = true;

            for (int i = 0; ;)
            {
                int dir = directions[i] == '<' ? -1 : +1;
                int j = i + dir * lengths[i];

                if (j < 0 || j >= n)
                    return false;
                i = j;
                if (visited[i])
                    return true;
                visited[i] = true;
            }
        }
    }
}


using System;
using System.Linq;

namespace TopCoder.Test.CodeForces
{
    public class Program641A
    {
        public static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            string directions = Console.ReadLine();
            int[] lengths = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();

            bool isInfinite = SimulateJumps(n, directions, lengths);

            Console.WriteLine(isInfinite ? "INFINITE" : "FINITE");
        }

        public static bool SimulateJumps(int n, string directions, int[] lengths)
        {
            bool[] visited = new bool[n];
            visited[0] = true;

            for (int i = 0; ;)
            {
                int dir = directions[i] == '<' ? -1 : +1;
                int j = i + dir * lengths[i];

                if (j < 0 || j >= n)
                    return false;

                if (visited[j])
                    return true;

                visited[j] = true;
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;

namespace codeforces
{
	class Program
	{
		public const int Osn = 1000000007;

		public class Pair
		{
			public long First;

			public int Second;

			public int Third;
		}

		public class PairComparer : IComparer<Pair>
		{
			public int Compare(Pair x, Pair y)
			{
				if (x.First > y.First || (x.First == y.First && x.Second < y.Second))
					return -1;
				return 1;
			}
		}

		public static long GetGcd(long a, long b)
		{
			while (true)
			{
				if (b == 0)
					return a;
				var a1 = a;
				a = b;
				b = a1 % b;
			}
		}

		public static void WriteYesNo(bool x, string yes = "YES", string no = "NO")
		{
			if (x)
				Console.WriteLine(yes);
			else
			{
				Console.WriteLine(no);
			}
		}

		public static string ReadString()
		{
			return Console.ReadLine();
		}

		public static List<int> ReadListOfInts()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(int.Parse).ToList();
		}

		public static List<long> ReadListOfLongs()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(long.Parse).ToList();
		}

		public static int ReadInt()
		{
			var s = Console.ReadLine();
			return int.Parse(s);
		}

		public static long ReadLong()
		{
			var s = Console.ReadLine();
			return long.Parse(s);
		}

		public class Vertex
		{
			public int Was;

			public List<Pair> Edges;
		}

		public static List<List<Vertex>> Graph = new List<List<Vertex>>();

/*		public static bool Dfs(int x, int y, int prevx, int prevy)
		{
			Graph[x][y].Was = 1;
			var result = false;
			foreach (var t in Graph[x][y].Edges)
			{
				if (Graph[t.First][t.Second].Was == 0)
					result |= Dfs(t.First, t.Second, x, y);
				else if (t.First != prevx || t.Second != prevy)
					return true;
			}

			return result;
		}*/

		public static bool IsPrime(int x)
		{
			for (var j = 2; j * j <= x; ++j)
				if (x % j == 0)
					return false;
			return true;
		}

		public class LinkedVertex
		{
			public int Next;

			public int Prev;

			public int Value;
		}

		private static void Main()
		{
			var n = ReadInt();
			var s = ReadString();
			var l = ReadListOfInts();
			var cur = 0;
			for (var i = 0; i < n + 1; ++i)
			{
				if (cur >= 0 && cur < n)
				{
					var p = 1;
					if (s[cur] == '<')
						p = -1;
					cur = cur + p * l[cur];
				}
			}
			WriteYesNo(cur < 0 || cur >= n, "FINITE", "INFINITE");
			Console.ReadLine();
		}
	}
}


fun main() {
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    val length = readInt()
    val strip = readLine()!!
    val jumps = readInts()
    val visited = mutableSetOf<Int>()
    var pos = 0
    while(true) {
        if (pos in visited) return print("INFINITE")
        if (pos < 0 || pos >= length) return print("FINITE")
        visited.add(pos)
        pos = if(strip[pos] == '<') pos - jumps[pos] else pos + jumps[pos]
    }
}


#include <stdio.h>
#include <memory.h>

int max(int a, int b){
	return a>b? a:b;
}

int main(){

	int n;
	scanf("%d",&n);
	char dir[200000];
	scanf("%s",&dir);
	int arr[200000];
	for (int i = 0; i < n; ++i){
		scanf("%d",&arr[i]);
	}

	int vis[200000];
	memset(vis,0,sizeof(vis));
	int pos=0;
	while(pos>=0 && pos<n && vis[pos]==0){
		vis[pos]=1;
		if(dir[pos]=='>'){
			pos+=arr[pos];
		}else if(dir[pos]=='<'){
			pos-=arr[pos];
		}
	}

	if(pos>=0 && pos<n){
		printf("INFINITE\n");
	}else{
		printf("FINITE\n");
	}

	return 0;
}


#include <stdio.h>

int main()
{
    int largo;
    char direction[100000];
    int step[100000];
    int marked[100000];
    marked[0] = 1;
    int pos;
    int i;
    pos = 0;
    scanf("%i",&largo);
    scanf("%s",&direction);
    for(i=0; i < largo; i++)
    {
        scanf("%d",&step[i]);
        marked[i]=0;
    }
    while(1)
    {
        if(direction[pos]=='>')
        {
            pos = pos + step[pos];
            if(pos > largo || pos < 0)
        {
            printf("FINITE");
            return 0;
        }
            marked[pos] = marked[pos] + 1;
        }
        else
        {
            pos = pos - step[pos];
            if(pos > largo || pos < 0)
        {
            printf("FINITE");
            return 0;
        }
            marked[pos] = marked[pos] + 1;
        }
        if(pos > largo || pos < 0)
        {
            printf("FINITE");
            return 0;
        }
        if(marked[pos] == 2)
        {
            printf("INFINITE");
            return 0;
        }
    }
}


#include <stdio.h>

int main()
{
    int largo;
    char direction[100000];
    int step[100000];
    int marked[100000];
    marked[0] = 1;
    int pos;
    int i;
    pos = 0;
    scanf("%i",&largo);
    scanf("%s",&direction);
    for(i=0; i < largo; i++)
    {
        scanf("%d",&step[i]);
        marked[i]=0;
    }
    while(1)
    {
        if(direction[pos]=='>')
        {
            pos = pos + step[pos];
            if(pos > largo || pos < 0)
        {
            printf("FINITE");
            return 0;
        }
            marked[pos] = marked[pos] + 1;
        }
        else
        {
            pos = pos - step[pos];
            marked[pos] = marked[pos] + 1;
        }
        if(marked[pos] == 2)
        {
            printf("INFINITE");
            return 0;
        }
    }
}


#include <stdio.h>

int main()
{
    int largo;
    char direction[100000];
    int step[100000];
    int marked[100000];
    marked[0] = 1;
    int pos;
    int i;
    pos = 0;
    scanf("%i",&largo);
    scanf("%s",&direction);
    for(i=0; i < largo; i++)
    {
        scanf("%d",&step[i]);
        marked[i]=0;
    }
    while(1)
    {
        if(direction[pos]=='>')
        {
            pos = pos + step[pos];
            if(pos >= largo || pos < 0)
        {
            printf("FINITE");
            return 0;
        }
            marked[pos] = marked[pos] + 1;
        }
        else
        {
            pos = pos - step[pos];
            if(pos >= largo || pos < 0)
        {
            printf("FINITE");
            return 0;
        }
            marked[pos] = marked[pos] + 1;
        }
        if(pos >= largo || pos < 0)
        {
            printf("FINITE");
            return 0;
        }
        if(marked[pos] == 2)
        {
            printf("INFINITE");
            return 0;
        }
    }
}


#include <stdio.h>

int main()
{
    int largo;
    char direction[100000];
    int step[100000];
    int marked[100000];
    marked[0] = 1;
    int pos;
    int i;
    pos = 0;
    scanf("%i",&largo);
    scanf("%s",&direction);
    for(i=0; i < largo; i++)
    {
        scanf("%d",&step[i]);
        marked[i]=0;
    }
    while(1)
    {
        if(direction[pos]=='>')
        {
            pos = pos + step[pos];
            marked[pos] = marked[pos] + 1;
        }
        else
        {
            pos = pos - step[pos];
            marked[pos] = marked[pos] + 1;
        }
        if(pos > largo || pos < 0)
        {
            printf("FINITE");
            return 0;
        }
        if(marked[pos] == 2)
        {
            printf("INFITINE");
            return 0;
        }
    }
}


#include <stdio.h>

int main()
{
    int largo;
    char direction[100000];
    int step[100000];
    int marked[100000];
    marked[0] = 1;
    int pos;
    int i;
    pos = 0;
    scanf("%i",&largo);
    scanf("%s",&direction);
    for(i=0; i < largo; i++)
    {
        scanf("%d",&step[i]);
        marked[i]=0;
    }
    while(1)
    {
        if(direction[pos]=='>')
        {
            pos = pos + step[pos];
            marked[pos] = marked[pos] + 1;
        }
        else
        {
            pos = pos - step[pos];
            marked[pos] = marked[pos] + 1;
        }
        if(pos > largo || pos < 0)
        {
            printf("FINITE");
            return 0;
        }
        if(marked[pos] == 2)
        {
            printf("INFINITE");
            return 0;
        }
    }
}


#include <stdio.h>
#include <stdlib.h>

/*
 * http://codeforces.com/contest/641/problem/A
 */
int main()
{
    size_t n = 0;
    scanf("%lu ", &n);

    char *directions = calloc(n, sizeof(char));
    for (size_t i = 0; i < n; i++) {
        scanf("%c", &directions[i]);
    }
    unsigned int *steps = calloc(n, sizeof(int));
    for (size_t i = 0; i < n; i++) {
        scanf("%d ", &steps[i]);
    }

    int i = 0;
    while (i < n && i > -1) {
        switch (directions[i]) {
            case 'x':
                printf("INFINITE\n");
                return 0;
            case '>':
                directions[i] = 'x';
                i += steps[i];
                break;
            case '<':
                directions[i] = 'x';
                i -= steps[i];
                break;
        }
    }

    printf("FINITE\n");

    return 0;
}


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

int main()
{
    char direction[100000];
    int step[100000];
    int size, currentPos, stepL=0, i;

    scanf( "%d", &size );

    scanf( "%s", &direction);

    for (i=0;i<size;i++)
    {
        scanf( "%d", &step[i] );
        fflush( stdout );
    }

    while(1)
    {
        currentPos=stepL;
        if (direction[stepL]=='<')
        {
            stepL=stepL-step[stepL];
        }
        else
        {
            stepL=stepL+step[stepL];
        }

        if((stepL>=size)||(stepL<0))
        {
            printf( "FINITE" );
            return 0;
            exit(0);
        }
        if(step[currentPos]==0)
        {
            printf( "INFINITE" );
            return 0;
            exit(0);
        }
        step[currentPos]=0;
    }
    return 0;
}


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

int main()
{
    char direction[100000];
    int step[100000];
    int size, currentPos, stepL=0, i;

    scanf( "%d", &size );

    for (i=0;i<size;i++)
    {
        scanf( "%s", &direction[i]);
        fflush( stdout );
    }
    for (i=0;i<size;i++)
    {
        scanf( "%d", &step[i] );
        fflush( stdout );
    }

    while(1)
    {
        currentPos=stepL;
        if (direction[stepL]=='<')
        {
            stepL=stepL-step[stepL];
        }
        else
        {
            stepL=stepL+step[stepL];
        }

        if((stepL>=size)||(stepL<0))
        {
            printf( "FINITE" );
            return 0;
            exit(0);
        }
        if(step[currentPos]==0)
        {
            printf( "INFINITE" );
            return 0;
            exit(0);
        }
        step[currentPos]=0;
    }
    return 0;
}


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

int main()
{
    char direction[100000];
    int step [100000];
    int n, i, x;

    scanf( "%d", &n );
    for (i=0;i<n;i++)
    {
        scanf( "%s", &direction[i]);
        fflush( stdout );
    }
    for (i=0;i<n;i++)
    {
        scanf( "%d", &step[i] );
    }

    i=0;

    while(1)
    {
        x=i;
        if (direction[i]=='<')
        {
            i=i-step[i];
            if((i<0)||(i>=n))
            {
                printf( "FINITE" );
                exit(0);
            }
            if(step[i]==0)
            {
                printf( "INFINITE" );
                exit(0);
            }
            step[x]=0;
        }
        else
        {
            if(direction[i]=='>')
            {
                i=i+step[i];
                if((i<0)||(i>=n))
                {
                    printf( "FINITE" );
                    exit(0);
                }
                if(step[i]==0)
                {
                    printf( "INFINITE" );
                    exit(0);
                }
                step[x]=0;
            }
        }
    }
    return 0;
}


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

int main()
{
    char direction[100000];
    int step [100000];
    int n, i, x;

    scanf( "%d", &n );
    for (i=0;i<n;i++)
    {
        scanf( "%s", &direction[i]);
        fflush( stdout );
    }
    for (i=0;i<n;i++)
    {
        scanf( "%d", &step[i] );
    }

    i=0;

    while(1)
    {
        x=i;
        if (direction[i]=='<')
        {
            i=i-step[i];
            if((i<0)||(i>=n))
            {
                printf( "FINITE" );
                exit(0);
            }
            if(step[i]==0)
            {
                printf( "INFINITE" );
                exit(0);
            }
            step[x]=0;
        }
        else
        {
            if(direction[i]=='>')
            {
                i=i+step[i];
                if((i<0)||(i>=n))
                {
                    printf( "FINITE" );
                    exit(0);
                }
                if(step[i]==0)
                {
                    printf( "INFINITE" );
                    exit(0);
                }
                step[x]=0;
            }

        }
    }
    return 0;
}


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

int main()
{
    char direction[100000];
    int step [100000];
    int n, i, x;

    scanf( "%d", &n );
    for (i=0;i<n;i++)
    {
        scanf( "%s", &direction);
        fflush( stdout );
    }
    for (i=0;i<n;i++)
    {
        scanf( "%d", &step[i] );
    }

    i=0;

    while(1)
    {
        x=i;
        if (direction[i]=='<')
        {
            i=i-step[i];
            if((i<0)||(i>=n))
            {
                printf( "FINITE" );
                exit(0);
            }
            if(step[i]==0)
            {
                printf( "INFINITE" );
                exit(0);
            }
            step[x]=0;
        }
        else
        {
            if(direction[i]=='>')
            {
                i=i+step[i];
                if((i<0)||(i>=n))
                {
                    printf( "FINITE" );
                    exit(0);
                }
                if(step[i]==0)
                {
                    printf( "INFINITE" );
                    exit(0);
                }
                step[x]=0;
            }
        }
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    long int n;
    int i,j,flag=0;
    scanf("%ld",&n);
    char a[n];
    long long int b[n],c=1;
    scanf("%s",&a);
    for (i=1;i<=n;i++)
        scanf("%lld",&b[i]);
    for(i=0;i<n;i++)
    {
        if(a[c-1]=='>')
            c=c+b[c];
        else if(a[c-1]=='<')
            c=c-b[c];
        if(c<1 || c>n)
            flag=1;
        if(flag==1)
            break;
    }
	if(flag==1)
		printf("FINITE\n");
	else
		printf("INFINITE\n");
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    long int n;
    int i,j,flag=0;
    scanf("%ld",&n);
    char a[n];
    long long int b[n],c=1;
    scanf("%s",&a);
    for (i=1;i<=n;i++)
        scanf("%lld",&b[i]);
    for(i=0;i<n;i++)
    {
        if(a[c-1]=='>')
            c=c+b[c];
        if(a[c-1]=='<')
            c=c-b[c];
        if(c<1 || c>n)
            flag=1;
        if(flag==1)
            break;
    }
	if(flag==1)
		printf("FINITE\n");
	else
		printf("INFINITE\n");
    return 0;
}


#include <stdio.h>

int main(void) {
	char a[100001];
	long long current,jump[100001],n,i;
	int flag = 1;
	scanf("%lld",&n);
	scanf("%s",a);
	for(i=0;i<n;i++)
	scanf("%lld",&jump[i]);
	current = 1;
    i=0;
    while(i<n && flag == 1){
    	if(a[i]=='>'){
    		current = i+1 + jump[i];
    	} else {
    		current = i+1 - jump[i];
    	}
    	if(current<1 || current>n){
    		flag = 0;
    	}
    	i++;
    }
    if(flag == 0){
    	printf("FINITE");
    } else {
    	printf("INFINITE");
    }
	return 0;
}


#include <stdio.h>
#include <string.h>

int main(void) {
	char a[100001];
	long long current,jump[100001],n,i;
	int flag = 1,visited[100001];
	memset(visited,0,sizeof(visited));
	scanf("%lld",&n);
	if(n==1){
		printf("FINITE");
		return 0;
	}
	scanf("%s",a);
	for(i=1;i<=n;i++)
	scanf("%lld",&jump[i]);
	current = 1;
    i=1;
    while(flag == 1){
    	visited[current]=1;
    	if(a[current-1]=='>'){
    		current = current + jump[current];
    	} else {
    		current = current - jump[current];
    	}
    	if(current<1 || current>n){
    		flag = 0;
    		break;
    	}
    	if(visited[current]==1){
    		break;
    	}
    }
    if(flag == 0){
    	printf("FINITE");
    } else {
    	printf("INFINITE");
    }
	return 0;
}


#include <stdio.h>
#include <string.h>

int main(void) {
	char a[100001];
	long long current,jump[100001],n,i;
	int flag = 1,visited[100001];
	memset(visited,0,sizeof(visited));
	scanf("%lld",&n);
	scanf("%s",a);
	for(i=1;i<=n;i++)
	scanf("%lld",&jump[i]);
	current = 1;
    i=1;
    while(flag == 1){
    	visited[current]=1;
    	if(a[current-1]=='>'){
    		current = current + jump[current];
    	} else {
    		current = current - jump[current];
    	}
    	if(current<1 || current>n){
    		flag = 0;
    	}
    	if(visited[current]==1){
    		break;
    	}
    }
    if(flag == 0){
    	printf("FINITE");
    } else {
    	printf("INFINITE");
    }
	return 0;
}


#include <stdio.h>
#include <string.h>

int main(void) {
	char a[100001];
	long long current,jump[100001],n,i;
	int flag = 1,visited[100001];
	memset(visited,0,sizeof(visited));
	scanf("%lld",&n);
	if(n==1){
		printf("FINITE");
		return 0;
	}
	scanf("%s",a);
	for(i=1;i<=n;i++)
	scanf("%lld",&jump[i]);
	current = 1;
    i=1;
    while(flag == 1){
    	visited[current]=1;
    	if(a[current-1]=='>'){
    		current = current + jump[current];
    	} else {
    		current = current - jump[current];
    	}
    	if(current<1 || current>n){
    		flag = 0;
    	}
    	if(visited[current]==1){
    		break;
    	}
    }
    if(flag == 0){
    	printf("FINITE");
    } else {
    	printf("INFINITE");
    }
	return 0;
}


/*l0in*/
#include <stdio.h>
#include <string.h>
const int max=1e5+10;
int main()
{
    int n, i, ans = 1;
    char cp[] = ">";
    while(scanf("%d", &n) != EOF)
    {
        char move[max];
        int step[n];
        scanf("%s", move+1);
        for (i = 1; i <= n; ++i)
        {
            scanf("%d", &step[i]);
        }
        for (i = 1; i <= n; i++)
        {
            if(move[ans]== '>') ans += step[ans];
            else ans -= step[ans];
            if(ans < 1 || ans > n)
            {
                printf("FINITE\n");
                return 0;
            }
        }
        printf("INFINITE\n");
        return 0;
    }
}


/*g4hz*/
#include<stdio.h>

const int max1=1e5+10;
int n,a[max1];
char str[max1];
int main()
{
    scanf("%d",&n);
    scanf("%s",str+1);
    int k=1;
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
    {
        if(str[k]=='>')
            k+=a[k];
        else
            k-=a[k];
        if(k<1||k>n)
        {
            printf("FINITE\n");
            return 0;
        }
    }
    printf("INFINITE\n");
    return 0;
}


/*kk7h*/
#include<stdio.h>
#include<math.h>
#include<string.h>
#define SZ 2000010
#define true 1
#define false 0
#define bool int
#define max(x,y) ((x) > (y) ? (x) : (y))
#define min(x,y) ((x) < (y) ? (x) : (y))

typedef long long LL;
const LL INF = 1000000010;
const LL mod = 1000000007;
const double eps = 1e-8;

LL read()
{
    LL n = 0;
    char a = getchar();
    int flag = 0;
    while(a < '0' || a > '9') { if(a == '-') flag = 1; a = getchar(); }
    while(a >= '0' && a <= '9') n = n * 10 + a - '0',a = getchar();
    if(flag) n = -n;
    return n;
}
int i,j;

int a[SZ],n,vis[SZ];
char s[SZ];

bool check()
{
    int pos = 1;
    while(233)
    {
        vis[pos] = 1;
        int d = a[pos];
        int t = s[pos] == '<' ? pos - d : pos + d;
        if(t <= 0 || t > n) return true;
        pos = t;
        if(vis[pos]) return false;
    }
}

int main()
{
    n = read();
    scanf("%s",s + 1);
    for(i = 1;i <= n;i ++)
        a[i] = read();
    if(check()) puts("FINITE");
    else puts("INFINITE");
    return 0;
}


#include <stdio.h>

int main(){
    long int n, i, casilla_actual;
    int flag=1;
    char signo;
    scanf("%ld%*c", &n);
    int direction[n];
    long int distance[n];
    for(i=0; i<n; i++){
        scanf("%c", &signo);
        if(signo=='>'){
            direction[i]=1;
        }
        else{
            direction[i]=-1;
        }
    }
    for(i=0; i<n; i++){
        scanf("%ld%*c", &distance[i]);
    }
    casilla_actual=1;
    for(i=0; i<n+1; i++){
            casilla_actual=casilla_actual+direction[casilla_actual-1]*distance[casilla_actual-1];
            if (casilla_actual>n||casilla_actual<1){
                flag=0;
                i=n+2;
            }
    }
    if(flag==0){
        printf("FINITE");
    }
    else{
        printf("INFINITE");
    }
    return 0;
}


#include <stdio.h>

int main(){
    long int n, i, casilla_actual;
    int flag=1;
    char signo;
    scanf("%ld%*c", &n);
    int direction[n];
    long int distance[n];
    for(i=0; i<n; i++){
        scanf("%c%*c", &signo);
        if(signo=='>'){
            direction[i]=1;
        }
        else{
            direction[i]=-1;
        }
    }
    for(i=0; i<n; i++){
        scanf("%ld", &distance[i]);
    }
    casilla_actual=1;
    for(i=0; i<n+1; i++){
            casilla_actual=casilla_actual+direction[casilla_actual-1]*distance[casilla_actual-1];
            if (casilla_actual>n||casilla_actual<1){
                flag=0;
                i=n+2;
            }
    }
    if(flag==0){
        printf("FINITE");
    }
    else{
        printf("INFINITE");
    }
}


#include <stdio.h>

int main(){
    long int n, i, casilla_actual;
    int flag=1;
    char signo;
    scanf("%ld%*c", &n);
    int direction[n];
    long int distance[n];
    for(i=0; i<n; i++){
        scanf("%c%*c", &signo);
        if(signo=='>'){
            direction[i]=1;
        }
        else{
            direction[i]=-1;
        }
    }
    for(i=0; i<n; i++){
        scanf("%ld%*c", &distance[i]);
    }
    casilla_actual=1;
    for(i=0; i<n+1; i++){
            casilla_actual=casilla_actual+direction[casilla_actual-1]*distance[casilla_actual-1];
            if (casilla_actual>n||casilla_actual<1){
                flag=0;
                i=n+2;
            }
    }
    if(flag==0){
        printf("FINITE");
    }
    else{
        printf("INFINITE");
    }
    return 0;
}


#include <stdio.h>

int main(){
    long int n, i, casilla_actual;
    int flag=1;
    char signo;
    scanf("%ld%*c", &n);
    int direction[n];
    long int distance[n];
    for(i=0; i<n; i++){
        scanf("%c%*c", &signo);
        if(signo=='>'){
            direction[i]=1;
        }
        else{
            direction[i]=-1;
        }
    }
    for(i=0; i<n; i++){
        scanf("%ld", &distance[i]);
    }
    casilla_actual=1;
    for(i=0; i<n+1; i++){
            casilla_actual=casilla_actual+direction[casilla_actual-1]*distance[casilla_actual-1];
            if (casilla_actual>n){
                flag=0;
                i=n+2;
            }
    }
    if(flag==0){
        printf("FINITE");
    }
    else{
        printf("INFINITE");
    }
}


#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>

#define N 102

char s[100002];
int v[1000002];
int n;

int go(int pos){
	if(pos >= n || pos < 0) return 1;
	else{
		if(s[pos] == 'X') return 0;
		int sig = (s[pos] == '>' ? 1: -1);
		s[pos] = 'X';
		return go(pos + sig*v[pos]);
	}
}

int main(){
	scanf("%d",&n);
	getchar();
	for(int i = 0; i < n; i ++) s[i] = getchar();
	getchar();
	for(int i = 0 ; i < n; i++) scanf("%d",&v[i]);

	if(go(0)) printf("FINITE\n");
	else printf("INFINITE\n");
	return 0;
}


#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>

#define N 102

char s[100002];
int v[1000002];
int n;

int go(int pos){
	if(pos > n || pos < 0) return 1;
	else{
		if(s[pos] == 'X') return 0;
		int sig = (s[pos] == '>' ? 1: -1);
		s[pos] = 'X';
		return go(pos + sig*v[pos]);
	}
}

int main(){
	scanf("%d",&n);
	getchar();
	for(int i = 0; i < n; i ++) s[i] = getchar();
	getchar();
	for(int i = 0 ; i < n; i++) scanf("%d",&v[i]);

	if(go(0)) printf("FINITE\n");
	else printf("INFINITE\n");
	return 0;
}


#include <stdio.h>

char Flag[100000];
char Str[100001];
int Offset[100000];

int main()
{
    int N, i;
    char outFlag = 0;
    scanf("%d %s", &N, Str);
    for(i = 0; i < N; ++i) {
        scanf("%d", &Offset[i]);
    }
    int s = 0;
    Flag[0] = 1;
    while(1) {
        int new;
        if(Str[s] == '>') {
            new = s + Offset[s];
        } else {
            new = s - Offset[s];
        }
        if(new < 0 || new >= N) {
            outFlag = 1;
            break;
        }
        if(Flag[new]) {
            break;
        }
        Flag[new] = 1;
        s = new;
    }
    puts(outFlag ? "FINITE" : "INFINITE");
    return 0;
}


#define N 100000
#include<stdio.h>
int main() {
	int n;
	scanf("%d",&n);
	int i;
	char dir[N];
	getchar();
	for(i=0;i<n;i++){
		dir[i]=getchar();
	}
	int jump[N];
	for(i=0;i<n;i++){
		scanf("%d",&jump[i]);
	}
	char see[N];
	for(i=0;i<n;i++){
		see[i]=0;
	}
	int at=0;
	int result=0;
	while(1){
		int next;
		if(see[at]){
			result=0;
			break;
		}
		if(dir[at]=='>'){
			next=at+jump[at];
		}else{
			next=at-jump[at];
		}
		if(next<0 || next>=n){
			result=1;
			break;
		}
		see[at]=1;
		at=next;
	}
	if(result==0){
		printf("INFINITE\n");
	}else{
		printf("FINITE\n");
	}
	return 0;
}