#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<pll> vpl;
typedef vector<int> vi;
#define int long long
inline ll mod(ll n, ll m){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0 ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);

}

const int N = 300100;
int b[N];

int32_t main(){
  fastio;
  int n;
  cin>>n;
  map<int,vector<int> > mp;

  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    mp[a].pb(i);
  }
  set<int> S;
  for(map<int,vector<int> >::iterator it = mp.begin();it!=mp.end();it++){
    int cur = it->first;
    vector<int> v = it->second;

    for(int x : v){
      S.insert(x);
    }

    if(S.size()){
      b[*S.begin()] = cur;
      S.erase(*S.begin());
    }
    if(S.size()){
      mp[cur+1];
    }

  }

  for(int i=0;i<n;i++)cout<<b[i]<<" ";
    cout<<endl;
  // Math -> gcd it all // check MAXN // check ll
  //did you check N=1? Did you mix up N,M?
}


#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<pll> vpl;
typedef vector<int> vi;
#define int long long
inline ll mod(ll n, ll m){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0 ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);

}

const int N = 300100;
int b[N];

int32_t main(){
  fastio;
  int n;
  cin>>n;
  map<int,vector<int> > mp;

  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    mp[a].pb(i);
  }

  for(map<int,vector<int> >::iterator it = mp.begin();it!=mp.end();it++){
    int cur = it->first;
    vector<int> v = it->second;
    if(v.size()==0)continue;
    b[v.back()] =cur;
    v.pop_back();
    vector<int> v2 = mp[cur+1];
    if(v2.size() < v.size()){
      for(int x : v2){
        v.pb(x);
      }
      mp[cur+1 ] = v;
    }else{
      for(int x : v){
        v2.pb(x);
      }
      mp[cur+1] = v2;
    }

  }

  for(int i=0;i<n;i++)cout<<b[i]<<" ";
    cout<<endl;
  // Math -> gcd it all // check MAXN // check ll
  //did you check N=1? Did you mix up N,M?
}


#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<pll> vpl;
typedef vector<int> vi;
#define int long long
inline ll mod(ll n, ll m){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0 ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);

}

const int N = 300100;
int b[N];

int32_t main(){
  fastio;
  int n;
  cin>>n;
  map<int,vector<int> > mp;

  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    mp[a].pb(i);
  }

  for(map<int,vector<int> >::iterator it = mp.begin();it!=mp.end();it++){
    int cur = it->first;
    vector<int> v = it->second;
    if(v.size()==0)continue;
    b[v.back()] =cur;
    v.pop_back();
    vector<int> v2 = mp[cur+1];
    if(v.size()<v2.size()){
      v.swap(v2);
    }
    for(int x : v2){
      v.pb(x);
    }
    mp[cur+1].swap(v);

    mp[cur] = vector<int>();
  }

  for(int i=0;i<n;i++)cout<<b[i]<<" ";
    cout<<endl;
  // Math -> gcd it all // check MAXN // check ll
  //did you check N=1? Did you mix up N,M?
}


#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<pll> vpl;
typedef vector<int> vi;
#define int long long
inline ll mod(ll n, ll m){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0 ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);

}

const int N = 300100;
int s[N];
int ini[N],fim[N];

int32_t main(){
  fastio;
  int k,x,n,m;
  cin>>k>>x>>n>>m;
  fim[1] = ini[1] = 1;
  fim[2] = ini[2] = 2;
 /*
  fim[3] = 1;
  ini[3] = 2;
  fim[4] = 2;
  ini[4] = 1;
  fim[5] = 2;
  ini[5] = 2;
  */
  for(int y=3;y<=50;y++){
    ini[y] = ini[y-2];
    fim[y] = fim[y-1];
  }

  auto tam = [&](int a){
    if(a==0)return 0;
    if(a==3)return 2;
    return 1;
  };

  for(int it1=0;it1<=3;it1++){

    for(int it2=0;it2<=3;it2++){

      for(int i=0;i<=n- tam(it1);i++){
        for(int j=0;j<=m - tam(it2);j++){

          s[1] = i/2;
          s[2] = j/2;
          // 0->nada;
          // 1->ini;
          // 2->fim;
          // 3->tudo;
          for(int y = 3;y<=k;y++){
            s[y] = s[y-2] + s[y-1];
            int ok = 0;

            if(ini[y]==1){
              if(it1&1)ok|=1;
            }else if(it2&1)ok|=1;
            if(fim[y]==1){
              if(it1&2)ok|=2;
            }else if(it2&2)ok|=2;

            if(ok==3)s[y]++;
          }

          if(s[k]==x){
                // NICE

                string s1="",s2="";
                if(it1&1){
                  n--;
                }
                if(it2&1){
                  m--;
                }
                if(it1&2){
                  n--;
                  s1+='C';
                }
                if(it2&2){
                  m--;
                  s2+='C';
                }

                for(int kk=0;kk<s[1]*2;kk+=2){
                      s1+='A';
                      s1+='C';
                    }
                    for(int kk = s[1]*2;kk<n;kk++){
                      s1+='D';
                    }
                    for(int kk = 0;kk < s[2]*2;kk+=2){
                      s2+='A';
                      s2+='C';
                    }
                    for(int kk=s[2]*2;kk<m;kk++){
                      s2+='D';
                    }

                if(it1&1)s1+='A';
                if(it2&1)s2+='A';

                cout<<s1<<endl;
                cout<<s2<<endl;

                return 0;
              }

            }
      }

    }

  }

  cout<< "Happy new year!"<<endl;

  // Math -> gcd it all // check MAXN // check ll
  //did you check N=1? Did you mix up N,M?
}


#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<pll> vpl;
typedef vector<int> vi;
#define int long long
inline ll mod(ll n, ll m){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0 ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);

}

const int N = 300100;
int b[N];

int32_t main(){
  fastio;
  int n;
  cin>>n;
  map<int,vector<int> > mp;

  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    mp[a].pb(i);
  }

  for(map<int,vector<int> >::iterator it = mp.begin();it!=mp.end();it++){
    int cur = it->first;
    vector<int> v = it->second;
    if(v.size()==0)continue;
    b[v.back()] =cur;
    v.pop_back();
    vector<int> v2 = mp[cur+1];
    if(v2.size() < v.size()){
      for(int x : v2){
        v2.pb(x);
      }
      mp[cur+1 ] = v;
    }else{
      for(int x : v){
        v2.pb(x);
      }
      mp[cur+1] = v2;
    }

  }

  for(int i=0;i<n;i++)cout<<b[i]<<" ";
    cout<<endl;
  // Math -> gcd it all // check MAXN // check ll
  //did you check N=1? Did you mix up N,M?
}


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

const int maxn = 3e5+5;
int n;
struct number{
    int m, id;
}num[maxn];

bool cmp_1(number x, number y)
{
    if(x.m != y.m)
        return x.m < y.m;
    return x.id < y.id;
}

bool cmp_2(number x, number y)
{
    return x.id < y.id;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> num[i].m;
        num[i].id = i;
    }
    sort(num, num+n, cmp_1);

    for(int i = 1; i < n; i++)
    {
        while(num[i].m <= num[i-1].m)
            num[i].m++;
    }
    sort(num, num+n, cmp_2);

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


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

const int maxn = 3e5+5;
int n;
struct number{
    int m, id;
}num[maxn];

bool cmp_1(number x, number y)
{
        return x.m < y.m;
}

bool cmp_2(number x, number y)
{
    return x.id < y.id;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> num[i].m;
        num[i].id = i;
    }
    sort(num, num+n, cmp_1);

    for(int i = 1; i < n; i++)
    {
        while(num[i].m <= num[i-1].m)
            num[i].m++;
    }
    sort(num, num+n, cmp_2);

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


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

const int maxn = 3e5+5;
int n;
struct number{
    int m, id;
}num[maxn];

bool cmp_1(number x, number y)
{
        return x.m < y.m;
}

bool cmp_2(number x, number y)
{
    return x.id < y.id;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> num[i].m;
        num[i].id = i;
    }
    sort(num, num+n, cmp_1);

    for(int i = 1; i < n; i++)
    {
        if(num[i].m <= num[i-1].m)
            num[i].m = num[i-1].m + 1;
    }
    sort(num, num+n, cmp_2);

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


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

const int maxn = 3e5+5;
int n;
struct number{
    int m, id;
}num[maxn];

bool cmp_1(number x, number y)
{
    if(x.m != y.m)
        return x.m < y.m;
    return x.id < y.id;
}

bool cmp_2(number x, number y)
{
    return x.id < y.id;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> num[i].m;
        num[i].id = i;
    }
    sort(num, num+n, cmp_1);

    for(int i = 1; i < n; i++)
    {
        if(num[i].m <= num[i-1].m)
            num[i].m++;
    }
    sort(num, num+n, cmp_2);

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


#include<bits/stdc++.h>
using namespace std;
int ans[200005],x,prev;
vector<pair<int,int> >b;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		b.push_back(make_pair(x,i));
	}
	sort(b.begin(),b.end());
	prev=b[0].first;
	ans[b[0].second]=prev;
	for(int i=1;i<n;i++)//a
	{
		if(prev<b[i].first)
		{
			prev=b[i].first;
			ans[b[i].second]=prev;
		}
		else
		{
			prev++;
			ans[b[i].second]=prev;
		}
	}
	for(int i=0;i<n;i++)
	cout<<ans[i]<<" ";
}


#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int> >b;
int main()
{
	int ans[300005],x,prev,n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		b.push_back(make_pair(x,i));
	}
	sort(b.begin(),b.end());
	prev=b[0].first;
	ans[b[0].second]=prev;
	for(int i=1;i<n;i++)
	{
		if(prev<b[i].first)
		{
			prev=b[i].first;
			ans[b[i].second]=prev;
		}
		else
		{
			prev++;
			ans[b[i].second]=prev;
		}
	}
	for(int i=0;i<n;i++)
	cout<<ans[i]<<" ";
}


#include<bits/stdc++.h>
using namespace std;
int ans[200005],x,prev;
vector<pair<int,int> >b;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		b.push_back(make_pair(x,i));
	}
	sort(b.begin(),b.end());
	prev=b[0].first;
	ans[b[0].second]=prev;
	for(int i=1;i<n;i++)
	{
		if(prev<b[i].first)
		{
			prev=b[i].first;
			ans[b[i].second]=prev;
		}
		else
		{
			prev++;
			ans[b[i].second]=prev;
		}
	}
	for(int i=0;i<n;i++)//b
	cout<<ans[i]<<" ";
}


#include<bits/stdc++.h>
using namespace std;
int ans[300005],x,previ,n;
vector<pair<int,int> >b;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		b.push_back(make_pair(x,i));
	}
	sort(b.begin(),b.end());
	previ=b[0].first;
	ans[b[0].second]=previ;
	for(int i=1;i<n;i++)
	{
		if(previ<b[i].first)
		{
			previ=b[i].first;
			ans[b[i].second]=previ;
		}
		else
		{
			previ++;
			ans[b[i].second]=previ;
		}
	}
	for(int i=0;i<n;i++)
	cout<<ans[i]<<" ";
}


#include<bits/stdc++.h>
using namespace std;
int ans[200005],x,prev;
vector<pair<int,int> >b;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		b.push_back(make_pair(x,i));
	}
	sort(b.begin(),b.end());
	prev=b[0].first;
	ans[b[0].second]=prev;
	for(int i=1;i<n;i++)
	{
		if(prev<b[i].first)
		{
			prev=b[i].first;
			ans[b[i].second]=prev;
		}
		else
		{
			prev++;
			ans[b[i].second]=prev;
		}
	}
	for(int i=0;i<n;i++)
	cout<<ans[i]<<" ";
}


#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int> >b;
int main()
{
	int ans[200005],x,prev,n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		b.push_back(make_pair(x,i));
	}
	sort(b.begin(),b.end());
	prev=b[0].first;
	ans[b[0].second]=prev;
	for(int i=1;i<n;i++)
	{
		if(prev<b[i].first)
		{
			prev=b[i].first;
			ans[b[i].second]=prev;
		}
		else
		{
			prev++;
			ans[b[i].second]=prev;
		}
	}
	for(int i=0;i<n;i++)
	cout<<ans[i]<<" ";
}


#include<bits/stdc++.h>
#define ss second
#define ff first
#define pb push_back
#define nn <<endl
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int siz = 2e5+5;
int n,m,a[siz],out[siz];
set<int>s;
bool is_ok(int num)
{
    if(s.find(num) == s.end()) return true; return false;
}
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);

   cin>>n;
   vector<pair<int,int> >v;
   for(int i = 1;i<=n;i++)
   {
       int x; cin>>x;
       v.pb({x,i});
   }
   sort(v.begin(),v.end());
   for(int i = 0;i<v.size();i++)
   {
       int cur = v[i].first,ind = v[i].second;
       int ans = cur,l = cur,r = 1e9;
       while(l<=r)
       {
           int mid = l+(r-l)/2;
           if(is_ok(mid))
           {
               ans = mid;
               r = mid-1;
           }
           else l = mid+1;
       }
       s.insert(ans);
       out[ind] = ans;
   }
   for(int i = 1;i<=n;i++) cout<<out[i]<<" ";
}


#include<bits/stdc++.h>
#define ss second
#define ff first
#define pb push_back
#define nn <<endl
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int siz = 3e5+5;
int n,m,a[siz],out[siz];
set<int>s;
bool is_ok(int num)
{
    if(s.find(num) == s.end()) return true; return false;
}
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);

   cin>>n;
   vector<pair<int,int> >v;
   for(int i = 1;i<=n;i++)
   {
       int x; cin>>x;
       v.pb({x,i});
   }
   sort(v.begin(),v.end());
   for(int i = 0;i<v.size();i++)
   {
       int cur = v[i].first,ind = v[i].second;
       int ans = cur,l = cur,r = 1e9;
       while(l<=r)
       {
           int mid = l+(r-l)/2;
           if(is_ok(mid))
           {
               ans = mid;
               r = mid-1;
           }
           else l = mid+1;
       }
       s.insert(ans);
       out[ind] = ans;
   }
   for(int i = 1;i<=n;i++) cout<<out[i]<<" ";
}


#include<bits/stdc++.h>
#define ss second
#define ff first
#define pb push_back
#define nn <<endl
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int siz = 3e5+5;
int n,m,a[siz],out[siz];
set<ll>s;
bool is_ok(ll num)
{
    if(s.find(num) == s.end()) return true; return false;
}
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);

   cin>>n;
   vector<pair<ll,ll> >v;
   for(int i = 1;i<=n;i++)
   {
       int x; cin>>x;
       v.pb({x,i});
   }
   sort(v.begin(),v.end()); int sofar = 0;
   for(int i = 0;i<v.size();i++)
   {
       int cur = v[i].first,ind = v[i].second;
       if(cur>sofar)
       {
           sofar = cur; out[ind] = sofar;
       }
       else
       {
           out[ind] = ++sofar;
       }
   }
   for(ll i = 1;i<=n;i++) cout<<out[i]<<" ";
}


#include<bits/stdc++.h>
#define ss second
#define ff first
#define pb push_back
#define nn <<endl
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int siz = 3e5+5;
int n,m,a[siz],out[siz];
set<ll>s;
bool is_ok(ll num)
{
    if(s.find(num) == s.end()) return true; return false;
}
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);

   cin>>n;
   vector<pair<ll,ll> >v;
   for(ll i = 1;i<=n;i++)
   {
       ll x; cin>>x;
       v.pb({x,i});
   }
   sort(v.begin(),v.end());
   for(ll i = 0;i<v.size();i++)
   {
       ll cur = v[i].first,ind = v[i].second;
       ll ans = cur,l = cur,r = 1e9;
       while(l<=r)
       {
           ll mid = l+(r-l)/2;
           if(is_ok(mid))
           {
               ans = mid;
               r = mid-1;
           }
           else l = mid+1;
       }
       s.insert(ans);
       out[ind] = ans;
   }
   for(ll i = 1;i<=n;i++) cout<<out[i]<<" ";
}


/**Bismillah-ir-Rahman-ir-Rahim**/
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,n) for(LL i=0; i<n; i++)
#define RFOR(i,n) for(LL i=n-1; i>=0; i--)
#define FILL(A,value) memset(A,value,sizeof(A))
#define LL long long int
#define sI(a) scanf("%d",&a)
#define pI(a) printf("%d",a)
#define sI2(a,b) sI(a),sI(b)
#define pI2(a,b) pI(a) , pI(b)
#define sL(a) scanf("%lld",&a)
#define pL(a) printf("%lld",a)
#define sL2(a,b) sL(a),sL(b)
#define pL2(a,b) pL(a) , pL(b)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define pN printf("\n")
#define pS printf(" ");
#define MAX 2000100
#define MX 200001
#define PI 3.14159
#define pb push_back
#define MOD 1000000007
inline int gcd(int a, int b){return (b == 0 ? a : gcd(b, a % b));}
inline int lcm(int a, int b){return (a * (b / gcd(a, b))); }
inline LL bigmod(LL a,LL b,LL m){if(b==0)return 1%m;LL x=bigmod(a,b/2,m);x=(x*x)%m;if(b%2==1){x=(x*a)%m;}return x;}
inline LL phi(LL n) {LL ret=n;for(LL i=2; i*i<=n; i++){if(n%i==0){while(n%i==0)n/=i;}ret-=ret/i;}if(n>1){ret-=ret/n;}return ret;}
LL missing_number(LL A[],LL n){LL x1=A[0],x2=1;for(int i=1; i<n; i++)x1^=A[i];for(int i=2; i<=n+1; i++)x2^=i;return (x1^x2);}
bool isFibo(LL n){LL A=(5*n*n+4);LL B=(5*n*n-4); LL C=sqrt(A); LL D=sqrt(B); return (A==(C*C)||B==(D*D));}
LL classini(LL n){return (n&1)? -1: 1;} // f(n-1)*f(n+1) - f(n)*f(n)
LL factorial(int n){return (n == 1 || n == 0) ? 1 : factorial(n - 1) * n;}
LL catanal(LL n) {return (factorial(2*n)/((factorial(n+1)*factorial(n))));}//Dyck path// //1,1,2,5,14,42,132,429,1430,4862,16796,58786, 208012, 742900, 2674440, 9694845, 35357670, 129644790, 477638700, 1767263190, 6564120420, 24466267020, 91482563640, 343059613650, 1289904147324, 4861946401452
string orientation_3_ordered_point(vector< pair<int,int> >V){LL value=(V[1].second-V[0].second)*(V[2].first-V[1].first)-(V[1].first*V[0].first)*(V[2].second-V[1].second);string res;if(value==0)res="colinear";value ==1 ? res="clockwise" : res="counterclockwise";return res;}
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};

string make_string(LL num){stringstream ss;ss<<num;string s;ss>>s;return s;}
LL make_num(string s){stringstream ss;LL tmp;ss<<s;ss>>tmp;return tmp;}

int SET(int mask,int pos){return (mask|(1<<pos));}
int check(int mask,int pos){return (mask&(1<<pos));}

map<LL,int>Chai;
map<LL,int>Ano;
LL res[1010110];

int main(){
    int n;
    sI(n);
    for(int i=1; i<=n; i++){
        int num;
        cin>>num;
        if(Chai[num]==0){
            Chai[num]=1;
            res[i]=num;
        }
        else{
            LL cur=num;
            while(Chai[cur]!=0){
                cur=cur+1;
            }
            Chai[cur]=1;
            res[i]=cur;
        }
    }
    for(int i=1; i<=n; i++)cout<<res[i]<<" ";
    return 0;
}


/**Bismillah-ir-Rahman-ir-Rahim**/
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,n) for(LL i=0; i<n; i++)
#define RFOR(i,n) for(LL i=n-1; i>=0; i--)
#define FILL(A,value) memset(A,value,sizeof(A))
#define LL long long int
#define sI(a) scanf("%d",&a)
#define pI(a) printf("%d",a)
#define sI2(a,b) sI(a),sI(b)
#define pI2(a,b) pI(a) , pI(b)
#define sL(a) scanf("%lld",&a)
#define pL(a) printf("%lld",a)
#define sL2(a,b) sL(a),sL(b)
#define pL2(a,b) pL(a) , pL(b)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define pN printf("\n")
#define pS printf(" ");
#define MAX 2000100
#define MX 200001
#define PI 3.14159
#define pb push_back
#define MOD 1000000007
inline int gcd(int a, int b){return (b == 0 ? a : gcd(b, a % b));}
inline int lcm(int a, int b){return (a * (b / gcd(a, b))); }
inline LL bigmod(LL a,LL b,LL m){if(b==0)return 1%m;LL x=bigmod(a,b/2,m);x=(x*x)%m;if(b%2==1){x=(x*a)%m;}return x;}
inline LL phi(LL n) {LL ret=n;for(LL i=2; i*i<=n; i++){if(n%i==0){while(n%i==0)n/=i;}ret-=ret/i;}if(n>1){ret-=ret/n;}return ret;}
LL missing_number(LL A[],LL n){LL x1=A[0],x2=1;for(int i=1; i<n; i++)x1^=A[i];for(int i=2; i<=n+1; i++)x2^=i;return (x1^x2);}
bool isFibo(LL n){LL A=(5*n*n+4);LL B=(5*n*n-4); LL C=sqrt(A); LL D=sqrt(B); return (A==(C*C)||B==(D*D));}
LL classini(LL n){return (n&1)? -1: 1;} // f(n-1)*f(n+1) - f(n)*f(n)
LL factorial(int n){return (n == 1 || n == 0) ? 1 : factorial(n - 1) * n;}
LL catanal(LL n) {return (factorial(2*n)/((factorial(n+1)*factorial(n))));}//Dyck path// //1,1,2,5,14,42,132,429,1430,4862,16796,58786, 208012, 742900, 2674440, 9694845, 35357670, 129644790, 477638700, 1767263190, 6564120420, 24466267020, 91482563640, 343059613650, 1289904147324, 4861946401452
string orientation_3_ordered_point(vector< pair<int,int> >V){LL value=(V[1].second-V[0].second)*(V[2].first-V[1].first)-(V[1].first*V[0].first)*(V[2].second-V[1].second);string res;if(value==0)res="colinear";value ==1 ? res="clockwise" : res="counterclockwise";return res;}
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};

string make_string(LL num){stringstream ss;ss<<num;string s;ss>>s;return s;}
LL make_num(string s){stringstream ss;LL tmp;ss<<s;ss>>tmp;return tmp;}

int SET(int mask,int pos){return (mask|(1<<pos));}
int check(int mask,int pos){return (mask&(1<<pos));}

pair<LL,int>IND[2020200];
map<LL,int>Freq;
int res[1010101];

int main(){
    int n;
    sI(n);
    for(int i=1; i<=n; i++){
        LL num;
        sL(num);
        IND[i].first=num;
        IND[i].second=i;
    }
    sort(IND+1,IND+n+1);
    LL e=0;
    for(int i=1; i<=n; i++){
        e++;
        e=max(e,IND[i].first);
        res[IND[i].second]=e;
    }
    for(int i=1; i<=n; i++){
        cout<<res[i]<<" ";
    }
    return 0;
}


/**Bismillah-ir-Rahman-ir-Rahim**/
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,n) for(LL i=0; i<n; i++)
#define RFOR(i,n) for(LL i=n-1; i>=0; i--)
#define FILL(A,value) memset(A,value,sizeof(A))
#define LL long long int
#define sI(a) scanf("%d",&a)
#define pI(a) printf("%d",a)
#define sI2(a,b) sI(a),sI(b)
#define pI2(a,b) pI(a) , pI(b)
#define sL(a) scanf("%lld",&a)
#define pL(a) printf("%lld",a)
#define sL2(a,b) sL(a),sL(b)
#define pL2(a,b) pL(a) , pL(b)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define pN printf("\n")
#define pS printf(" ");
#define MAX 2000100
#define MX 200001
#define PI 3.14159
#define pb push_back
#define MOD 1000000007
inline int gcd(int a, int b){return (b == 0 ? a : gcd(b, a % b));}
inline int lcm(int a, int b){return (a * (b / gcd(a, b))); }
inline LL bigmod(LL a,LL b,LL m){if(b==0)return 1%m;LL x=bigmod(a,b/2,m);x=(x*x)%m;if(b%2==1){x=(x*a)%m;}return x;}
inline LL phi(LL n) {LL ret=n;for(LL i=2; i*i<=n; i++){if(n%i==0){while(n%i==0)n/=i;}ret-=ret/i;}if(n>1){ret-=ret/n;}return ret;}
LL missing_number(LL A[],LL n){LL x1=A[0],x2=1;for(int i=1; i<n; i++)x1^=A[i];for(int i=2; i<=n+1; i++)x2^=i;return (x1^x2);}
bool isFibo(LL n){LL A=(5*n*n+4);LL B=(5*n*n-4); LL C=sqrt(A); LL D=sqrt(B); return (A==(C*C)||B==(D*D));}
LL classini(LL n){return (n&1)? -1: 1;} // f(n-1)*f(n+1) - f(n)*f(n)
LL factorial(int n){return (n == 1 || n == 0) ? 1 : factorial(n - 1) * n;}
LL catanal(LL n) {return (factorial(2*n)/((factorial(n+1)*factorial(n))));}//Dyck path// //1,1,2,5,14,42,132,429,1430,4862,16796,58786, 208012, 742900, 2674440, 9694845, 35357670, 129644790, 477638700, 1767263190, 6564120420, 24466267020, 91482563640, 343059613650, 1289904147324, 4861946401452
string orientation_3_ordered_point(vector< pair<int,int> >V){LL value=(V[1].second-V[0].second)*(V[2].first-V[1].first)-(V[1].first*V[0].first)*(V[2].second-V[1].second);string res;if(value==0)res="colinear";value ==1 ? res="clockwise" : res="counterclockwise";return res;}
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};

string make_string(LL num){stringstream ss;ss<<num;string s;ss>>s;return s;}
LL make_num(string s){stringstream ss;LL tmp;ss<<s;ss>>tmp;return tmp;}

int SET(int mask,int pos){return (mask|(1<<pos));}
int check(int mask,int pos){return (mask&(1<<pos));}

map<LL,int>Chai;
LL res[1010110];

int main(){
    int n;
    sI(n);
    for(int i=1; i<=n; i++){
        int num;
        cin>>num;
        Chai[num]++;
        res[i]=(num+Chai[num]-1);
    }
    sort(res+1,res+n+1);
    for(int i=1; i<=n; i++)cout<<res[i]<<" ";
    return 0;
}


/**Bismillah-ir-Rahman-ir-Rahim**/
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,n) for(LL i=0; i<n; i++)
#define RFOR(i,n) for(LL i=n-1; i>=0; i--)
#define FILL(A,value) memset(A,value,sizeof(A))
#define LL long long int
#define sI(a) scanf("%d",&a)
#define pI(a) printf("%d",a)
#define sI2(a,b) sI(a),sI(b)
#define pI2(a,b) pI(a) , pI(b)
#define sL(a) scanf("%lld",&a)
#define pL(a) printf("%lld",a)
#define sL2(a,b) sL(a),sL(b)
#define pL2(a,b) pL(a) , pL(b)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define pN printf("\n")
#define pS printf(" ");
#define MAX 2000100
#define MX 200001
#define PI 3.14159
#define pb push_back
#define MOD 1000000007
inline int gcd(int a, int b){return (b == 0 ? a : gcd(b, a % b));}
inline int lcm(int a, int b){return (a * (b / gcd(a, b))); }
inline LL bigmod(LL a,LL b,LL m){if(b==0)return 1%m;LL x=bigmod(a,b/2,m);x=(x*x)%m;if(b%2==1){x=(x*a)%m;}return x;}
inline LL phi(LL n) {LL ret=n;for(LL i=2; i*i<=n; i++){if(n%i==0){while(n%i==0)n/=i;}ret-=ret/i;}if(n>1){ret-=ret/n;}return ret;}
LL missing_number(LL A[],LL n){LL x1=A[0],x2=1;for(int i=1; i<n; i++)x1^=A[i];for(int i=2; i<=n+1; i++)x2^=i;return (x1^x2);}
bool isFibo(LL n){LL A=(5*n*n+4);LL B=(5*n*n-4); LL C=sqrt(A); LL D=sqrt(B); return (A==(C*C)||B==(D*D));}
LL classini(LL n){return (n&1)? -1: 1;} // f(n-1)*f(n+1) - f(n)*f(n)
LL factorial(int n){return (n == 1 || n == 0) ? 1 : factorial(n - 1) * n;}
LL catanal(LL n) {return (factorial(2*n)/((factorial(n+1)*factorial(n))));}//Dyck path// //1,1,2,5,14,42,132,429,1430,4862,16796,58786, 208012, 742900, 2674440, 9694845, 35357670, 129644790, 477638700, 1767263190, 6564120420, 24466267020, 91482563640, 343059613650, 1289904147324, 4861946401452
string orientation_3_ordered_point(vector< pair<int,int> >V){LL value=(V[1].second-V[0].second)*(V[2].first-V[1].first)-(V[1].first*V[0].first)*(V[2].second-V[1].second);string res;if(value==0)res="colinear";value ==1 ? res="clockwise" : res="counterclockwise";return res;}
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};

string make_string(LL num){stringstream ss;ss<<num;string s;ss>>s;return s;}
LL make_num(string s){stringstream ss;LL tmp;ss<<s;ss>>tmp;return tmp;}

int SET(int mask,int pos){return (mask|(1<<pos));}
int check(int mask,int pos){return (mask&(1<<pos));}

pair<LL,int>IND[2020200];
map<LL,int>Freq;
int res[1010101];

int main(){
    int n;
    sI(n);
    for(int i=1; i<=n; i++){
        LL num;
        sL(num);
        IND[i].first=num;
        IND[i].second=i;
    }
    sort(IND+1,IND+n+1);
    for(int i=1; i<=n; i++){
        if(Freq[IND[i].first]==0){
            res[IND[i].second]=IND[i].first;
            Freq[IND[i].first]=1;
        }
        else{
            res[IND[i].second]=IND[i].first+Freq[IND[i].first];
            Freq[IND[i].first+Freq[IND[i].first]]=1;
            Freq[IND[i].first]++;
        }
    }
    for(int i=1; i<=n; i++){
        cout<<res[i]<<" ";
    }
    return 0;
}


/**Bismillah-ir-Rahman-ir-Rahim**/
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,n) for(LL i=0; i<n; i++)
#define RFOR(i,n) for(LL i=n-1; i>=0; i--)
#define FILL(A,value) memset(A,value,sizeof(A))
#define LL long long int
#define sI(a) scanf("%d",&a)
#define pI(a) printf("%d",a)
#define sI2(a,b) sI(a),sI(b)
#define pI2(a,b) pI(a) , pI(b)
#define sL(a) scanf("%lld",&a)
#define pL(a) printf("%lld",a)
#define sL2(a,b) sL(a),sL(b)
#define pL2(a,b) pL(a) , pL(b)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define pN printf("\n")
#define pS printf(" ");
#define MAX 2000100
#define MX 200001
#define PI 3.14159
#define pb push_back
#define MOD 1000000007
inline int gcd(int a, int b){return (b == 0 ? a : gcd(b, a % b));}
inline int lcm(int a, int b){return (a * (b / gcd(a, b))); }
inline LL bigmod(LL a,LL b,LL m){if(b==0)return 1%m;LL x=bigmod(a,b/2,m);x=(x*x)%m;if(b%2==1){x=(x*a)%m;}return x;}
inline LL phi(LL n) {LL ret=n;for(LL i=2; i*i<=n; i++){if(n%i==0){while(n%i==0)n/=i;}ret-=ret/i;}if(n>1){ret-=ret/n;}return ret;}
LL missing_number(LL A[],LL n){LL x1=A[0],x2=1;for(int i=1; i<n; i++)x1^=A[i];for(int i=2; i<=n+1; i++)x2^=i;return (x1^x2);}
bool isFibo(LL n){LL A=(5*n*n+4);LL B=(5*n*n-4); LL C=sqrt(A); LL D=sqrt(B); return (A==(C*C)||B==(D*D));}
LL classini(LL n){return (n&1)? -1: 1;} // f(n-1)*f(n+1) - f(n)*f(n)
LL factorial(int n){return (n == 1 || n == 0) ? 1 : factorial(n - 1) * n;}
LL catanal(LL n) {return (factorial(2*n)/((factorial(n+1)*factorial(n))));}//Dyck path// //1,1,2,5,14,42,132,429,1430,4862,16796,58786, 208012, 742900, 2674440, 9694845, 35357670, 129644790, 477638700, 1767263190, 6564120420, 24466267020, 91482563640, 343059613650, 1289904147324, 4861946401452
string orientation_3_ordered_point(vector< pair<int,int> >V){LL value=(V[1].second-V[0].second)*(V[2].first-V[1].first)-(V[1].first*V[0].first)*(V[2].second-V[1].second);string res;if(value==0)res="colinear";value ==1 ? res="clockwise" : res="counterclockwise";return res;}
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};

string make_string(LL num){stringstream ss;ss<<num;string s;ss>>s;return s;}
LL make_num(string s){stringstream ss;LL tmp;ss<<s;ss>>tmp;return tmp;}

int SET(int mask,int pos){return (mask|(1<<pos));}
int check(int mask,int pos){return (mask&(1<<pos));}

pair<LL,int>IND[2020200];
map<LL,int>Freq;
int res[1010101];

int main(){
    int n;
    sI(n);
    for(int i=1; i<=n; i++){
        LL num;
        sL(num);
        IND[i].first=num;
        IND[i].second=i;
    }
    sort(IND+1,IND+n+1);
    for(int i=1; i<=n; i++){
        if(Freq[IND[i].first]==0){
            res[IND[i].second]=IND[i].first;
            Freq[IND[i].first]=1;
        }
        else{
            res[IND[i].second]=IND[i].first+Freq[IND[i].first];
            Freq[IND[i].first+Freq[IND[i].first]]++;
            Freq[IND[i].first]++;
        }
    }
    for(int i=1; i<=n; i++){
        cout<<res[i]<<" ";
    }
    return 0;
}


/**Bismillah-ir-Rahman-ir-Rahim**/
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,n) for(LL i=0; i<n; i++)
#define RFOR(i,n) for(LL i=n-1; i>=0; i--)
#define FILL(A,value) memset(A,value,sizeof(A))
#define LL long long int
#define sI(a) scanf("%d",&a)
#define pI(a) printf("%d",a)
#define sI2(a,b) sI(a),sI(b)
#define pI2(a,b) pI(a) , pI(b)
#define sL(a) scanf("%lld",&a)
#define pL(a) printf("%lld",a)
#define sL2(a,b) sL(a),sL(b)
#define pL2(a,b) pL(a) , pL(b)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define pN printf("\n")
#define pS printf(" ");
#define MAX 2000100
#define MX 200001
#define PI 3.14159
#define pb push_back
#define MOD 1000000007
inline int gcd(int a, int b){return (b == 0 ? a : gcd(b, a % b));}
inline int lcm(int a, int b){return (a * (b / gcd(a, b))); }
inline LL bigmod(LL a,LL b,LL m){if(b==0)return 1%m;LL x=bigmod(a,b/2,m);x=(x*x)%m;if(b%2==1){x=(x*a)%m;}return x;}
inline LL phi(LL n) {LL ret=n;for(LL i=2; i*i<=n; i++){if(n%i==0){while(n%i==0)n/=i;}ret-=ret/i;}if(n>1){ret-=ret/n;}return ret;}
LL missing_number(LL A[],LL n){LL x1=A[0],x2=1;for(int i=1; i<n; i++)x1^=A[i];for(int i=2; i<=n+1; i++)x2^=i;return (x1^x2);}
bool isFibo(LL n){LL A=(5*n*n+4);LL B=(5*n*n-4); LL C=sqrt(A); LL D=sqrt(B); return (A==(C*C)||B==(D*D));}
LL classini(LL n){return (n&1)? -1: 1;} // f(n-1)*f(n+1) - f(n)*f(n)
LL factorial(int n){return (n == 1 || n == 0) ? 1 : factorial(n - 1) * n;}
LL catanal(LL n) {return (factorial(2*n)/((factorial(n+1)*factorial(n))));}//Dyck path// //1,1,2,5,14,42,132,429,1430,4862,16796,58786, 208012, 742900, 2674440, 9694845, 35357670, 129644790, 477638700, 1767263190, 6564120420, 24466267020, 91482563640, 343059613650, 1289904147324, 4861946401452
string orientation_3_ordered_point(vector< pair<int,int> >V){LL value=(V[1].second-V[0].second)*(V[2].first-V[1].first)-(V[1].first*V[0].first)*(V[2].second-V[1].second);string res;if(value==0)res="colinear";value ==1 ? res="clockwise" : res="counterclockwise";return res;}
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};

string make_string(LL num){stringstream ss;ss<<num;string s;ss>>s;return s;}
LL make_num(string s){stringstream ss;LL tmp;ss<<s;ss>>tmp;return tmp;}

int SET(int mask,int pos){return (mask|(1<<pos));}
int check(int mask,int pos){return (mask&(1<<pos));}

map<LL,int>Chai;
LL res[1010110];

int main(){
    int n;
    sI(n);
    for(int i=1; i<=n; i++){
        int num;
        cin>>num;
        Chai[num]++;
        res[i]=(num+Chai[num]-1);
    }
    for(int i=1; i<=n; i++)cout<<res[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    long long n,x;
    cin>>n;
    vector<pair<int,int> >v,ans;
    for(int i=0; i<n; i++)
        cin>>x,v.push_back({x,i});
    x=1;
    sort(v.begin(),v.end());
    for(int i=0; i<n; i++)
    {
        if(v[i].first==x)
            ans.push_back({v[i].second,x++});
        else if(v[i].first>x)
            ans.push_back({v[i].second,v[i].first}),x=v[i].first+1;
        else
            ans.push_back({v[i].second,x++});
    }
    sort(ans.begin(),ans.end());
    for(auto i : ans)
        cout<<i.second<<" ";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    long long n,x;
    cin>>n;
    vector<pair<int,int> >v,ans;
    for(int i=0; i<n; i++)
        cin>>x,v.push_back({x,i});
    x=1;
    sort(v.begin(),v.end());
    for(int i=0; i<n; i++)
    {
        if(v[i].first==x)
            ans.push_back({v[i].second,x++});
        else if(v[i].first>x)
            ans.push_back({v[i].second,v[i].first}),x=v[i].first;
        else
            ans.push_back({v[i].second,x++});
    }
    sort(ans.begin(),ans.end());
    for(auto i : ans)
        cout<<i.second<<" ";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    long long n,x;
    cin>>n;
    vector<pair<int,int> >v,ans;
    for(int i=0; i<n; i++)
        cin>>x,v.push_back({x,i});
    x=1;
    sort(v.begin(),v.end());
    for(int i=0; i<n; i++)
    {
        if(v[i].first==x)
            ans.push_back({v[i].second,x++});
        else if(v[i].first>x)
            ans.push_back({v[i].second,v[i].first}),x=v[i].first;
        else
            ans.push_back({v[i].first,x++});
    }
    sort(ans.begin(),ans.end());
    for(auto i : ans)
        cout<<i.second<<" ";
    return 0;
}


    // " every champion was once a contender who refused to give up " //
    // eat sleep code repeat :)
    // vectorTango
    // reapedJuggler

    #include "bits/stdc++.h"

    #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    #define ld long int
    #define all(A) begin(A) , end(A)
    #define rep(i , a , b)  for(lld i = a; i < b ; i++)
    #define rep1(i , a , b) for(lld i = a ; i >= b ; i--)
    #define lld long long int
    #define ulld unsigned long long int
    #define input lld* a = new lld [n]
    #define input1 lld* b = new lld [n]
    #define vec vector < lld >
    #define pb push_back
    #define ss second
    #define ff first
    #define inf 999999999999999999
    #define fin -999999999999999999
    #define mod 1000000007
    #define umap unordered_map
    #define mpp make_pair
    #define finish(x) cout << v << " ";
    #define tolower(s)   std::transform(s.begin(), s.end(), s.begin(),[](unsigned char c){ return std::tolower(c); });

    using namespace std;

    void start()
    {
      #ifndef ONLINE_JUDGE
      freopen("input.txt" , "r" , stdin) ;
      freopen("output1.txt" , "w" , stdout) ;
      #endif
    }

  //   vec g[200007];
  //   vec v;
  //   map<lld , bool> vis ; lld siz = 0 , ans = 1 ;

  //    void dfs(lld x , lld dest){

  //    vis[x] = 1;

  //    for(auto i : g[x]){
  //     if(!vis[i]){
  //       dfs(i);
  //     }
  //    }

  //    return;
  //   }

  // lld pow1(ulld  a , ulld y){
  //   // a %= mod;
  //   ulld  res = 1;

  //   while(y > 0){

  //     if(y & 1)
  //       res = (res*a)%mod;

  //     y = y >> 1;
  //     a = (a*a)%mod;
  //   }
  //   return res;
  // }

bool sortbysec(const pair<lld ,lld > &a, const pair<lld ,lld > &b) {
  return (a.ss < b.ss);
}

void sober(){
lld n , x , ans = 0 , a = 0 , b = 0 , y = 0 , sum = 0;
cin >> n;
vec v1(n);
rep(i , 0 ,n)
  cin >> v1[i];

vector<pair<lld , lld>> v;

rep(i , 0, n){
  v.pb(mpp(v1[i] , i));
}

// for(auto i : v)
//   cout << i.ff << " " <<  i.ss << " \n";

sort(all(v));

lld cur = 1;
lld flag = 0;
rep(i , 0 , n){
  if(!i){
    flag = v[0].ff;
  }
  if(i){

    if(v[i].ff == flag){
      v[i].ff += cur++;
    }
    else{
      cur--;
      flag = v[i].ff;
      if(v[i - 1].ff < v[i].ff){
        cur = 0;
        v[i].ff += cur++;
      }

      else{
        v[i].ff += cur++;
      }

    }
  }
}
sort(all(v) , sortbysec);
for(auto i : v)
   cout << i.ff << " ";
}

signed main(){
  start();
  FAST_IO;
  lld t = 1;
  // cin >> t;
  while(t--){
     sober();
  }
}

//  c0ded by :
// - - - - - - - - - - - - - - - - - - - - - - s 0 b e r and s i m r a n


    // " every champion was once a contender who refused to give up " //
    // eat sleep code repeat :)
    // vectorTango
    // reapedJuggler

    #include "bits/stdc++.h"

    #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    #define ld long int
    #define all(A) begin(A) , end(A)
    #define rep(i , a , b)  for(lld i = a; i < b ; i++)
    #define rep1(i , a , b) for(lld i = a ; i >= b ; i--)
    #define lld long long int
    #define ulld unsigned long long int
    #define input lld* a = new lld [n]
    #define input1 lld* b = new lld [n]
    #define vec vector < lld >
    #define pb push_back
    #define ss second
    #define ff first
    #define inf 999999999999999999
    #define fin -999999999999999999
    #define mod 1000000007
    #define umap unordered_map
    #define mpp make_pair
    #define finish(x) cout << v << " ";
    #define tolower(s)   std::transform(s.begin(), s.end(), s.begin(),[](unsigned char c){ return std::tolower(c); });

    using namespace std;

    void start()
    {
      #ifndef ONLINE_JUDGE
      freopen("input.txt" , "r" , stdin) ;
      freopen("output1.txt" , "w" , stdout) ;
      #endif
    }

  //   vec g[200007];
  //   vec v;
  //   map<lld , bool> vis ; lld siz = 0 , ans = 1 ;

  //    void dfs(lld x , lld dest){

  //    vis[x] = 1;

  //    for(auto i : g[x]){
  //     if(!vis[i]){
  //       dfs(i);
  //     }
  //    }

  //    return;
  //   }

  // lld pow1(ulld  a , ulld y){
  //   // a %= mod;
  //   ulld  res = 1;

  //   while(y > 0){

  //     if(y & 1)
  //       res = (res*a)%mod;

  //     y = y >> 1;
  //     a = (a*a)%mod;
  //   }
  //   return res;
  // }

bool sortbysec(const pair<lld ,lld > &a, const pair<lld ,lld > &b) {
  return (a.ss < b.ss);
}

void sober(){
lld n , x , ans = 0 , a = 0 , b = 0 , y = 0 , sum = 0;
cin >> n;
vec v1(n);
rep(i , 0 ,n)
  cin >> v1[i];

vector<pair<lld , lld>> v;

rep(i , 0, n){
  v.pb(mpp(v1[i] , i));
}

// for(auto i : v)
//   cout << i.ff << " " <<  i.ss << " \n";

sort(all(v));

lld cur = 1;
lld flag = 0;
rep(i , 0 , n){

  if(!i){
    flag = v[0].ff;
  }

  if(i){

    if(v[i].ff == flag){
      v[i].ff += cur;
      cur++;
    }

    else{
      // cout << "hie  at " << i << "\n";
      cur--;
      flag = v[i].ff;
      if(v[i - 1].ff < v[i].ff){
        cur = 0;
        v[i].ff += cur;
        cur++;
        // cout << "  hello  " << i << "\n";
      }

      else{
        // cur++;
        flag = v[i].ff;
        cout << cur << "  " << i << "\n";
        v[i].ff += cur;
        cur++;

      }

    }
  }
}
sort(all(v) , sortbysec);
for(auto i : v)
   cout << i.ff << " ";
}

signed main(){
  start();
  FAST_IO;
  lld t = 1;
  // cin >> t;
  while(t--){
     sober();
  }
}

//  c0ded by :
// - - - - - - - - - - - - - - - - - - - - - - s 0 b e r and s i m r a n


    // " every champion was once a contender who refused to give up " //
    // eat sleep code repeat :)
    // vectorTango
    // reapedJuggler

    #include "bits/stdc++.h"

    #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    #define ld long int
    #define all(A) begin(A) , end(A)
    #define rep(i , a , b)  for(lld i = a; i < b ; i++)
    #define rep1(i , a , b) for(lld i = a ; i >= b ; i--)
    #define lld long long int
    #define ulld unsigned long long int
    #define input lld* a = new lld [n]
    #define input1 lld* b = new lld [n]
    #define vec vector < lld >
    #define pb push_back
    #define ss second
    #define ff first
    #define inf 999999999999999999
    #define fin -999999999999999999
    #define mod 1000000007
    #define umap unordered_map
    #define mpp make_pair
    #define finish(x) cout << v << " ";
    #define tolower(s)   std::transform(s.begin(), s.end(), s.begin(),[](unsigned char c){ return std::tolower(c); });

    using namespace std;

    void start()
    {
      #ifndef ONLINE_JUDGE
      freopen("input.txt" , "r" , stdin) ;
      freopen("output1.txt" , "w" , stdout) ;
      #endif
    }

  //   vec g[200007];
  //   vec v;
  //   map<lld , bool> vis ; lld siz = 0 , ans = 1 ;

  //    void dfs(lld x , lld dest){

  //    vis[x] = 1;

  //    for(auto i : g[x]){
  //     if(!vis[i]){
  //       dfs(i);
  //     }
  //    }

  //    return;
  //   }

  // lld pow1(ulld  a , ulld y){
  //   // a %= mod;
  //   ulld  res = 1;

  //   while(y > 0){

  //     if(y & 1)
  //       res = (res*a)%mod;

  //     y = y >> 1;
  //     a = (a*a)%mod;
  //   }
  //   return res;
  // }

bool sortbysec(const pair<lld ,lld > &a, const pair<lld ,lld > &b) {
  return (a.ss < b.ss);
}

void sober(){
lld n , x , ans = 0 , a = 0 , b = 0 , y = 0 , sum = 0;
cin >> n;
vec v1(n);
rep(i , 0 ,n)
  cin >> v1[i];

vector<pair<lld , lld>> v;

rep(i , 0, n){
  v.pb(mpp(v1[i] , i));
}

// for(auto i : v)
//   cout << i.ff << " " <<  i.ss << " \n";

sort(all(v));

lld cur = 1;
lld flag = 0;
rep(i , 0 , n){

  if(!i){
    flag = v[0].ff;
  }

  if(i){

    if(v[i].ff == flag){
      v[i].ff += cur;
      cur++;
    }

    else{
      // cout << "hie  at " << i << "\n";
      cur--;
      flag = v[i].ff;
      if(v[i - 1].ff < v[i].ff){
        cur = 0;
        v[i].ff += cur;
        cur++;
        // cout << "  hello  " << i << "\n";
      }

      else{
        // cur++;
        flag = v[i].ff;
        // cout << cur << "  " << i << "\n";
        v[i].ff += cur;
        cur++;

      }

    }
  }
}
sort(all(v) , sortbysec);
for(auto i : v)
   cout << i.ff << " ";
}

signed main(){
  start();
  FAST_IO;
  lld t = 1;
  // cin >> t;
  while(t--){
     sober();
  }
}

//  c0ded by :
// - - - - - - - - - - - - - - - - - - - - - - s 0 b e r and s i m r a n


      // " every champion was once a contender who refused to give up " //
      // eat sleep code repeat :)
      // vectorTango
      // reapedJuggler

      #include "bits/stdc++.h"

      #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
      #define ld long int
      #define all(A) begin(A) , end(A)
      #define rep(i , a , b)  for(lld i = a; i < b ; i++)
      #define rep1(i , a , b) for(lld i = a ; i >= b ; i--)
      #define lld long long int
      #define ulld unsigned long long int
      #define input lld* a = new lld [n]
      #define input1 lld* b = new lld [n]
      #define vec vector < lld >
      #define pb push_back
      #define ss second
      #define ff first
      #define inf 999999999999999999
      #define fin -999999999999999999
      #define mod 1000000007
      #define umap unordered_map
      #define mpp make_pair
      #define finish(x) cout << v << " ";
      #define tolower(s)   std::transform(s.begin(), s.end(), s.begin(),[](unsigned char c){ return std::tolower(c); });

      using namespace std;

      void start()
      {
        #ifndef ONLINE_JUDGE
        freopen("input.txt" , "r" , stdin) ;
        freopen("output1.txt" , "w" , stdout) ;
        #endif
      }

    //   vec g[200007];
    //   vec v;
    //   map<lld , bool> vis ; lld siz = 0 , ans = 1 ;

    //    void dfs(lld x , lld dest){

    //    vis[x] = 1;

    //    for(auto i : g[x]){
    //     if(!vis[i]){
    //       dfs(i);
    //     }
    //    }

    //    return;
    //   }

    // lld pow1(ulld  a , ulld y){
    //   // a %= mod;
    //   ulld  res = 1;

    //   while(y > 0){

    //     if(y & 1)
    //       res = (res*a)%mod;

    //     y = y >> 1;
    //     a = (a*a)%mod;
    //   }
    //   return res;
    // }

  bool sortbysec(const pair<lld ,lld > &a, const pair<lld ,lld > &b) {
    return (a.ss < b.ss);
  }

  void sober(){
  lld n , x , ans = 0 , a = 0 , b = 0 , y = 0 , sum = 0;
  cin >> n;
  vec v1(n);
  rep(i , 0 ,n)
    cin >> v1[i];

  vector<pair<lld , lld>> v;

  rep(i , 0, n){
    v.pb(mpp(v1[i] , i));
  }

  // for(auto i : v)
  //   cout << i.ff << " " <<  i.ss << " \n";

  sort(all(v));

  lld cur = 0;
  lld flag = 0;
  rep(i , 0 , n){
    if(v[i].ff > cur){
      cur = v[i].ff;
    }
    else{
      cur++;
    }

    v[i].ff = cur;
  }
  sort(all(v) , sortbysec);

  for(auto i : v)
     cout << i.ff << " ";
  }

  signed main(){
    start();
    FAST_IO;
    lld t = 1;
    // cin >> t;
    while(t--){
       sober();
    }
  }

  //  c0ded by :
  // - - - - - - - - - - - - - - - - - - - - - - s 0 b e r and s i m r a n


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const int sz = 300005;

int n;
ll a[sz];
int pos[sz];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		pos[i] = i;
		}
	sort(pos+1, pos+n+1, [](ll c, ll d){ return a[c]<=a[d]; });
	//~ for(int i=1;i<=n;i++) cout<<pos[i]<<' ';
	//~ cout<<'\n';
	ll ans = 0;
	for(int i=2;i<=n;i++){
		if(a[pos[i]]<=a[pos[i-1]]) ans+=(a[pos[i-1]]-a[pos[i]]+1),a[pos[i]]=a[pos[i-1]]+1;
		}
	for(int i=1;i<=n;i++){
		cout<<a[i]<<" ";
		}
	}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const int sz = 100005;

int n;
ll a[sz];
int pos[sz];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		pos[i] = i;
		}
	sort(pos+1, pos+n+1, [](ll c, ll d){ return a[c]<=a[d]; });
	for(int i=1;i<=n;i++) cout<<pos[i]<<' ';
	cout<<'\n';
	ll ans = 0;
	for(int i=2;i<=n;i++){
		if(a[pos[i]]<=a[pos[i-1]]) ans+=(a[pos[i-1]]-a[pos[i]]+1),a[pos[i]]=a[pos[i-1]]+1;
		}
	for(int i=1;i<=n;i++){
		cout<<a[i]<<" ";
		}
	}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const int sz = 300005;

int n;
ll a[sz];
int pos[sz];
int main(){
	//freopen("testcase.txt", "r", stdin);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		pos[i] = i;
		}
	sort(pos+1, pos+n+1, [](ll c, ll d){ return a[c]<a[d]; });
	//~ for(int i=1;i<=n;i++) cout<<pos[i]<<' ';
	//~ cout<<'\n';
	ll ans = 0;
	for(int i=2;i<=n;i++){
		if(a[pos[i]]<=a[pos[i-1]]) ans+=(a[pos[i-1]]-a[pos[i]]+1),a[pos[i]]=a[pos[i-1]]+1;
		}
	for(int i=1;i<=n;i++){
		cout<<a[i]<<" ";
		}
	}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const int sz = 100005;

int n;
ll a[sz];
int pos[sz];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		pos[i] = i;
		}
	sort(pos+1, pos+n+1, [](ll c, ll d){ return a[c]<=a[d]; });
	//~ for(int i=1;i<=n;i++) cout<<pos[i]<<' ';
	//~ cout<<'\n';
	ll ans = 0;
	for(int i=2;i<=n;i++){
		if(a[pos[i]]<=a[pos[i-1]]) ans+=(a[pos[i-1]]-a[pos[i]]+1),a[pos[i]]=a[pos[i-1]]+1;
		}
	for(int i=1;i<=n;i++){
		cout<<a[i]<<" ";
		}
	}


#include<bits/stdc++.h>
using namespace std;
#define ll __int64
#define pb push_back
#define in(i,a) for(i=0;i<a;++i)
#define inn(i,a,b) for(i=a;i<b;++i)
#define all(s) s.begin(),s.end()
#define mp make_pair
const int M=1e5+5;
map<ll,ll> m;
ll a[M];

int main()
{
  ll n,i;
  cin>>n;
  in(i,n)
  {
      cin>>a[i];
      m[a[i]]=1;
  }
  in(i,n)
  {
      if(m[a[i]]==1)
      {
          cout<<a[i]<<" ";
          m[a[i]]=2;
      }
      else if(m[a[i]]>1)
      {
          while(1)
          {
              a[i]++;
              m[a[i]]++;
              if(m[a[i]]==1)
              {
                  cout<<a[i]<<" ";
                  m[a[i]]++;
                  break;
              }
              m[a[i]]--;
          }
      }
  }
}


#include<bits/stdc++.h>
using namespace std;
#define ll __int64
#define pb push_back
#define in(i,a) for(i=0;i<a;++i)
#define inn(i,a,b) for(i=a;i<b;++i)
#define all(s) s.begin(),s.end()
#define mp make_pair
const int M=(1e5+5)*3;
map<ll,ll> m;
ll a[M];

int main()
{
  ll n,i;
  cin>>n;
  in(i,n)
  {
      cin>>a[i];
      m[a[i]]=1;
  }
  in(i,n)
  {
      if(m[a[i]]==1)
      {
          cout<<a[i]<<" ";
          m[a[i]]=2;
      }
      else if(m[a[i]]>1)
      {
          while(1)
          {
              a[i]++;
              m[a[i]]++;
              if(m[a[i]]==1)
              {
                  cout<<a[i]<<" ";
                  m[a[i]]++;
                  break;
              }
              m[a[i]]--;
          }
      }
  }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int M=(1e5+5)*3;
vector< pair<ll,ll> > v;
ll vi[M];
vector< pair<ll,ll> >::iterator it;
int main()
{
    ll n,temp=1,i,x;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(make_pair(x,i));
    }
    sort(v.begin(),v.end());
    for(it=v.begin();it!=v.end();it++)
    {
        vi[it->second]=max(it->first,temp);
        temp=vi[it->second]+1;
    }
    for(i=0;i<n;i++)
        cout<<vi[i]<<" ";

}


#include<bits/stdc++.h>
using namespace std;
#define ll __int64
#define pb push_back
#define in(i,a) for(i=0;i<a;++i)
#define inn(i,a,b) for(i=a;i<b;++i)
#define all(s) s.begin(),s.end()
#define mp make_pair
const int M=1e5+5;
map<int,int> m;
int a[M];

int main()
{
  ll n,i;
  cin>>n;
  in(i,n)
  {
      cin>>a[i];
      m[a[i]]=1;
  }
  in(i,n)
  {
      if(m[a[i]]==1)
      {
          cout<<a[i]<<" ";
          m[a[i]]=2;
      }
      else if(m[a[i]]>1)
      {
          while(1)
          {
              a[i]++;
              m[a[i]]++;
              if(m[a[i]]==1)
              {
                  cout<<a[i]<<" ";
                  m[a[i]]++;
                  break;
              }
              m[a[i]]--;
          }
      }
  }
}


#include<bits/stdc++.h>
using namespace std;
#define ll __int64
#define pb push_back
#define in(i,a) for(i=0;i<a;++i)
#define inn(i,a,b) for(i=a;i<b;++i)
#define all(s) s.begin(),s.end()
#define mp make_pair
const int M=1e5+5;
map<ll,ll> m;
int a[M];

int main()
{
  ll n,i;
  cin>>n;
  in(i,n)
  {
      cin>>a[i];
      m[a[i]]=1;
  }
  in(i,n)
  {
      if(m[a[i]]==1)
      {
          cout<<a[i]<<" ";
          m[a[i]]=2;
      }
      else if(m[a[i]]>1)
      {
          while(1)
          {
              a[i]++;
              m[a[i]]++;
              if(m[a[i]]==1)
              {
                  cout<<a[i]<<" ";
                  m[a[i]]++;
                  break;
              }
              m[a[i]]--;
          }
      }
  }
}


#include<bits/stdc++.h>
using namespace std;
#define ll __int64
#define pb push_back
#define in(i,a) for(i=0;i<a;++i)
#define inn(i,a,b) for(i=a;i<b;++i)
#define all(s) s.begin(),s.end()
#define mp make_pair
const int M=1e5+5;
map<int,int> m;
ll a[M];

int main()
{
  ll n,i;
  cin>>n;
  in(i,n)
  {
      cin>>a[i];
      m[a[i]]=1;
  }
  in(i,n)
  {
      if(m[a[i]]==1)
      {
          cout<<a[i]<<" ";
          m[a[i]]=2;
      }
      else if(m[a[i]]>1)
      {
          while(1)
          {
              a[i]++;
              m[a[i]]++;
              if(m[a[i]]==1)
              {
                  cout<<a[i]<<" ";
                  m[a[i]]++;
                  break;
              }
              m[a[i]]--;
          }
      }
  }
}


#include <bits\stdc++.h> //Íîâîãîäíåå èçìåíåíèå ðåéòèíãà
using namespace std;

typedef pair <int, int> pii;
#define fi first
#define se second
#define mp make_pair
const int MAXN = 3e5+5;
pii a[MAXN];
int b[MAXN];

int main () {
	int n;
	int val;

	scanf ("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf ("%d", &val);
		a[i] = mp (val, i);
	}
	sort (a, a + n+1);
	for (int i = 1; i <= n; i++) {
		if (a[i].fi == a[i-1].fi) {
			b[a[i].se] = b[a[i-1].se]+1;
		}
		else {
			b[a[i].se] = a[i].fi;
		}
	}
	for (int i = 1; i <= n; i++) {
		printf ("%d ", b[i]);
	}

	return 0;
}


#include <bits\stdc++.h> //Íîâîãîäíåå èçìåíåíèå ðåéòèíãà
using namespace std;

typedef pair <int, int> pii;
#define fi first
#define se second
#define mp make_pair
const int MAXN = 3e5+5;
pii a[MAXN];
int b[MAXN];

int main () {
	int n;
	int val;

	scanf ("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf ("%d", &val);
		a[i] = mp (val, i);
	}
	sort (a, a + n+1);
	for (int i = 1; i <= n; i++) {
		if (a[i].fi == a[i-1].fi) {
			a[i].fi = a[i-1].fi + 1;
		}
		b[a[i].se] = a[i].fi;
	}
	for (int i = 1; i <= n; i++) {
		printf ("%d ", b[i]);
	}

	return 0;
}


#include <bits\stdc++.h> //Íîâîãîäíåå èçìåíåíèå ðåéòèíãà
using namespace std;

typedef pair <int, int> pii;
#define fi first
#define se second
#define mp make_pair
const int MAXN = 3e5+5;
pii a[MAXN];
int b[MAXN];

int main () {
	int n;
	int val;

	scanf ("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf ("%d", &val);
		a[i] = mp (val, i);
	}
	sort (a, a + n+1);
	for (int i = 1; i <= n; i++) {
		if (a[i].fi == a[i-1].fi || a[i].fi == b[a[i-1].se]) {
			b[a[i].se] = b[a[i-1].se]+1;
		}
		else {
			b[a[i].se] = a[i].fi;
		}
	}
	for (int i = 1; i <= n; i++) {
		printf ("%d ", b[i]);
	}

	return 0;
}


#include <bits\stdc++.h> //Íîâîãîäíåå èçìåíåíèå ðåéòèíãà
using namespace std;

typedef pair <int, int> pii;
#define fi first
#define se second
#define mp make_pair
const int MAXN = 3e5+5;
pii a[MAXN];
int b[MAXN];

int main () {
	int n;
	int val;

	scanf ("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf ("%d", &val);
		a[i] = mp (val, i);
	}
	sort (a, a + n+1);
	int cur = 1;
	for (int i = 1; i <= n; i++) {
		if (a[i].fi > cur) cur = a[i].fi + 1;
		else {
			a[i].fi = cur;
			cur++;
		}
		b[a[i].se] = a[i].fi;
	}
	for (int i = 1; i <= n; i++) {
		printf ("%d ", b[i]);
	}

	return 0;
}


/* ---------itz_me9---------- */
/* ---------ONLY GOD AND I KNOW WHAT I HAVE WRITTEN ----------*/
#include<bits/stdc++.h>
#define ll long long
#define hell 1000000007
#define vi vector<long long>

using namespace std;

bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
	return (a.second < b.second);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,i;
	cin>>n;
	map<ll,ll> m;
	vector< pair<ll,ll> > v;
	for(i=0;i<n;i++)
	{
		ll temp;
		cin>>temp;
		v.push_back(make_pair(temp,i));
	}
	for(i=0;i<n;i++)
	{
		if(m[v[i].first]==0)
			m[v[i].first]=1;
		else
		{
			while(m[v[i].first]!=0)
			{
				v[i].first=v[i].first+1;
			}
			m[v[i].first]=1;
		}
	}
	sort(v.begin(),v.end(),sortbysec);
	for(i=0;i<n;i++)
	{
		cout<<v[i].first<<" ";
	}
	return 0;
}


/* ---------itz_me9---------- */
/* ---------ONLY GOD AND I KNOW WHAT I HAVE WRITTEN ----------*/
#include<bits/stdc++.h>
#define ll long long
#define hell 1000000007
#define vi vector<long long>

using namespace std;

bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
	return (a.second < b.second);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,i;
	cin>>n;
	map<ll,ll> m;
	vector< pair<ll,ll> > v;
	for(i=0;i<n;i++)
	{
		ll temp;
		cin>>temp;
		v.push_back(make_pair(temp,i));
	}
	m[v[0].first]=1;
	for(i=1;i<n;i++)
	{
		if(m[v[i].first]==0)
			m[v[i].first]=1;
		else
		{
			if(v[i].first<=v[i-1].first)
				v[i].first=v[i-1].first+1;
			m[v[i].first]=1;
		}
	}
	sort(v.begin(),v.end(),sortbysec);
	for(i=0;i<n;i++)
	{
		cout<<v[i].first<<" ";
	}
	return 0;
}


/* ---------itz_me9---------- */
/* ---------ONLY GOD AND I KNOW WHAT I HAVE WRITTEN ----------*/
#include<bits/stdc++.h>
#define ll long long
#define hell 1000000007
#define vi vector<long long>

using namespace std;

bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
	return (a.second < b.second);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,i;
	cin>>n;
	map<ll,ll> m;
	vector< pair<ll,ll> > v;
	for(i=0;i<n;i++)
	{
		ll temp;
		cin>>temp;
		v.push_back(make_pair(temp,i));
	}
	sort(v.begin(),v.end());
	m[v[0].first]=1;
	for(i=1;i<n;i++)
	{
		if(m[v[i].first]==0)
			m[v[i].first]=1;
		else
		{
			if(v[i].first<=v[i-1].first)
				v[i].first=v[i-1].first+1;
			m[v[i].first]=1;
		}
	}
	sort(v.begin(),v.end(),sortbysec);
	for(i=0;i<n;i++)
	{
		cout<<v[i].first<<" ";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define Intertreasure cin.tie(0);std::ios::sync_with_stdio(false);
int main()
{
Intertreasure
int n;
cin>>n;
int seq[n];
map<int,int>mop;
for (int i=0;i<n;i++){cin>>seq[i];mop[seq[i]]++;}
for (int i=0;i<mop.size();i++)mop[i]--;
for (int i=0;i<n;i++)
{
if (mop[seq[i]]>=0){cout<<seq[i]+mop[seq[i]]<<" ";mop[seq[i]]--;}
}
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define Intertreasure cin.tie(0);std::ios::sync_with_stdio(false);
int main()
{
Intertreasure
int n;
cin>>n;
int seq[n];
map<int,int>mop,m;
for (int i=0;i<n;i++)
{
int x;
cin>>x;
seq[i]=x+mop[x];mop[x]++;
m[seq[i]]++;
}
int cnt=0,a;
a=m.size();
for (int i=0;;i++)
{
if (m[seq[i]]==1)cnt++;
if (cnt==n)break;
if (m[seq[i]]>1){m[seq[i]]--;seq[i]++;m[seq[i]]++;}
i%=a;
}
for (int i=0;i<n;i++)cout<<seq[i]<<" ";
cout<<endl;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lli;
typedef int I;
#define Intertreasure cin.tie(0);std::ios::sync_with_stdio(false);
#define OO ll(1e18);
int arr[300005];
pair<I,I>p[300005];
int main()
{
Intertreasure
I n;
cin>>n;
for (int i=0;i<n;i++)
{
cin>>p[i].first;
p[i].second=i;
}
sort(p,p+n);
ll x=0;
for (int i=0;i<n;i++)
{
x++;
if (x<p[i].first)x=p[i].first;
arr[p[i].second]=x;
}
for (int i=0;i<n;i++)cout<<arr[i]<<" ";
cout<<endl;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define Intertreasure cin.tie(0);std::ios::sync_with_stdio(false);
int main()
{
Intertreasure
int n;
cin>>n;
int seq[n],arr[n];
for (int i=0;i<n;i++)cin>>seq[i];
int cnt=0,cpy=0;
for (int i=0;i<n-1;i++)
{
arr[i]=seq[i];
cnt=seq[i];
for (int j=i+1;j<n;j++)
{
if (seq[i]==seq[j])
{
cnt++;
arr[j]=cnt;
}
}
}
if (n==1)cout<<seq[0]<<endl;
else
for (int i=0;i<n;i++)cout<<arr[i]<<" ";
cout<<endl;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define Intertreasure cin.tie(0);std::ios::sync_with_stdio(false);
int main()
{
Intertreasure
int n;
cin>>n;
int seq[n];
map<int,int>mop,m;
//for (int i=0;i<n;i++){cin>>seq[i];mop[seq[i]]++;}
//for (int i=0;i<mop.size();i++)mop[i]--;
for (int i=0;i<n;i++)
{
int x;
cin>>x;
seq[i]=x+mop[x];mop[x]++;
m[seq[i]]++;
//cout<<x+mop[x]<<" ";mop[x]++;
}
for (int i=0;i<n;i++)
{
if (m[seq[i]]>1){seq[i]++;m[seq[i]]--;}
}
for (int i=0;i<n;i++)cout<<seq[i]<<" ";
cout<<endl;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define Intertreasure cin.tie(0);std::ios::sync_with_stdio(false);
int main()
{
Intertreasure
int n;
cin>>n;
map<int,int>mop;
for (int i=0;i<n;i++)
{
int x;
cin>>x;
if (mop[x]>=0){cout<<x+mop[x]<<" ";mop[x]++;}
}
return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <stack>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lli;
typedef int I;
#define Intertreasure cin.tie(0);std::ios::sync_with_stdio(false);
#define OO ll(1e18);
unordered_set<ll>mySet;
int main()
{
	Intertreasure
		I n;
	cin >> n;
	ll x;
	lli a, b;
	a = mySet.size();
	for (int i = 0; i<n; i++)
	{
		cin >> x;
		mySet.insert(x);
		b = mySet.size();
		if (b>a)a = b;
		else
		{
			while (true)
			{
				x++;
				mySet.insert(x);
				b = mySet.size();
				if (b > a){ a = b; break;}
			}
		}
	}
	unordered_set<ll>::iterator it;
	it = mySet.begin();
	for (; it != mySet.end(); *it++)cout << *it << " ";
	cout << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lli;
typedef int I;
#define Intertreasure cin.tie(0);std::ios::sync_with_stdio(false);
#define OO ll(1e18);
int main()
{
Intertreasure
I n;
cin>>n;
ll seq[n],cnt=0;
for (int i=0;i<n;i++)cin>>seq[i];
for (int i=0;i<n;i++)
{
cnt+=seq[i];
cout<<cnt<<" ";
}
cout<<endl;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define Intertreasure cin.tie(0);std::ios::sync_with_stdio(false);
int main()
{
Intertreasure
int n;
cin>>n;
int seq[n];
map<int,int>mop,m;
//for (int i=0;i<n;i++){cin>>seq[i];mop[seq[i]]++;}
//for (int i=0;i<mop.size();i++)mop[i]--;
for (int i=0;i<n;i++)
{
int x;
cin>>x;
seq[i]=x+mop[x];mop[x]++;
m[seq[i]]++;
//cout<<x+mop[x]<<" ";mop[x]++;
}
int cnt=0,a;
a=m.size();
for (int i=0;;i++)
{
if (m[seq[i]]==1)cnt++;
if (cnt==n)break;
if (m[seq[i]]>1){m[seq[i]]--;seq[i]++;}
i%=a;
}
for (int i=0;i<n;i++)cout<<seq[i]<<" ";
cout<<endl;
return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <stack>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lli;
typedef int I;
#define Intertreasure cin.tie(0);std::ios::sync_with_stdio(false);
#define OO ll(1e18);
unordered_set<ll>mySet;
int main()
{
	Intertreasure
		I n;
	cin >> n;
	ll x;
	lli a, b;
	a = mySet.size();
	for (int i = 0; i<n; i++)
	{
		cin >> x;
		mySet.insert(x);
		b = mySet.size();
		if (b>a)a = b;
		else
		{
			while (true)
			{
				x++;
				mySet.insert(x);
				b = mySet.size();
				if (b > a){ a = b; break;}
			}
		}
	}
	unordered_set<ll>::iterator it;
	it = mySet.begin();
	for (; it != mySet.end(); *it++)cout << *it << " ";
	cout << endl;
	system("pause");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lli;
typedef int I;
#define Intertreasure cin.tie(0);std::ios::sync_with_stdio(false);
#define OO ll(1e18);
set<ll>mySet;
int arr[300005];
map<int,int>mop;
int main()
{
Intertreasure
I n;
cin>>n;
ll x;
lli a,b;
a=mySet.size();
for (int i=0;i<n;i++)
{
cin>>x;
mySet.insert(x);
b=mySet.size();
if (b>a){a=b;mop[x]=i;}
else
{
while(true)
{
x++;
mySet.insert(x);
b=mySet.size();
if (b>a){a=b;mop[x]=i;break;}
}
}
}
set<ll>::iterator it;
it=mySet.begin();
for (;it!=mySet.end();*it++){arr[mop[*it]]=*it;}
for (int i=0;i<n;i++)cout<<arr[i]<<" ";
cout<<endl;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lli;
typedef int I;
#define Intertreasure cin.tie(0);std::ios::sync_with_stdio(false);
#define OO ll(1e18);
set<ll>mySet;
int main()
{
Intertreasure
I n;
cin>>n;
ll x;
lli a,b;
a=mySet.size();
for (int i=0;i<n;i++)
{
cin>>x;
mySet.insert(x);
b=mySet.size();
if (b>a)a=b;
else
{
while(true)
{
x++;
mySet.insert(x);
b=mySet.size();
if (b>a){a=b;break;}
}
}
}
set<ll>::iterator it;
it=mySet.begin();
for (;it!=mySet.end();*it++)cout<<*it<<" ";
cout<<endl;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define Intertreasure cin.tie(0);std::ios::sync_with_stdio(false);
int main()
{
Intertreasure
int n;
cin>>n;
int seq[n];
map<int,int>mop,m;
//for (int i=0;i<n;i++){cin>>seq[i];mop[seq[i]]++;}
//for (int i=0;i<mop.size();i++)mop[i]--;
for (int i=0;i<n;i++)
{
int x;
cin>>x;
seq[i]=x+mop[x];mop[x]++;
m[seq[i]]++;
//cout<<x+mop[x]<<" ";mop[x]++;
}
for (int i=0;i<n;i++)
{
if (m[seq[i]]>1){m[seq[i]]--;seq[i]++;}
}
for (int i=0;i<n;i++)cout<<seq[i]<<" ";
cout<<endl;
return 0;
}


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

const int N = 4e5 + 5;

int n;
long long   a[N];
map<long long,bool> used;

int main(){

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

    cin >> n;

    for (int i = 1;i <= n;i++){

        long long x;
        cin >> x;
        while (used[x]) ++x;
        used[x] = true;
        a[i] = x;
    }

    for (int i = 1;i <= n;i++)
        cout << a[i] << ' ';

}


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

const int N = 4e5 + 5;

int n;
long long ans[N];
pair<long long,int> a[N];

int main(){

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

    cin >> n;

    for (int i = 1;i <= n;i++){

        long long x;
        cin >> x;
        a[i] = make_pair(x,i);
    }
    sort(a + 1,a + n + 1);
    int cur = 0;
    for (int i = 1;i <= n;i++){

        if (a[i].first <= cur) ++cur;
        else cur = a[i].first;
        ans[a[i].second] = cur;
    }

    for (int i = 1;i <= n;i++)
        cout << ans[i] << ' ';

}


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

const int N = 4e5 + 5;

int n,a[N];
bool used[N];

int main(){

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

    cin >> n;

    for (int i = 1;i <= n;i++){

        int x;
        cin >> x;
        while (used[x]) ++x;
        used[x] = true;
        a[i] = x;
    }

    for (int i = 1;i <= n;i++)
        cout << a[i] << ' ';

}


#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define ll long long

using namespace std;

set <int> st;

int main() {
    ios_base::sync_with_stdio( 0 );
#ifdef LOCAL
    freopen( "input.txt", "r", stdin );
    freopen( "output.txt", "w", stdout );
#endif //LOCAL
    int n;
    cin>>n;
    vector <pair<int,int>> a(n);
    vector <int> b(n);
    for ( int i = 0; i < n; i++ ) {
        cin>>a[i].F;
        a[i].S = i;
    }
    sort( a.begin(), a.end() );
    int cur = 0;
    for ( int i = 0; i < n; i++ ) {
        if ( st.find(a[i].F) == st.end() ) {
            b[a[i].S] = a[i].F;
            st.insert( a[i].F );
            cur = max( cur, a[i].F );
        }
        else {
            cur = max( cur+1, a[i].F+1 );
            b[a[i].S] = cur;
        }
    }
    for ( int i = 0; i < n; i++ )
        cout<<b[i]<<' ';
}


#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define ll long long

using namespace std;

set <int> st;

int main() {
    ios_base::sync_with_stdio( 0 );
#ifdef LOCAL
    freopen( "input.txt", "r", stdin );
    freopen( "output.txt", "w", stdout );
#endif //LOCAL
    int n;
    cin>>n;
    vector <pair<int,int>> a(n);
    vector <int> b(n);
    for ( int i = 0; i < n; i++ ) {
        cin>>a[i].F;
        a[i].S = i;
    }
    sort( a.begin(), a.end() );
    for ( int i = 0; i < n; i++ ) {
        while ( st.find(a[i].F) != st.end() ) {
            a[i].F++;
        }
        b[a[i].S] = a[i].F;
        st.insert(a[i].F);
    }
    for ( int i = 0; i < n; i++ )
        cout<<b[i]<<' ';
}


#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define ll long long

using namespace std;

set <int> st;

int main() {
    ios_base::sync_with_stdio( 0 );
#ifdef LOCAL
    freopen( "input.txt", "r", stdin );
    freopen( "output.txt", "w", stdout );
#endif //LOCAL
    int n;
    cin>>n;
    vector <pair<int,int>> a(n);
    vector <int> b(n);
    for ( int i = 0; i < n; i++ ) {
        cin>>a[i].F;
        a[i].S = i;
    }
    sort( a.begin(), a.end() );
    int cur = 0;
    for ( int i = 0; i < n; i++ ) {
        cur = max( cur, a[i].F );
        while ( st.find(cur) != st.end() ) {
            cur++;
        }
        b[a[i].S] = cur;
        st.insert(cur);
    }
    for ( int i = 0; i < n; i++ )
        cout<<b[i]<<' ';
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
#define FastIO      ios_base::sync_with_stdio(false); cin.tie(0);
#define aPrint(a,b,c)for(int i=b;i<=c;i++)cout<<a[i]<<" ";cout<<endl;
#define vPrint(a)   for(int i=0;i<a.size();i++){cout<<a[i];if(i==a.size()-1)cout<<endl;else cout<<" ";}
#define Case(t)     printf("Case %d: ", t)
#define clr(x,a)    memset(x,a,sizeof(x))
#define debug(x)    cerr<<#x<<" = "<<(x)<<"\n"

#define umap        unordered_map
#define plll        pair<ll, pair<ll, ll> >
#define pll         pair<ll, ll>
#define ff          first
#define ss          second
#define mp          make_pair
#define pb          push_back
#define ppb         pop_back
#define sf          scanf
#define pf          printf
#define all(a)      a.begin(),a.end()
#define allr(a)     a.rbegin(),a.rend()
#define Unique(a)   sort(all(a)), a.erase(unique(all(a)),a.end())
template <class T> inline T bigmod(T b,T p,T M){T ret=1;for(;p>0;p>>=1){if(p&1) ret=(ret*b)%M;b=(b*b)%M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T lcm(T a,T b){return a*b / gcd<T>(a, b);}
template <class T> inline T power(T b,T p){ull x=1;while(p--)x*=b;return x;}
const int mod = 1000000007;

#define pi        acos(-1.0)//3.1415926535897932
#define inf       1e9 + 7
#define MAX       1000010
/// 'N'+'A'+'E'+'E'+'E'+'M' ///
/// Hash
string s, t;
ll BASE = 29, MOD = 1000000007;
ll Pow[MAX+5];
ll H[MAX+5], revH[MAX+5];
ll charToInt(char ch) {
    if(ch >= 'A' && ch <= 'Z') return ch - 'A' + 26;
    return ch - 'a' + 1;
}

void prePower(){
    Pow[0] = 1LL;
    for(int i = 1; i <= 100001; i++){
        Pow[i] = (Pow[i-1] * BASE) % MOD;
    }
}
void Hash(string str){
    H[0] = charToInt(str[0]);
    for(int i = 1; i < str.size(); i++){
        H[i] = (H[i-1] * BASE) % MOD;
        H[i] = (H[i] + charToInt(str[i])) % MOD;
    }
}
void revHash(string str){
    revH[0] = charToInt(str[0]);
    for(int i = 1; i < str.size(); i++){
        revH[i] = (revH[i-1] * BASE) % MOD;
        revH[i] = (revH[i] + charToInt(str[i])) % MOD;
    }
}
ll RollingHash(int l, int r){
    if(l > r) return 0LL;
    ll R = H[r];
    ll L = (H[l-1] * Pow[r-l+1]) % MOD;
    return (R - L + MOD) % MOD;
}
ll revRollingHash(int l, int r){
    if(l > r) return 0LL;
    ll R = revH[r];
    ll L = (revH[l-1] * Pow[r-l+1]) % MOD;
    return (R - L + MOD) % MOD;
}
ll AddTwoSubStringHash(int l, int r, int x, int y) {
    if(l > r) return RollingHash(x, y);
    if(x > y) return RollingHash(l, r);
    ll A = RollingHash(l, r);
    ll B = RollingHash(x, y);
    ll HH = (A * Pow[y - x + 1]) % MOD;
    HH = (HH + B + MOD) % MOD;
    return HH;
}
ll AddTwoSubStringRevHash(int l, int r, int x, int y) {
    if(l > r) return revRollingHash(x, y);
    if(x > y) return revRollingHash(l, r);
    ll A = revRollingHash(l, r);
    ll B = revRollingHash(x, y);
    ll HH = (A * Pow[y - x + 1]) % MOD;
    HH = (HH + B + MOD) % MOD;
    return HH;
}
int isOkay(int baad) {
    //debug(baad);
    int n = s.size();
    int l = 0, r = baad - 1;
    int x = n - baad, y = n - 1;
    for( ; r < n; l++, r++, x--, y--) {
        ll H1 = AddTwoSubStringHash(0, l - 1, r + 1, n - 1);
        ll H2 = AddTwoSubStringRevHash(0, x - 1, y + 1, n - 1);
        if(H1 == H2) return l;
    }
    return -1;
}
int main() {
    #ifndef ONLINE_JUDGE
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif
    FastIO;

    prePower();

    int tc; cin >> tc; while(tc--) {
        cin >> s;
        t = s; reverse(all(t));
        int n = (int) s.size();

        Hash(s);
        revHash(t);

        if(H[n - 1] == revH[n - 1]) {
            cout << s << endl;
            continue;
        }

        int maxi = -1, X = -1, Y = -1;
        for(int parity : {0, 1}) {
            int l = 1, r = n;
            if(l%2 != parity) l++;
            if(r%2 != parity) r--;
            while(l <= r) {
                int mid = (l + r) / 2;
                if(mid%2 != parity) mid++;
                if(mid > r) break;
                int Baad = n - mid;
                int tmp = isOkay(Baad);
                if(tmp != -1){
                    if(mid > maxi) {
                        maxi = mid;
                        X = tmp;
                        Y = X + Baad - 1;
                    }
                    l = mid + 2;
                }
                else r = mid - 2;
            }
        }
        cout << s.substr(0, X) + s.substr(Y + 1) << endl;

    }

    #ifndef ONLINE_JUDGE
        printf("\n**Time -> %.10fs\n", (double)(clock()-tStart) / CLOCKS_PER_SEC);
    #endif

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
#define FastIO      ios_base::sync_with_stdio(false); cin.tie(0);
#define aPrint(a,b,c)for(int i=b;i<=c;i++)cout<<a[i]<<" ";cout<<endl;
#define vPrint(a)   for(int i=0;i<a.size();i++){cout<<a[i];if(i==a.size()-1)cout<<endl;else cout<<" ";}
#define Case(t)     printf("Case %d: ", t)
#define clr(x,a)    memset(x,a,sizeof(x))
#define debug(x)    cerr<<#x<<" = "<<(x)<<"\n"

#define umap        unordered_map
#define plll        pair<ll, pair<ll, ll> >
#define pll         pair<ll, ll>
#define ff          first
#define ss          second
#define mp          make_pair
#define pb          push_back
#define ppb         pop_back
#define sf          scanf
#define pf          printf
#define all(a)      a.begin(),a.end()
#define allr(a)     a.rbegin(),a.rend()
#define Unique(a)   sort(all(a)), a.erase(unique(all(a)),a.end())
template <class T> inline T bigmod(T b,T p,T M){T ret=1;for(;p>0;p>>=1){if(p&1) ret=(ret*b)%M;b=(b*b)%M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T lcm(T a,T b){return a*b / gcd<T>(a, b);}
template <class T> inline T power(T b,T p){ull x=1;while(p--)x*=b;return x;}
const int mod = 1000000007;

#define pi        acos(-1.0)//3.1415926535897932
#define inf       1e9 + 7
#define MAX       1000010
/// 'N'+'A'+'E'+'E'+'E'+'M' ///
/// Hash
string s, t;
//ll BASE = 129, MOD = 998244353LL;
ll BASE = 100001, MOD = 1000000007;
ll Pow[MAX+5];
ll n, H[MAX+5], revH[MAX+5];
void prePower(){
    Pow[0] = 1LL;
    for(int i = 1; i < MAX; i++){
        Pow[i] = (Pow[i-1] * BASE) % MOD;
    }
}
void Hash(string str){
    H[0] = str[0] - 'a';
    for(int i = 1; i < str.size(); i++){
        H[i] = (H[i-1] * BASE) % MOD;
        H[i] = (H[i] + (str[i] - 'a')) % MOD;
    }
}
void revHash(string str){
    revH[0] = str[0] - 'a';
    for(int i = 1; i < str.size(); i++){
        revH[i] = (revH[i-1] * BASE) % MOD;
        revH[i] = (revH[i] + (str[i] - 'a')) % MOD;
    }
}
ll RollingHash(int l, int r){
    if(l == 0) return H[r];
    ll R = H[r];
    ll L = (H[l-1] * Pow[r-l+1]) % MOD;
    return (R - L + MOD) % MOD;
}
ll revRollingHash(int l, int r){
    if(l == 0) return revH[r];
    ll R = revH[r];
    ll L = (revH[l-1] * Pow[r-l+1]) % MOD;
    return (R - L + MOD) % MOD;
}
bool isPal(int l, int r) {
    if(r < l) return false;
    return RollingHash(l, r) == revRollingHash(n - r - 1, n - l - 1);
}
int main() {
    #ifndef ONLINE_JUDGE
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif
    FastIO;

    prePower();

    int tc; cin >> tc; while(tc--) {
        cin >> s;
        t = s; reverse(all(t));
        n = (ll) s.size();

        Hash(s);
        revHash(t);

        int l = 0, r = n - 1;
        while(s[l] == s[r] && l <= r) l++, r--;

        if(l >= r) {
            cout << s << endl;
            continue;
        }

        string A = s.substr(0 , l);
        string C = s.substr(r + 1);
        string B = "";

        int posA = l, posB = r;
        for(int i = l; i <= r; i++) {
            if(isPal(l, i)) posA = i;
        }
        for(int j = r; j >= l; j--) {
            if(isPal(j, r)) posB = j;
        }

        if(posA - l >= r - posB) B = s.substr(l, posA - l + 1);
        else B = s.substr(posB, r - posB + 1);

        cout << A + B + C << endl;
    }

    #ifndef ONLINE_JUDGE
        printf("\n**Time -> %.10fs\n", (double)(clock()-tStart) / CLOCKS_PER_SEC);
    #endif

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
#define FastIO      ios_base::sync_with_stdio(false); cin.tie(0);
#define aPrint(a,b,c)for(int i=b;i<=c;i++)cout<<a[i]<<" ";cout<<endl;
#define vPrint(a)   for(int i=0;i<a.size();i++){cout<<a[i];if(i==a.size()-1)cout<<endl;else cout<<" ";}
#define Case(t)     printf("Case %d: ", t)
#define clr(x,a)    memset(x,a,sizeof(x))
#define debug(x)    cerr<<#x<<" = "<<(x)<<"\n"

#define umap        unordered_map
#define plll        pair<ll, pair<ll, ll> >
#define pll         pair<ll, ll>
#define ff          first
#define ss          second
#define mp          make_pair
#define pb          push_back
#define ppb         pop_back
#define sf          scanf
#define pf          printf
#define all(a)      a.begin(),a.end()
#define allr(a)     a.rbegin(),a.rend()
#define Unique(a)   sort(all(a)), a.erase(unique(all(a)),a.end())
template <class T> inline T bigmod(T b,T p,T M){T ret=1;for(;p>0;p>>=1){if(p&1) ret=(ret*b)%M;b=(b*b)%M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T lcm(T a,T b){return a*b / gcd<T>(a, b);}
template <class T> inline T power(T b,T p){ull x=1;while(p--)x*=b;return x;}
const int mod = 1000000007;

#define pi        acos(-1.0)//3.1415926535897932
#define inf       1e9 + 7
#define MAX       1000010
/// 'N'+'A'+'E'+'E'+'E'+'M' ///
/// Hash
string s, t;
ll BASE = 29, MOD = 1000000007;
ll Pow[MAX+5];
ll n, H[MAX+5], revH[MAX+5];
ll charToInt(char ch) {
    if(ch >= 'A' && ch <= 'Z') return ch - 'A' + 26 + 1;
    return ch - 'a' + 1;
}
void prePower(){
    Pow[0] = 1LL;
    for(int i = 1; i <= 100001; i++){
        Pow[i] = (Pow[i-1] * BASE) % MOD;
    }
}
void Hash(string str){
    H[0] = charToInt(str[0]);
    for(int i = 1; i < str.size(); i++){
        H[i] = (H[i-1] * BASE) % MOD;
        H[i] = (H[i] + charToInt(str[i])) % MOD;
    }
}
void revHash(string str){
    revH[0] = charToInt(str[0]);
    for(int i = 1; i < str.size(); i++){
        revH[i] = (revH[i-1] * BASE) % MOD;
        revH[i] = (revH[i] + charToInt(str[i])) % MOD;
    }
}
ll RollingHash(int l, int r){
    ll R = H[r];
    ll L = (H[l-1] * Pow[r-l+1]) % MOD;
    return (R - L + MOD) % MOD;
}
ll revRollingHash(int l, int r){
    ll R = revH[r];
    ll L = (revH[l-1] * Pow[r-l+1]) % MOD;
    return (R - L + MOD) % MOD;
}
bool isPal(int l, int r) {
    if(r < l) return false;
    return RollingHash(l, r) == revRollingHash(n - r - 1, n - l - 1);
}
int main() {
    #ifndef ONLINE_JUDGE
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif
    FastIO;

    prePower();

    int tc; cin >> tc; while(tc--) {
        cin >> s;
        t = s; reverse(all(t));
        n = (ll) s.size();

        Hash(s);
        revHash(t);

        int l = 0, r = n - 1;
        while(s[l] == s[r] && l <= r) l++, r--;

        if(l >= r) {
            cout << s << endl;
            continue;
        }

        string A = s.substr(0 , l);
        string C = s.substr(r + 1);
        string B = "";

        int posA = l, posB = r;
        for(int i = l; i <= r; i++) {
            if(isPal(l, i)) posA = i;
        }
        for(int j = r; j >= l; j--) {
            if(isPal(j, r)) posB = j;
        }

        if(posA - l >= r - posB) B = s.substr(l, posA - l + 1);
        else B = s.substr(posB, r - posB + 1);

        cout << A + B + C << endl;
    }

    #ifndef ONLINE_JUDGE
        printf("\n**Time -> %.10fs\n", (double)(clock()-tStart) / CLOCKS_PER_SEC);
    #endif

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
#define FastIO      ios_base::sync_with_stdio(false); cin.tie(0);
#define aPrint(a,b,c)for(int i=b;i<=c;i++)cout<<a[i]<<" ";cout<<endl;
#define vPrint(a)   for(int i=0;i<a.size();i++){cout<<a[i];if(i==a.size()-1)cout<<endl;else cout<<" ";}
#define Case(t)     printf("Case %d: ", t)
#define clr(x,a)    memset(x,a,sizeof(x))
#define debug(x)    cerr<<#x<<" = "<<(x)<<"\n"

#define umap        unordered_map
#define plll        pair<ll, pair<ll, ll> >
#define pll         pair<ll, ll>
#define ff          first
#define ss          second
//#define mp          make_pair
#define pb          push_back
#define ppb         pop_back
#define sf          scanf
#define pf          printf
#define all(a)      a.begin(),a.end()
#define allr(a)     a.rbegin(),a.rend()
#define Unique(a)   sort(all(a)), a.erase(unique(all(a)),a.end())
template <class T> inline T bigmod(T b,T p,T M){T ret=1;for(;p>0;p>>=1){if(p&1) ret=(ret*b)%M;b=(b*b)%M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T lcm(T a,T b){return a*b / gcd<T>(a, b);}
template <class T> inline T power(T b,T p){ull x=1;while(p--)x*=b;return x;}
const int mod = 1000000007;

#define pi        acos(-1.0)//3.1415926535897932
#define inf       1e9 + 7
#define MAX       1000010
/// 'N'+'A'+'E'+'E'+'E'+'M' ///
/// Hash
struct FindHash{
    ll BASE1 = 129, BASE2 = 371;
    ll MOD1 = 998244353LL, MOD2 = 1000000009LL;
    vector<int> Pow1, Pow2;
    vector<int> H1, H2;
    string s;
    int sz;

    void SET(string _s)
    {
        Pow1.clear(), Pow2.clear();
        H1.clear(), H2.clear();

        s = _s;
        sz = s.size();

        Pow1.pb(1),
        Pow2.pb(1);
        for(int i = 1; i < sz + 2; i++) {
            Pow1.pb((1LL * Pow1.back() * BASE1) % MOD1);
            Pow2.pb((1LL * Pow2.back() * BASE2) % MOD2);
        }

        H1.pb(s[0] - 'a');
        H2.pb(s[0] - 'a');
        for(int i = 1; i < sz; i++) {
            H1.pb((1LL * H1.back() * BASE1 + s[i]-'a') % MOD1);
            H2.pb((1LL * H2.back() * BASE2 + s[i]-'a') % MOD2);
        }
    }

    pair<int, int> GET(int i, int j)
    {
        pair<int, int> res = make_pair(H1[j], H2[j]);
        if(i > 0) {
            ll A = (res.ff - (1LL * H1[i-1] * Pow1[j-i+1])) % MOD1;
            ll B = (res.ss - (1LL * H2[i-1] * Pow2[j-i+1])) % MOD2;
            res = make_pair(A, B);
        }
        res.ff = (res.ff % MOD1 + MOD1) % MOD1;
        res.ss = (res.ss % MOD2 + MOD2) % MOD2;
        return res ;
    }

} Forward, Backward;

bool isPal(int l, int r, int n) {
    if(r < l) return false;
    return Forward.GET(l, r) == Backward.GET(n - r - 1, n - l - 1);
}
int main() {
    #ifndef ONLINE_JUDGE
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif
    FastIO;

    string s, t;
    int tc; cin >> tc; while(tc--) {
        cin >> s;
        t = s; reverse(all(t));
        ll n = (ll) s.size();

        Forward.SET(s);
        Backward.SET(t);

        int l = 0, r = n - 1;
        while(s[l] == s[r] && l <= r) l++, r--;

        if(l >= r) {
            cout << s << endl;
            continue;
        }

        string A = s.substr(0 , l);
        string C = s.substr(r + 1);
        string B = "";

        int posA = l, posB = r;
        for(int i = l; i <= r; i++) {
            if(isPal(l, i, n)) posA = i;
        }
        for(int j = r; j >= l; j--) {
            if(isPal(j, r, n)) posB = j;
        }

        if(posA - l >= r - posB) B = s.substr(l, posA - l + 1);
        else B = s.substr(posB, r - posB + 1);

        cout << A + B + C << endl;
    }

    #ifndef ONLINE_JUDGE
        printf("\n**Time -> %.10fs\n", (double)(clock()-tStart) / CLOCKS_PER_SEC);
    #endif

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
#define FastIO      ios_base::sync_with_stdio(false); cin.tie(0);
#define aPrint(a,b,c)for(int i=b;i<=c;i++)cout<<a[i]<<" ";cout<<endl;
#define vPrint(a)   for(int i=0;i<a.size();i++){cout<<a[i];if(i==a.size()-1)cout<<endl;else cout<<" ";}
#define Case(t)     printf("Case %d: ", t)
#define clr(x,a)    memset(x,a,sizeof(x))
#define debug(x)    cerr<<#x<<" = "<<(x)<<"\n"

#define umap        unordered_map
#define plll        pair<ll, pair<ll, ll> >
#define pll         pair<ll, ll>
#define ff          first
#define ss          second
#define mp          make_pair
#define pb          push_back
#define ppb         pop_back
#define sf          scanf
#define pf          printf
#define all(a)      a.begin(),a.end()
#define allr(a)     a.rbegin(),a.rend()
#define Unique(a)   sort(all(a)), a.erase(unique(all(a)),a.end())
template <class T> inline T bigmod(T b,T p,T M){T ret=1;for(;p>0;p>>=1){if(p&1) ret=(ret*b)%M;b=(b*b)%M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T lcm(T a,T b){return a*b / gcd<T>(a, b);}
template <class T> inline T power(T b,T p){ull x=1;while(p--)x*=b;return x;}
const int mod = 1000000007;

#define pi        acos(-1.0)//3.1415926535897932
#define inf       1e9 + 7
#define MAX       1000010
/// 'N'+'A'+'E'+'E'+'E'+'M' ///
/// Hash
string s, t;
ll BASE = 29, MOD = 1000000007;
ll Pow[MAX+5];
ll H[MAX+5], revH[MAX+5];
ll charToInt(char ch) {
    if(ch >= 'A' && ch <= 'Z') return ch - 'A' + 26 + 1;
    return ch - 'a' + 1;
}
void prePower(){
    Pow[0] = 1LL;
    for(int i = 1; i <= 100001; i++){
        Pow[i] = (Pow[i-1] * BASE) % MOD;
    }
}
void Hash(string str){
    H[0] = charToInt(str[0]);
    for(int i = 1; i < str.size(); i++){
        H[i] = (H[i-1] * BASE) % MOD;
        H[i] = (H[i] + charToInt(str[i])) % MOD;
    }
}
void revHash(string str){
    revH[0] = charToInt(str[0]);
    for(int i = 1; i < str.size(); i++){
        revH[i] = (revH[i-1] * BASE) % MOD;
        revH[i] = (revH[i] + charToInt(str[i])) % MOD;
    }
}
ll RollingHash(int l, int r){
    if(l > r) return 0LL;
    ll R = H[r];
    ll L = (H[l-1] * Pow[r-l+1]) % MOD;
    return (R - L + MOD) % MOD;
}
ll revRollingHash(int l, int r){
    if(l > r) return 0LL;
    ll R = revH[r];
    ll L = (revH[l-1] * Pow[r-l+1]) % MOD;
    return (R - L + MOD) % MOD;
}
ll AddTwoSubStringHash(int l, int r, int x, int y) {
    if(l > r) return RollingHash(x, y);
    if(x > y) return RollingHash(l, r);
    ll A = RollingHash(l, r);
    ll B = RollingHash(x, y);
    ll HH = (A * Pow[y - x + 1]) % MOD;
    HH = (HH + B + MOD) % MOD;
    return HH;
}
ll AddTwoSubStringRevHash(int l, int r, int x, int y) {
    if(l > r) return revRollingHash(x, y);
    if(x > y) return revRollingHash(l, r);
    ll A = revRollingHash(l, r);
    ll B = revRollingHash(x, y);
    ll HH = (A * Pow[y - x + 1]) % MOD;
    HH = (HH + B + MOD) % MOD;
    return HH;
}
int isOkay(int baad) {
    int n = s.size();
    int l = 0, r = baad - 1;
    int x = n - baad, y = n - 1;
    for( ; r < n; l++, r++, x--, y--) {
        ll H1 = AddTwoSubStringHash(0, l - 1, r + 1, n - 1);
        ll H2 = AddTwoSubStringRevHash(0, x - 1, y + 1, n - 1);
        if(H1 == H2) return l;
    }
    return -1;
}
int main() {
    #ifndef ONLINE_JUDGE
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif
    FastIO;

    prePower();

    int tc; cin >> tc; while(tc--) {
        cin >> s;
        t = s; reverse(all(t));
        int n = (int) s.size();

        Hash(s);
        revHash(t);

        if(H[n - 1] == revH[n - 1]) {
            cout << s << endl;
            continue;
        }

        int mini = INT_MAX, X, Y;
        for(int parity : {0, 1}) {
            int l = 1, r = n - 1;
            if(l%2 != parity) l++;
            if(r%2 != parity) r--;
            while(l <= r) {
                int mid = (l + r) / 2;
                if(mid%2 != parity) mid--;
                if(mid > r) break;
                int tmp = isOkay(mid);
                if(tmp != -1){
                    if(mid < mini) {
                        mini = mid;
                        X = tmp;
                        Y = X + mid - 1;
                    }
                    r = mid - 2;
                }
                else l = mid + 2;
            }
        }
        //cout << X << " " << Y << endl;
        cout << s.substr(0, X) + s.substr(Y + 1) << endl;

    }

    #ifndef ONLINE_JUDGE
        printf("\n**Time -> %.10fs\n", (double)(clock()-tStart) / CLOCKS_PER_SEC);
    #endif

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
#define FastIO      ios_base::sync_with_stdio(false); cin.tie(0);
#define aPrint(a,b,c)for(int i=b;i<=c;i++)cout<<a[i]<<" ";cout<<endl;
#define vPrint(a)   for(int i=0;i<a.size();i++){cout<<a[i];if(i==a.size()-1)cout<<endl;else cout<<" ";}
#define Case(t)     printf("Case %d: ", t)
#define clr(x,a)    memset(x,a,sizeof(x))
#define debug(x)    cerr<<#x<<" = "<<(x)<<"\n"

#define umap        unordered_map
#define plll        pair<ll, pair<ll, ll> >
#define pll         pair<ll, ll>
#define ff          first
#define ss          second
#define mp          make_pair
#define pb          push_back
#define ppb         pop_back
#define sf          scanf
#define pf          printf
#define all(a)      a.begin(),a.end()
#define allr(a)     a.rbegin(),a.rend()
#define Unique(a)   sort(all(a)), a.erase(unique(all(a)),a.end())
template <class T> inline T bigmod(T b,T p,T M){T ret=1;for(;p>0;p>>=1){if(p&1) ret=(ret*b)%M;b=(b*b)%M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T lcm(T a,T b){return a*b / gcd<T>(a, b);}
template <class T> inline T power(T b,T p){ull x=1;while(p--)x*=b;return x;}
const int mod = 1000000007;

#define pi        acos(-1.0)//3.1415926535897932
#define inf       1e9 + 7
#define MAX       1000010
/// 'N'+'A'+'E'+'E'+'E'+'M' ///
/// Hash
string s, t;
ll BASE = 29, MOD = 1000000007;
ll Pow[MAX+5];
ll n, H[MAX+5], revH[MAX+5];
ll charToInt(char ch) {
    if(ch >= 'A' && ch <= 'Z') return ch - 'A' + 26 + 1;
    return ch - 'a' + 1;
}
void prePower(){
    Pow[0] = 1LL;
    for(int i = 1; i <= 100001; i++){
        Pow[i] = (Pow[i-1] * BASE) % MOD;
    }
}
void Hash(string str){
    H[0] = charToInt(str[0]);
    for(int i = 1; i < str.size(); i++){
        H[i] = (H[i-1] * BASE) % MOD;
        H[i] = (H[i] + charToInt(str[i])) % MOD;
    }
}
void revHash(string str){
    revH[0] = charToInt(str[0]);
    for(int i = 1; i < str.size(); i++){
        revH[i] = (revH[i-1] * BASE) % MOD;
        revH[i] = (revH[i] + charToInt(str[i])) % MOD;
    }
}
ll RollingHash(int l, int r){
    ll R = H[r];
    ll L = (H[l-1] * Pow[r-l+1]) % MOD;
    return (R - L + MOD) % MOD;
}
ll revRollingHash(int l, int r){
    ll R = revH[r];
    ll L = (revH[l-1] * Pow[r-l+1]) % MOD;
    return (R - L + MOD) % MOD;
}
bool isPal(int l, int r) {
    if(r < l) return false;
    return RollingHash(l, r) == revRollingHash(n - r - 1, n - l - 1);
}
int main() {
    #ifndef ONLINE_JUDGE
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif
    FastIO;

    prePower();

    int tc; cin >> tc; while(tc--) {
        cin >> s;
        t = s; reverse(all(t));
        n = (ll) s.size();

        Hash(s);
        revHash(t);

        int l = 0, r = n - 1;
        while(s[l] == s[n - l - 1] && l <= r) l++, r--;

        if(l >= r) {
            cout << s << endl;
            continue;
        }

        string A = s.substr(0 , l);
        string C = s.substr(r + 1);
        string B = "";

        int posA = -1, posB = -1;
        for(int i = l; i <= r; i++) {
            if(isPal(l, i)) posA = i;
        }
        for(int j = r; j >= l; j--) {
            if(isPal(j, r)) posB = j;
        }

        if(posA - l >= r - posB) B = s.substr(l + 1, posA - l + 1);
        else B = s.substr(posB, r - posB + 1);

        cout << A + B + C << endl;
    }

    #ifndef ONLINE_JUDGE
        printf("\n**Time -> %.10fs\n", (double)(clock()-tStart) / CLOCKS_PER_SEC);
    #endif

    return 0;
}