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

int vis[3002],parent[3001];

list<int> adjlist[3002];

vector<int> v;

pair<int,int> dfs1(int s)
{
    vis[s]=1;

    pair<int,int>  r;

    for(list<int> ::iterator it= adjlist[s].begin() ; it!=adjlist[s].end() ; it++)
    {
        if(vis[*it]==0)
        {
            //cout<<*it<<endl;
            parent[*it]=s;
            r=dfs1(*it);

            if(r.first!=-1)
                return  r;

        }
        else if(vis[*it]==1 && *it!=parent[s])
            {
                //cout<<s<<endl;
                //cout<<parent[s]<<" "<<*it<<endl;
                return make_pair(s,*it);
            }
    }
    vis[s]=2;
    return make_pair(-1,-1);
}
int d[3001];
void dfs(int s)
{
    vis[s]=1;

    for(list<int> ::iterator it= adjlist[s].begin() ; it!=adjlist[s].end() ; it++)
    {
        if(vis[*it]==0)
        {

                if(binary_search(v.begin(),v.end(),s))
                    {
                        d[*it]=1;
                        //cout<<s<<endl;
                    }
                else
                    d[*it]=d[s]+1;

                 dfs(*it);

        }
    }

}

int main()
{
    int n,x,y,i;
    cin>>n;

    memset(vis , 0 , sizeof(vis));

    for(i=1;i<=n;i++)
    {
        cin>>x>>y;
        adjlist[x].push_back(y);
        adjlist[y].push_back(x);
    }

    pair<int,int> ans=dfs1(1);

   memset(vis , 0 , sizeof(vis));

    int u=ans.first;
     //cout<<ans.first<<" "<<ans.second<<endl;
    while(u!=ans.second)
    {
        v.push_back(u);
        u=parent[u];

    }
    v.push_back(u);
    d[ans.first]=0;
    dfs(ans.first);
    for(i=0;i<v.size();i++)
        d[v[i]]=0;

        for(i=0;i<v.size();i++)
            cout<<v[i]<<endl;

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

        cout<<d[i]<<" ";
    }

    return 0;
}


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

int vis[3002],parent[3001];

list<int> adjlist[3002];

vector<int> v;

pair<int,int> dfs1(int s)
{
    vis[s]=1;

    pair<int,int>  r;

    for(list<int> ::iterator it= adjlist[s].begin() ; it!=adjlist[s].end() ; it++)
    {
        if(vis[*it]==0)
        {
            //cout<<*it<<endl;
            parent[*it]=s;
            r=dfs1(*it);

            if(r.first!=-1)
                return  r;

        }
        else if(vis[*it]==1 && *it!=parent[s])
            {
                //cout<<s<<endl;
                //cout<<parent[s]<<" "<<*it<<endl;
                return make_pair(s,*it);
            }
    }
    vis[s]=2;
    return make_pair(-1,-1);
}
//int d[3001];
int  dfs(int s , int d)
{
    vis[s]=1;

    if(binary_search(v.begin(),v.end(),s))
        return d;

        int r;

    for(list<int> ::iterator it= adjlist[s].begin() ; it!=adjlist[s].end() ; it++)
    {
        if(vis[*it]==0)
        {
          r=dfs(*it,d+1);

          if(r!=-1)
            return r;
        }
    }
    return -1;

}

int main()
{
    int n,x,y,i;
    cin>>n;

    memset(vis , 0 , sizeof(vis));

    for(i=1;i<=n;i++)
    {
        cin>>x>>y;
        adjlist[x].push_back(y);
        adjlist[y].push_back(x);
    }

    pair<int,int> ans=dfs1(1);

    int u=ans.first;
     cout<<ans.first<<" "<<ans.second<<endl;
    while(u!=ans.second)
    {
        v.push_back(u);
        u=parent[u];

    }
    v.push_back(u);
    sort(v.begin(),v.end());
    //d[ans.first]=0;
    //dfs(1);
    /*for(i=0;i<v.size();i++)
        d[v[i]]=0;

        for(i=0;i<v.size();i++)
            cout<<v[i]<<endl;*/

         for(i=1;i<=n;i++)
         {
             memset(vis , 0 , sizeof(vis));
             cout<<dfs(i,0)<<" ";
         }

    /*for(i=1;i<=n;i++)
    {

        cout<<d[i]<<" ";
    }*/

    return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int n, j, a, b, e;
vector<int> r(3001);
vector<vector<int>> g(3001);

void dfsr(int x, int y)
{
	r[x] = y;
	for (int i = 0; i < g[x].size(); i++) if (!r[g[x][i]]) dfsr(g[x][i], y + 1);
}

bool dfs(int x, int y)
{
	if (r[x]) { e = x; return true; }
	r[x] = 1;
	for (int i = 0; i < g[x].size(); i++)
		if (g[x][i] != y && dfs(g[x][i], x))
		{
			dfsr(x, 1);
			if (x != e) return true;
			return false;
		}
	r[x] = 0;
	return false;
}

int main()
{
	cin >> n;
	j = n;
	while(j--)
	{
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(1, 1);
	dfsr(e, 1);
	j++;
	while (j++ < n) cout << r[j] - 1<< " ";
	return 0;
}


#include<iostream>
#include<vector>
#include<bitset>
using namespace std;
int n, a, b, e;
bitset<3001> v;
vector<int> r(3001, -1);
vector<vector<int>> g(3001);

bool dfs (int x, int y)
{
	if (v[x]) { e = x; return true; }
	v[x] = 1;
	for (int i = 0; i < g[x].size(); i++)
		if (g[x][i] != y && dfs(g[x][i], x))
		{
			r[x] = 0;
			if (x != e) return true;
			break;
		}
	return false;
}

void dfsr(int x, int y)
{
	v[x] = 1;
	if (r[x] != 0) 	r[x] = r[y] + 1;
	for (int i = 0; i < g[x].size(); i++) if (g[x][i] != y && !v[g[x][i]]) dfsr(g[x][i], x);
}

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(1, 1);
	v.reset();
	for (int i = 1; i <= n; i++) if (r[i] == 0) { dfsr(i, i); break; }
	for (int i = 1; i <= n; i++) cout << r[i] << " ";
	return 0;
}


#include<iostream>
#include<vector>
#include <bitset>
using namespace std;
int n, a, b, e;
bitset<3001> v;
vector<int> r(3001, -1);
vector<vector<int>> g(3001);

bool dfs (int x, int y)
{
	if (v[x]) { e = x; return true; }
	v[x] = 1;
	for (int i = 0; i < g[x].size(); i++)
		if (g[x][i] != y && dfs(g[x][i], x))
		{
			r[x] = 0;
			if (x != e) return true;
		}
	return false;
}

void dfsr(int x, int y)
{
	v[x] = 1;
	if (r[x] != 0) 	r[x] = r[y] + 1;
	for (int i = 0; i < g[x].size(); i++) if (g[x][i] != y && !v[g[x][i]]) dfsr(g[x][i], x);
}

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(1, 0);
	v.reset();
	dfsr(1, 0);
	for (int i = 1; i <= n; i++) cout << r[i] << " ";
	return 0;
}


#include<iostream>
#include<vector>
#include<bitset>
using namespace std;
int n, a, b, e;
bitset<3001> v;
vector<int> r(3001, -1);
vector<vector<int>> g(3001);

bool dfs (int x, int y)
{
	if (v[x]) { e = x; return true; }
	v[x] = 1;
	for (int i = 0; i < g[x].size(); i++)
		if (g[x][i] != y && dfs(g[x][i], x))
		{
			r[x] = 0;
			if (x != e) return true;
			break;
		}
	return false;
}

void dfsr(int x, int y)
{
	v[x] = 1;
	if (r[x] != 0) 	r[x] = r[y] + 1;
	for (int i = 0; i < g[x].size(); i++) if (g[x][i] != y && !v[g[x][i]]) dfsr(g[x][i], x);
}

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(1, 0);
	v.reset();
	dfsr(1, 0);
	for (int i = 1; i <= n; i++) cout << r[i] << " ";
	return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int dp[3000+5];
vector<int>gs[3000+5];
int n;
bool v[3000+5];
int parent[3000+5],super,st;

int dfss(int x){
if(dp[x]!= 1<<30)
    return dp[x];
for(int i = 0;i < gs[x].size();i++){
    dp[x] = min(dp[x],dfss(gs[x][i])+1);
}
return dp[x];
}

void cycle(int x){
    int i = 0;
while(x!=super&&x!=parent[x]&&i < 3000+5){
//  cout<<x+1<<' ';
    dp[x] = 0;
    x = parent[x];
    i++;
}

dp[x] = 0;
// cout<<x+1<<"\n***********"<<endl;
}
bool f = false;
int itis;
void dfs(int x){
    v[x] = true;
    int cc = 0;
    for(int i = 0;i < gs[x].size();i++){
      if(v[gs[x][i]]&&gs[x][i]!= parent[x]&&!f) super = gs[x][i],st = x,itis = st,f = true;
      //    dp[x] = 0,super = gs[x][i],st = x,f = true,cout<<"***"<<x+1<<' '<<gs[x][i]+1<<'\n';
      if(!v[gs[x][i]]){
      parent[gs[x][i]] = x;
        dfs(gs[x][i]);
      }
    }
if(x == itis){
    dp[x] = 0;
    itis = parent[itis];
    if(x == super) itis = -1;
}
}

int main(){
    ios_base::sync_with_stdio(0);
    int x,y;
cin >> n;
for(int i = 0; i < n ;i++){
    cin >> x >> y;
    x--,y--;
    gs[x].push_back(y);
    gs[y].push_back(x);
    parent[i] = i;
    v[i] =  false;
    dp[i] = 1<<30;
}
dfs(0);
//cycle(st);
//berno(0); //cout<<endl;
//cout<<st<<' '<<super<<endl;
// cycle(st);

/*
for(int i = 0 ; i < n ; i++)
    if(dfs[i] == )*/
for(int i = 0;i < n ;i++)
    if(dp[i] == 1<<30){
        dfss(i);
    }
    for(int i = 0;i < n ;i++)cout<<dp[i]<<' ';cout<<endl;
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int dfslow[4000],dfsnum[4000],timer = 0;
vector<int>stk;
int counter[4000];
bool v2[4000];
int dp[4000];
vector<int>gs[4000];
int n;

bool v[1000];
int dfss(int x){
if(dp[x]!= 5000)
    return dp[x];
for(int i = 0;i < gs[x].size();i++){
    dp[x] = min(dp[x],dfss(gs[x][i])+1);
}
return dp[x];
}
int parent[4000],super,st;
void cycle(int x){
while(x!=super){
    cout<<x<<' ';
    x = parent[x];
}
cout<<endl;
}
bool f = false;
void dfs(int x){
    v[x] = true;
    int cc = 0;
    for(int i = 0;i < gs[x].size();i++){
      if(v[gs[x][i]]&&gs[x][i]!= parent[x]) super = gs[x][i];
      //    dp[x] = 0,super = gs[x][i],st = x,f = true,cout<<"***"<<x+1<<' '<<gs[x][i]+1<<'\n';
      if(!v[gs[x][i]]){
      parent[gs[x][i]] = x;
        dfs(gs[x][i]);
      }
    }

}

int stps = 10000;
bool bernoulli[500];
bool berno(int x){
    v2[x] = true;
    bool y = false,z = false,zz;
    for(int i = 0;i < gs[x].size();i++){
        if(v2[gs[x][i]]&&dp[gs[x][i]]&&gs[x][i]!= parent[x]){
            stps = gs[x][i];
            dp[gs[x][i]] = 0;
// cout<<gs[x][i]+1<<" "<<x+1<<" ***\n";
            return true;
        }
        if(!v2[gs[x][i]]){
            zz = berno(gs[x][i]);
            if(zz){
            //  cout<<gs[x][i]+1<<"**\n";
                dp[gs[x][i]] = 0;
        //  if(x == stps) cout<<x+1<<"*\n";
            return true;
            }

            y|= zz;
            z&= zz;
        }
    }
    if(y&&f)
        dp[x] = 0;//,cout<<x+1<<" **\n";
    if(x == stps) f = false;
    return false;
}

int main(){
    int x,y;
cin >> n;
for(int i = 0; i < n ;i++){
    cin >> x >> y;
    x--,y--;
    gs[x].push_back(y);
    gs[y].push_back(x);
    parent[i] = i;
    v[i] = v2[i] = dfslow[i] = false;
    dp[i] = 5000,counter[i] = 0;
    dfsnum[i] = -1;
}
dfs(0);
berno(0); //cout<<endl;
// cycle(st);
//cout<<st<<' '<<super<<endl;
/*
for(int i = 0 ; i < n ; i++)
    if(dfs[i] == )*/
for(int i = 0;i < n ;i++)
    if(dp[i] == 5000){
        dfss(i);
    }
    for(int i = 0;i < n ;i++)cout<<dp[i]<<' ';cout<<endl;
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int dp[40000];
vector<int>gs[40000];
int n;

bool v[10000];
int dfss(int x){
if(dp[x]!= 1<<30)
    return dp[x];
for(int i = 0;i < gs[x].size();i++){
    dp[x] = min(dp[x],dfss(gs[x][i])+1);
}
return dp[x];
}
int parent[40000],super,st;
void cycle(int x){
while(x!=super&&x!=parent[x]){
//  cout<<x+1<<' ';
    dp[x] = 0;
    x = parent[x];
}

dp[x] = 0;
// cout<<x+1<<"\n***********"<<endl;
}
bool f = false;
void dfs(int x){
    v[x] = true;
    int cc = 0;
    for(int i = 0;i < gs[x].size();i++){
      if(v[gs[x][i]]&&gs[x][i]!= parent[x]&&!f) super = gs[x][i],st = x,cycle(st),f = true;
      //    dp[x] = 0,super = gs[x][i],st = x,f = true,cout<<"***"<<x+1<<' '<<gs[x][i]+1<<'\n';
      if(!v[gs[x][i]]){
      parent[gs[x][i]] = x;
        dfs(gs[x][i]);
      }
    }

}

int main(){
    int x,y;
cin >> n;
for(int i = 0; i < n ;i++){
    cin >> x >> y;
    x--,y--;
    gs[x].push_back(y);
    gs[y].push_back(x);
    parent[i] = i;
    v[i] =  false;
    dp[i] = 1<<30;
}
dfs(0);
//berno(0); //cout<<endl;
//cout<<st<<' '<<super<<endl;
// cycle(st);

/*
for(int i = 0 ; i < n ; i++)
    if(dfs[i] == )*/
for(int i = 0;i < n ;i++)
    if(dp[i] == 1<<30){
        dfss(i);
    }
    for(int i = 0;i < n ;i++)cout<<dp[i]<<' ';cout<<endl;
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int dfslow[4000],dfsnum[4000],timer = 0;
vector<int>stk;
int counter[4000];
bool v2[4000];
int dp[4000];
vector<int>gs[4000];
int n;

bool v[1000];
int dfss(int x){
if(dp[x]!= 5000)
    return dp[x];
for(int i = 0;i < gs[x].size();i++){
    dp[x] = min(dp[x],dfss(gs[x][i])+1);
}
return dp[x];
}
int parent[4000],super,st;
void cycle(int x){
while(x!=super&&x!=parent[x]){
//  cout<<x+1<<' ';
    dp[x] = 0;
    x = parent[x];
}

dp[x] = 0;
// cout<<x+1<<"\n***********"<<endl;
}
bool f = false;
void dfs(int x){
    v[x] = true;
    int cc = 0;
    for(int i = 0;i < gs[x].size();i++){
      if(v[gs[x][i]]&&gs[x][i]!= parent[x]&&!f) super = gs[x][i],st = x,cycle(st),f = true;
      //    dp[x] = 0,super = gs[x][i],st = x,f = true,cout<<"***"<<x+1<<' '<<gs[x][i]+1<<'\n';
      if(!v[gs[x][i]]){
      parent[gs[x][i]] = x;
        dfs(gs[x][i]);
      }
    }

}

int stps = 10000;
bool bernoulli[500];
bool berno(int x){
    v2[x] = true;
    bool y = false,z = false,zz;
    for(int i = 0;i < gs[x].size();i++){
        if(v2[gs[x][i]]&&dp[gs[x][i]]&&gs[x][i]!= parent[x]){
            stps = gs[x][i];
            dp[gs[x][i]] = 0;
// cout<<gs[x][i]+1<<" "<<x+1<<" ***\n";
            return true;
        }
        if(!v2[gs[x][i]]){
            zz = berno(gs[x][i]);
            if(zz){
            //  cout<<gs[x][i]+1<<"**\n";
                dp[gs[x][i]] = 0;
        //  if(x == stps) cout<<x+1<<"*\n";
            return true;
            }

            y|= zz;
            z&= zz;
        }
    }
    if(y&&f)
        dp[x] = 0;//,cout<<x+1<<" **\n";
    if(x == stps) f = false;
    return false;
}

int main(){
    int x,y;
cin >> n;
for(int i = 0; i < n ;i++){
    cin >> x >> y;
    x--,y--;
    gs[x].push_back(y);
    gs[y].push_back(x);
    parent[i] = i;
    v[i] = v2[i] = dfslow[i] = false;
    dp[i] = 5000,counter[i] = 0;
    dfsnum[i] = -1;
}
dfs(0);
//berno(0); //cout<<endl;
//cout<<st<<' '<<super<<endl;
// cycle(st);

/*
for(int i = 0 ; i < n ; i++)
    if(dfs[i] == )*/
for(int i = 0;i < n ;i++)
    if(dp[i] == 5000){
        dfss(i);
    }
    for(int i = 0;i < n ;i++)cout<<dp[i]<<' ';cout<<endl;
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int dfslow[4000],dfsnum[4000],timer = 0;
vector<int>stk;
int counter[4000];
bool v2[4000];
int dp[4000];
vector<int>gs[4000];
int n;
void SCC(int x){
    dfsnum[x] = dfslow[x] = timer++;
    stk.push_back(x);
    v2[x] = true;
    for(int i = 0 ;i < gs[x].size();i++){
        if(dfsnum[gs[x][i]] == -1){
            SCC(gs[x][i]);
        }
        if(v2[gs[x][i]])
            dfslow[x] = min(dfslow[x],dfslow[gs[x][i]]);
    }
    int n = 0;

 if(dfslow[x] == dfsnum[x]){
cout<<"***"<<x<<' ';
         while(1){
            int y = stk.back(); stk.pop_back();
            counter[y] = 1<<30;
            dp[y] = 0;
           cout<<y<<' ';
            if(y == x) break;
         }
         cout<<'\n';
    }
}

void SCCC(int x){
  dfslow[x] = dfsnum[x] = timer++;
  v2[x] = true;
  stk.push_back(x);
  for(int i = 0 ; i < gs[x].size();i++){
         if(dfsnum[gs[x][i]] == -1)
                SCCC(gs[x][i]);
         if(v2[gs[x][i]])
            dfslow[x] = min(dfslow[x],dfslow[gs[x][i]]);}
         if(dfslow[x] == dfsnum[x]){
while (1) {
int v = stk.back(); stk.pop_back(); v2[v] = false;
cout<<v;
if (x == v) break; }
                cout<<endl;
         }
  }

bool v[1000];
int dfss(int x){
if(dp[x]!= 5000)
    return dp[x];
for(int i = 0;i < gs[x].size();i++){
    dp[x] = min(dp[x],dfss(gs[x][i])+1);
}
return dp[x];
}
int parent[4000];
void dfs(int x){
    v[x] = true;
    int cc = 0;
    for(int i = 0;i < gs[x].size();i++){
      if(v[gs[x][i]]&&gs[x][i]!= parent[x])
        dp[x] = 0;//,cout<<"***"<<x+1<<' '<<gs[x][i]+1<<'\n';
      if(!v[gs[x][i]]){
      parent[gs[x][i]] = x;
        dfs(gs[x][i]);
        if(!dp[gs[x][i]])
            dp[x] = 0;
      }
    }

}

int main(){
    int x,y;
cin >> n;
for(int i = 0; i < n ;i++){
    cin >> x >> y;
    x--,y--;
    gs[x].push_back(y);
    gs[y].push_back(x);
    parent[i] = i;
    v[i] = v2[i] = dfslow[i] = false;
    dp[i] = 5000,counter[i] = 0;
    dfsnum[i] = -1;
}
dfs(0);
/*
for(int i = 0 ; i < n ; i++)
    if(dfs[i] == )*/
for(int i = 0;i < n ;i++)
    if(dp[i] == 5000){
        dfss(i);
    }
    for(int i = 0;i < n ;i++)cout<<dp[i]<<' ';cout<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int parent[3005];
bool v[3005];
vector<int>gs[3005];
int d[3005];
int n;
bool r = false;
queue<int>q;
void ring(int x,int y){
    while(x!=y){
        d[x] = 0;
        q.push(x);
        x = parent[x];
    }
d[x] = 0;
q.push(x);
}
void dfs(int x){
    v[x] = true;
    for(int i = 0;i < gs[x].size();i++){
       if(v[gs[x][i]]&&!r&&gs[x][i]!= parent[x]) r = true,ring(x,gs[x][i]);//,cout<<x<<" "<<gs[x][i]<<"**\n",
       else if(!v[gs[x][i]]){
        parent[gs[x][i]] = x;
        dfs(gs[x][i]);
       }
    }
}

int calc(int x){
    if(d[x]!= -1)
        return d[x];
    d[x] = calc(gs[x][0]) + 1;
}

int main(){
//  freopen("in.txt","r",stdin);
cin >> n;

int x,y;
for(int i =0;i < n;i++){
    cin >> x >> y;
    gs[x].push_back(y);
    gs[y].push_back(x);
d[i] = -1;
v[i] = false;
}
d[n] = -1;
v[n] = false;

parent[1] = 1;
dfs(1);

while(!q.empty()){
    x = q.front();q.pop();
    for(int i = 0;i < gs[x].size();i++)
        if(d[gs[x][i]] == -1){
            d[gs[x][i]] = d[x] + 1;
            q.push(gs[x][i]);
        }
}

/*
for(int i = 1;i <= n;i++)
if(d[i] == -1)
    calc(i);
*/

 for(int i= 1 ;i<=n;i++) cout<<d[i]<<" ";
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int dp[3000+5];
vector<int>gs[3000+5];
int n;
bool v[3000+5];
int parent[3000+5],super,st;

int dfss(int x){
if(dp[x]!= 1<<30)
    return dp[x];
for(int i = 0;i < gs[x].size();i++){
    dp[x] = min(dp[x],dfss(gs[x][i])+1);
}
return dp[x];
}

void cycle(int x){
    int i = 0;
while(x!=super&&x!=parent[x]&&i < 3000+5){
//  cout<<x+1<<' ';
    dp[x] = 0;
    x = parent[x];
    i++;
}

dp[x] = 0;
// cout<<x+1<<"\n***********"<<endl;
}
bool f = false;
void dfs(int x){
    v[x] = true;
    int cc = 0;
    for(int i = 0;i < gs[x].size();i++){
      if(v[gs[x][i]]&&gs[x][i]!= parent[x]&&!f) super = gs[x][i],st = x,cycle(st),f = true;
      //    dp[x] = 0,super = gs[x][i],st = x,f = true,cout<<"***"<<x+1<<' '<<gs[x][i]+1<<'\n';
      if(!v[gs[x][i]]){
      parent[gs[x][i]] = x;
        dfs(gs[x][i]);
      }
    }

}

int main(){
    ios_base::sync_with_stdio(0);
    int x,y;
cin >> n;
for(int i = 0; i < n ;i++){
    cin >> x >> y;
    x--,y--;
    gs[x].push_back(y);
    gs[y].push_back(x);
    parent[i] = i;
    v[i] =  false;
    dp[i] = 1<<30;
}
dfs(0);
//berno(0); //cout<<endl;
//cout<<st<<' '<<super<<endl;
// cycle(st);

/*
for(int i = 0 ; i < n ; i++)
    if(dfs[i] == )*/
for(int i = 0;i < n ;i++)
    if(dp[i] == 1<<30){
        dfss(i);
    }
    for(int i = 0;i < n ;i++)cout<<dp[i]<<' ';cout<<endl;
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int dp[3000+5];
vector<int>gs[3000+5];
int n;
bool v[3000+5];
int parent[3000+5],super,st;

int dfss(int x){
if(dp[x]!= 1<<30)
    return dp[x];
for(int i = 0;i < gs[x].size();i++){
    dp[x] = min(dp[x],dfss(gs[x][i])+1);
}
return dp[x];
}

void cycle(int x){
    int i = 0;
while(x!=super&&x!=parent[x]&&i < 3000+5){
//  cout<<x+1<<' ';
    dp[x] = 0;
    x = parent[x];
    i++;
}

dp[x] = 0;
// cout<<x+1<<"\n***********"<<endl;
}
bool f = false;
void dfs(int x){
    v[x] = true;
    int cc = 0;
    for(int i = 0;i < gs[x].size();i++){
      if(v[gs[x][i]]&&gs[x][i]!= parent[x]&&!f) super = gs[x][i],st = x,f = true;
      //    dp[x] = 0,super = gs[x][i],st = x,f = true,cout<<"***"<<x+1<<' '<<gs[x][i]+1<<'\n';
      if(!v[gs[x][i]]){
      parent[gs[x][i]] = x;
        dfs(gs[x][i]);
      }
    }

}

int main(){
    ios_base::sync_with_stdio(0);
    int x,y;
cin >> n;
for(int i = 0; i < n ;i++){
    cin >> x >> y;
    x--,y--;
    gs[x].push_back(y);
    gs[y].push_back(x);
    parent[i] = i;
    v[i] =  false;
    dp[i] = 1<<30;
}
dfs(0);
cycle(st);
//berno(0); //cout<<endl;
//cout<<st<<' '<<super<<endl;
// cycle(st);

/*
for(int i = 0 ; i < n ; i++)
    if(dfs[i] == )*/
for(int i = 0;i < n ;i++)
    if(dp[i] == 1<<30){
        dfss(i);
    }
    for(int i = 0;i < n ;i++)cout<<dp[i]<<' ';cout<<endl;
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int dp[3000+5];
vector<int>gs[3000+5];
int n;
bool v[3000+5];
int parent[3000+5],super,st;

int dfss(int x){
if(dp[x]!= 1<<30)
    return dp[x];
for(int i = 0;i < gs[x].size();i++){
    dp[x] = min(dp[x],dfss(gs[x][i])+1);
}
return dp[x];
}

void cycle(int x){
while(x!=super&&x!=parent[x]){
//  cout<<x+1<<' ';
    dp[x] = 0;
    x = parent[x];
}

dp[x] = 0;
// cout<<x+1<<"\n***********"<<endl;
}
bool f = false;
void dfs(int x){
    v[x] = true;
    int cc = 0;
    for(int i = 0;i < gs[x].size();i++){
      if(v[gs[x][i]]&&gs[x][i]!= parent[x]&&!f) super = gs[x][i],st = x,cycle(st),f = true;
      //    dp[x] = 0,super = gs[x][i],st = x,f = true,cout<<"***"<<x+1<<' '<<gs[x][i]+1<<'\n';
      if(!v[gs[x][i]]){
      parent[gs[x][i]] = x;
        dfs(gs[x][i]);
      }
    }

}

int main(){
    ios_base::sync_with_stdio(0);
    int x,y;
cin >> n;
for(int i = 0; i < n ;i++){
    cin >> x >> y;
    x--,y--;
    gs[x].push_back(y);
    gs[y].push_back(x);
    parent[i] = i;
    v[i] =  false;
    dp[i] = 1<<30;
}
dfs(0);
//berno(0); //cout<<endl;
//cout<<st<<' '<<super<<endl;
// cycle(st);

/*
for(int i = 0 ; i < n ; i++)
    if(dfs[i] == )*/
for(int i = 0;i < n ;i++)
    if(dp[i] == 1<<30){
        dfss(i);
    }
    for(int i = 0;i < n ;i++)cout<<dp[i]<<' ';cout<<endl;
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int dp[8000];
vector<int>gs[8000];
int n;

bool v[8000];
int dfss(int x){
if(dp[x]!= 1<<30)
    return dp[x];
for(int i = 0;i < gs[x].size();i++){
    dp[x] = min(dp[x],dfss(gs[x][i])+1);
}
return dp[x];
}
int parent[8000],super,st;
void cycle(int x){
while(x!=super&&x!=parent[x]){
//  cout<<x+1<<' ';
    dp[x] = 0;
    x = parent[x];
}

dp[x] = 0;
// cout<<x+1<<"\n***********"<<endl;
}
bool f = false;
void dfs(int x){
    v[x] = true;
    int cc = 0;
    for(int i = 0;i < gs[x].size();i++){
      if(v[gs[x][i]]&&gs[x][i]!= parent[x]&&!f) super = gs[x][i],st = x,cycle(st),f = true;
      //    dp[x] = 0,super = gs[x][i],st = x,f = true,cout<<"***"<<x+1<<' '<<gs[x][i]+1<<'\n';
      if(!v[gs[x][i]]){
      parent[gs[x][i]] = x;
        dfs(gs[x][i]);
      }
    }

}

int main(){
    int x,y;
cin >> n;
for(int i = 0; i < n ;i++){
    cin >> x >> y;
    x--,y--;
    gs[x].push_back(y);
    gs[y].push_back(x);
    parent[i] = i;
    v[i] =  false;
    dp[i] = 1<<30;
}
dfs(0);
//berno(0); //cout<<endl;
//cout<<st<<' '<<super<<endl;
// cycle(st);

/*
for(int i = 0 ; i < n ; i++)
    if(dfs[i] == )*/
for(int i = 0;i < n ;i++)
    if(dp[i] == 1<<30){
        dfss(i);
    }
    for(int i = 0;i < n ;i++)cout<<dp[i]<<' ';cout<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int parent[3005];
bool v[3005];
vector<int>gs[3005];
int d[3005];
int n;
bool r = false;

void ring(int x,int y){
//cout<<"******\n";
    while(x!=y){
        d[x] = 0;
//      cout<<x<<" ";
        x = parent[x];
    }
d[x] = 0;
// cout<<x<<"\n";
// cout<<"********\n";
}
void dfs(int x){
    v[x] = true;
//cout<<x<<"*\n";
    for(int i = 0;i < gs[x].size();i++){
       if(v[gs[x][i]]&&!r&&gs[x][i]!= parent[x]) r = true,ring(x,gs[x][i]);//,cout<<x<<" "<<gs[x][i]<<"**\n",
       else if(!v[gs[x][i]]){
        parent[gs[x][i]] = x;
        dfs(gs[x][i]);
       }
    }
}

int calc(int x){
    if(d[x]!= -1)
        return d[x];
//  cout<<"*"<<x<<" "<<d[x]<<endl;
    d[x] = calc(gs[x][0]) + 1;
}

int main(){
//  freopen("in.txt","r",stdin);
cin >> n;

int x,y;
for(int i =0;i < n;i++){
    cin >> x >> y;
    gs[x].push_back(y);
    gs[y].push_back(x);
d[i] = -1;
v[i] = false;
}
d[n] = -1;
v[n] = false;

parent[1] = 1;
dfs(1);

for(int i = 1;i <= n;i++){
if(d[i] == -1) calc(i);
//cout<<i<<" - "<<d[i]<<endl;
/*  if(d[i]!= -1)
        cout<<d[i]<<"*\n";
    else cout<<calc(i)<<"*\n";*/
}

 for(int i= 1 ;i<=n;i++) cout<<d[i]<<" ";
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int dp[3000+50];
vector<int>gs[3000+50];
int n;

bool v[3000+50];
int dfss(int x){
if(dp[x]!= 1<<30)
    return dp[x];
for(int i = 0;i < gs[x].size();i++){
    dp[x] = min(dp[x],dfss(gs[x][i])+1);
}
return dp[x];
}
int parent[3000+50],super,st;
void cycle(int x){
while(x!=super&&x!=parent[x]){
//  cout<<x+1<<' ';
    dp[x] = 0;
    x = parent[x];
}

dp[x] = 0;
// cout<<x+1<<"\n***********"<<endl;
}
bool f = false;
void dfs(int x){
    v[x] = true;
    int cc = 0;
    for(int i = 0;i < gs[x].size();i++){
      if(v[gs[x][i]]&&gs[x][i]!= parent[x]&&!f) super = gs[x][i],st = x,cycle(st),f = true;
      //    dp[x] = 0,super = gs[x][i],st = x,f = true,cout<<"***"<<x+1<<' '<<gs[x][i]+1<<'\n';
      if(!v[gs[x][i]]){
      parent[gs[x][i]] = x;
        dfs(gs[x][i]);
      }
    }

}

int main(){
    int x,y;
cin >> n;
for(int i = 0; i < n ;i++){
    cin >> x >> y;
    x--,y--;
    gs[x].push_back(y);
    gs[y].push_back(x);
    parent[i] = i;
    v[i] =  false;
    dp[i] = 1<<30;
}
dfs(0);
//berno(0); //cout<<endl;
//cout<<st<<' '<<super<<endl;
// cycle(st);

/*
for(int i = 0 ; i < n ; i++)
    if(dfs[i] == )*/
for(int i = 0;i < n ;i++)
    if(dp[i] == 1<<30){
        dfss(i);
    }
    for(int i = 0;i < n ;i++)cout<<dp[i]<<' ';cout<<endl;
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <string>

using namespace std;

/*
int main(){
	cin.sync_with_stdio(false);

	return 0;
}
*/

const int MAXN=3007;
vector<int> g[MAXN];
int cycleStart, cycleEnd;
int color[MAXN];
int visitedfrom[MAXN];
bool incycle[MAXN];
int res[MAXN];

bool visited[MAXN];
void dfs(int v){
	color[v]=1;
	for(size_t i=0; i<g[v].size(); ++i){
		if(visitedfrom[v]==g[v][i]){
			continue;
		}
		if(color[g[v][i]]==0){
			visitedfrom[g[v][i]]=v;
			dfs(g[v][i]);
		} else if(color[g[v][i]]==1){
			cycleStart=g[v][i];
			cycleEnd=v;
		}
	}
	color[v]=2;
}

int main(){
	cin.sync_with_stdio(false);
	int n, a, b;
	cin>>n;
	for(int i=0; i<n; ++i){
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	dfs(1);

	queue<pair<int, int>> q;
	incycle[cycleStart]=true;
	visited[cycleStart]=true;
	q.push(make_pair(cycleStart, 0));
	for(int u=cycleEnd; u!=cycleStart; u=visitedfrom[u]){
		incycle[u]=true;
		q.push(make_pair(u, 0));
		visited[u]=true;
	}

	while(!q.empty()){
		int frontid=q.front().first;
		int frontdist=q.front().second;
		q.pop();
		visited[frontid]=true;
		res[frontid]=frontdist;
		for(size_t i=0; i<g[frontid].size(); ++i){
			if(!visited[g[frontid][i]]){
				q.push(make_pair(g[frontid][i], frontdist+1));
			}
		}

	}

	for(int i=1; i<=n; ++i){
		cout<<res[i]<<" ";
	}
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <string>

using namespace std;

/*
int main(){
	cin.sync_with_stdio(false);

	return 0;
}
*/

const int MAXN=3007;
vector<int> g[MAXN];
int cycleStart, cycleEnd;
int color[MAXN];
int visitedfrom[MAXN];
bool incycle[MAXN];

void dfs(int v){
	color[v]=1;
	for(size_t i=0; i<g[v].size(); ++i){
		if(visitedfrom[v]==g[v][i]){
			continue;
		}
		if(color[g[v][i]]==0){
			visitedfrom[g[v][i]]=v;
			dfs(g[v][i]);
		} else if(color[g[v][i]]==1){
			cycleStart=g[v][i];
			cycleEnd=v;
		}
	}
	color[v]=2;
}

int bfs(int v){
	queue<pair<int, int>> q; // id, dist
	q.push(make_pair(v, 0));
	while(!q.empty()){
		int frontid=q.front().first;
		int frontdist=q.front().second;
		q.pop();
		if(incycle[frontid]){
			return frontdist;
		}
		for(int i=0; i<g[frontid].size(); ++i){
			q.push(make_pair(g[frontid][i], frontdist+1));
		}
	}
}

int main(){
	cin.sync_with_stdio(false);
	int n, a, b;
	cin>>n;
	for(int i=0; i<n; ++i){
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	dfs(1);

	incycle[cycleStart]=true;
	for(int u=cycleEnd; u!=cycleStart; u=visitedfrom[u]){
		incycle[u]=true;
	}

	for(int i=1; i<=n; ++i){
		cout<<bfs(i)<<" ";
	}
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <string>

using namespace std;

/*
int main(){
	cin.sync_with_stdio(false);

	return 0;
}
*/

const int MAXN=3007;
vector<int> g[MAXN];
int cycleStart, cycleEnd;
int color[MAXN];
int visitedfrom[MAXN];
bool incycle[MAXN];
int res[MAXN];

bool visited[MAXN];
void dfs(int v){
	color[v]=1;
	for(size_t i=0; i<g[v].size(); ++i){
		if(visitedfrom[v]==g[v][i]){
			continue;
		}
		if(color[g[v][i]]==0){
			visitedfrom[g[v][i]]=v;
			dfs(g[v][i]);
		} else if(color[g[v][i]]==1){
			cycleStart=g[v][i];
			cycleEnd=v;
		}
	}
	color[v]=2;
}

int bfs(int v){
	queue<pair<int, int>> q; // id, dist
	q.push(make_pair(v, 0));
	while(!q.empty()){
		int frontid=q.front().first;
		int frontdist=q.front().second;
		q.pop();
		if(incycle[frontid]){
			return frontdist;
		}
		for(int i=0; i<g[frontid].size(); ++i){
			q.push(make_pair(g[frontid][i], frontdist+1));
		}
	}
}

int main(){
	cin.sync_with_stdio(false);
	int n, a, b;
	cin>>n;
	for(int i=0; i<n; ++i){
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	dfs(1);

	queue<pair<int, int>> q;
	incycle[cycleStart]=true;
	visited[cycleStart]=true;
	for(int u=cycleEnd; u!=cycleStart; u=visitedfrom[u]){
		incycle[u]=true;
		q.push(make_pair(u, 0));
		visited[u]=true;
	}

	while(!q.empty()){
		int frontid=q.front().first;
		int frontdist=q.front().second;
		q.pop();
		visited[frontid]=true;

		res[frontid]=frontdist;
		for(size_t i=0; i<g[frontid].size(); ++i){
			if(!visited[g[frontid][i]]){
				q.push(make_pair(g[frontid][i], frontdist+1));
			}
		}

	}

	for(int i=1; i<=n; ++i){
		cout<<res[i]<<" ";
	}
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vint vector<ll>
#define pint pair<ll,ll>
#define vpint vector<pint>
#define pb push_back
#define all(v) v.begin(),v.end()
#define ios cin.sync_with_stdio(false),cin.tie(NULL)
#define f_(i,m,n) for(ll i=m;i<n;i++)
#define N 200005

vint adj[N];
//ll parent[N];
//ll rank[N];

ll bs;
ll ans_;

/*class MinHeap{
	ll *harr;
	ll capacity;
	ll heap_size;

public:

	MinHeap(ll capacity);

	ll parent(ll i){
		return (i-1)/2;
	}

	ll left(ll i){
		return (2*i+1);
	}

	ll right(ll i){
		return 2*i+2;
	}

	ll extractMin();

	void decreaseKey(ll i, ll val);

	ll get_min(){
		return harr[0];
	}

	void delete(ll i);

	void insert(ll val);
};

void MinHeap::insert(ll val){
	heap_size++;

	ll i= heap_size-1;
	harr[i]=val;

	while(i!=0 && harr[parent(i)]>harr[i]){
		swap(&harr[i] , &harr[parent(i)]);
		i= parent(i);
	}
}

void MinHeap::decreaseKey(ll i, ll val){

}*/

void dfs(vint adj[] , ll root, ll p, bool cycle[], ll ans[] ){

	for(auto it:adj[root]){
		if(it!=p && !cycle[it]){
			ans[it]= ans[root]+1;
			dfs(adj , it, root , cycle , ans);
		}
	}
}

bool find_path(ll root , ll p, vint adj[] , ll dest , bool cycle[] ){
	cycle[root]=true;

	if(root== dest){
		return true;
	}

	for(auto it: adj[root]){
		if(it!=p){
			if(find_path(it, root , adj, dest , cycle)){
				return true;
			}
		}
	}

	cycle[root]=false;
	return false;
}

bool check(ll root , ll itr, vint adj[] , bool cycle[] ){

	for(auto it:adj[root]){
		if(itr!=it){
			if(find_path(itr , root, adj , it , cycle)){
				cycle[root]=true;
				return true;
			}
		}
	}

	return false;
}

void solve(){
	ll n;
	cin>>n;

	vint adj[n+1];

	f_(i,1,n+1){
		ll a,b;
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	bool cycle[n+1];  // to store the nodes which are included in ringroad
	f_(i,1,n+1){
		cycle[i]=false;
	}

	ll ans[n+1];
	f_(i,1,n+1){
		ans[i]=0;
	}

	// find cycle nodes

	ll i1;
	ll i2;

	bool flag=false;

	for(ll i=1;i<n+1;i++){
		for(auto it:adj[i]){
			if(check(i, it , adj , cycle)){
				flag=true;
				break;
			}
		}

		if(flag){
			break;
		}
	}

	//find(adj , cycle , i, it);

	//queue<ll> q;

	f_(i,1,n+1){
		if(cycle[i]){
			dfs(adj , i, i, cycle , ans );
			//q.push(i);
		}
	}

	/*while(!q.empty()){
		ll a= q.front();
		q.pop();

		for(auto it:adj[a]){
			if(!cycle[it]){
				q.push(it);
				ans[it]= ans[a]+1;
				cycle[it]=true;
			}
		}
	}*/

	f_(i,1,n+1){
		cout<<ans[i]<<" ";
	}

	cout<<endl;
	return;

}

int main(){
	ios;
	ll t;
	t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vint vector<ll>
#define pint pair<ll,ll>
#define vpint vector<pint>
#define pb push_back
#define all(v) v.begin(),v.end()
#define ios cin.sync_with_stdio(false),cin.tie(NULL)
#define f_(i,m,n) for(ll i=m;i<n;i++)

void dfs(vint adj[] , ll root, ll p, bool cycle[], ll ans[] ){

	for(auto it:adj[root]){
		if(it!=p && !cycle[it]){
			ans[it]= ans[root]+1;
			dfs(adj , it, root , cycle , ans);
		}
	}
}

bool find_path(ll root , ll p, vint adj[] , ll dest , bool cycle[] ){
	cycle[root]=true;

	if(root== dest){
		return true;
	}

	for(auto it: adj[root]){
		if(it!=p){
			if(find_path(it, root , adj, dest , cycle)){
				return true;
			}
		}
	}

	cycle[root]=false;
	return false;
}

bool check(ll root , ll itr, vint adj[] , bool cycle[] ){

	for(auto it:adj[root]){
		if(itr!=it){
			if(find_path(itr , root, adj , it , cycle)){
				cycle[root]=true;
				return true;
			}
		}
	}

	return false;
}

void solve(){
	ll n;
	cin>>n;

	vint adj[n+1];

	f_(i,1,n+1){
		ll a,b;
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	bool cycle[n+1];  // to store the nodes which are included in ringroad
	f_(i,1,n+1){
		cycle[i]=false;
	}

	ll ans[n+1];
	f_(i,1,n+1){
		ans[i]=0;
	}

	// find cycle nodes

	ll i1;
	ll i2;

	bool flag=false;

	for(ll i=1;i<n+1;i++){
		for(auto it:adj[i]){
			if(check(i, it , adj , cycle)){
				flag=true;
				break;
			}
		}

		if(flag){
			break;
		}
	}

	//find(adj , cycle , i, it);

	//queue<ll> q;

	f_(i,1,n+1){
		if(cycle[i]){
			dfs(adj , i, i, cycle , ans );
			//q.push(i);
		}
	}

	/*while(!q.empty()){
		ll a= q.front();
		q.pop();

		for(auto it:adj[a]){
			if(!cycle[it]){
				q.push(it);
				ans[it]= ans[a]+1;
				cycle[it]=true;
			}
		}
	}*/

	f_(i,1,n+1){
		cout<<ans[i]<<" ";
	}

	cout<<endl;
	return;

}

int main(){
	ios;
	ll t;
	t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vint vector<ll>
#define pint pair<ll,ll>
#define vpint vector<pint>
#define pb push_back
#define all(v) v.begin(),v.end()
#define ios cin.sync_with_stdio(false),cin.tie(NULL)
#define f_(i,m,n) for(ll i=m;i<n;i++)
#define N 200005

vint adj[N];
//ll parent[N];
//ll rank[N];

ll bs;
ll ans_;

/*class MinHeap{
	ll *harr;
	ll capacity;
	ll heap_size;

public:

	MinHeap(ll capacity);

	ll parent(ll i){
		return (i-1)/2;
	}

	ll left(ll i){
		return (2*i+1);
	}

	ll right(ll i){
		return 2*i+2;
	}

	ll extractMin();

	void decreaseKey(ll i, ll val);

	ll get_min(){
		return harr[0];
	}

	void delete(ll i);

	void insert(ll val);
};

void MinHeap::insert(ll val){
	heap_size++;

	ll i= heap_size-1;
	harr[i]=val;

	while(i!=0 && harr[parent(i)]>harr[i]){
		swap(&harr[i] , &harr[parent(i)]);
		i= parent(i);
	}
}

void MinHeap::decreaseKey(ll i, ll val){

}*/

bool find_path(ll root , ll p, vint adj[] , ll dest , bool cycle[] ){
	cycle[root]=true;

	if(root== dest){
		return true;
	}

	for(auto it: adj[root]){
		if(it!=p){
			if(find_path(it, root , adj, dest , cycle)){
				return true;
			}
		}
	}

	cycle[root]=false;
	return false;
}

bool check(ll root , ll itr, vint adj[] , bool cycle[] ){

	for(auto it:adj[root]){
		if(itr!=it){
			if(find_path(itr , root, adj , it , cycle)){
				cycle[root]=true;
				return true;
			}
		}
	}

	return false;
}

void solve(){
	ll n;
	cin>>n;

	vint adj[n+1];

	f_(i,1,n+1){
		ll a,b;
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	bool cycle[n+1];  // to store the nodes which are included in ringroad
	f_(i,1,n+1){
		cycle[i]=false;
	}

	ll ans[n+1];
	f_(i,1,n+1){
		ans[i]=0;
	}

	// find cycle nodes

	ll i1;
	ll i2;
	bool flag=false;
	for(ll i=1;i<n+1;i++){
		for(auto it:adj[i]){
			if(check(i, it , adj , cycle)){
				flag=true;

				//cycle[i]=true;
				//cycle[it]=true;
				//i1=i;
				//i2=it;
				break;
			}
		}

		if(flag){
			break;
		}
	}

	//find(adj , cycle , i, it);

	queue<ll> q;

	f_(i,1,n+1){
		if(cycle[i]){
			//cout<<i<<" ";
			q.push(i);
		}
	}
	//cout<<endl;

	while(!q.empty()){
		ll a= q.front();
		q.pop();
		//cout<<a<<" this "<<endl;

		for(auto it:adj[a]){
			if(!cycle[it]){
				q.push(it);
				ans[it]= ans[a]+1;
				//cout<<it<<" "<<ans[it]<<endl;
				cycle[it]=true;
			}
		}
	}

	f_(i,1,n+1){
		cout<<ans[i]<<" ";
	}

	cout<<endl;
	return;

}

int main(){
	ios;
	ll t;
	t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
const int inf = 1000000007;

using namespace std;

int i, j, k, m, n, t, deg[3005], x[3005], q[3005], qi, qn, p[3005], ans[3005];

void get(int i) {
    if (ans[i] == -1) {
        get(p[i]);
        ans[i] = ans[p[i]]+1;
    }
}

int main()
{

    cin >> n;
    for (k = 0; k < n; k++) {
        cin >> i >> j;
        deg[i]++;
        deg[j]++;
        x[i] ^= j;
        x[j] ^= i;
    }
    for (i = 1; i <= n; i++)
        if (deg[i] == 1) q[qn++] = i;
    while (qi < qn) {
        i = q[qi++];
        ans[i] = -1;
        j = x[i];
        p[i] = j;
        x[j] ^= i;
        deg[j]--;
        if (deg[j] == 1) {
            q[qn++] = j;
        }
    }
    for (i = 1; i <= n; i++) {
        get(i);
        cout << ans[i] << " ";
    }
    return 0;
}


#include<iostream>
#include<vector>
using namespace std;
vector<int>road[3005];
int n,m;
int go[3005];
bool onr[3005];
int len[3005];
void dfs(int x,int p){
	if(onr[x])return;
	if(go[x]==1)onr[x]=1;
	go[x]++;
	for(int i=0;i<road[x].size();i++){
		if(road[x][i]==p)continue;
		dfs(road[x][i],x);
	}
	go[x]--;
}
void dfs2(int x,int l){
	if(len[x])return;
	len[x]=l;
	for(int i=0;i<road[x].size();i++){
		if(!onr[road[x][i]])
			dfs2(road[x][i],l+1);
	}
}
int main(){
	cin>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		n=max(n,max(x,y));
		road[x].push_back(y);
		road[y].push_back(x);
	}
	go[1]=-1;
	dfs(1,-1);
	for(int i=1;i<=n;i++){
		if(onr[i]){
			dfs2(i,0);
		}
	}
	for(int i=1;i<=n;i++){
		cout<<len[i]<<' ';
	}
}


#include<iostream>
#include<cstdio>
#include<cstring>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
const int N = 2e5 + 10;
int main(){
    char s[N],ans[N];
    int n[30];
    while(~scanf("%s",s)){
        mem(n,0);
        mem(ans,0);
        int len = strlen(s);
        for(int i=0;i<len;i++){
            n[s[i]-'a']++;
        }
        for(int i=0;i<26;i++)
            if(n[i]%2==1){
                for(int j=25;j>i;j--)
                    if(n[j]%2==1){
                        n[i]++;
                        n[j]--;
                    }
                break;
            }
        int l=0,r=len-1;
        if(len%2){
            for(int i=0;i<26;i++){
                if(n[i]%2==1){
                    while(n[i]>1){
                        ans[l++]=i+'a';
                        ans[r--]=i+'a';
                        n[i]-=2;
                    }
                    ans[len/2]=i+'a';
                }
                if(n[i]&&!(n[i]%2)){
                    while(n[i]){
                        ans[l++]=i+'a';
                        ans[r--]=i+'a';
                        n[i]-=2;
                    }
                }
            }
        }else{
            for(int i=0;i<26;i++){
                while(n[i]){
                    ans[l++]=i+'a';
                    ans[r--]=i+'a';
                    n[i]-=2;
                }
            }
        }
        ans[len]='\0';
        printf("%s\n",ans);
    }
}


#include<algorithm>
#include<deque>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int cct[30];
string s;
deque<char> a, b;
int main() {
    ios::sync_with_stdio(0);
    cin >> s;
    for (int i = 0;i < s.size();++i)
        ++cct[s[i] - 'a' + 1];
    vector<int> res;
    for (int i = 1;i <= 26;++i)
        if (cct[i] & 1)
            res.push_back(i);
    for (int i = 0;i < res.size();++i) {
        ++cct[res[i]];
        --cct[res[res.size() - i - 1]];
        res[res.size() - i - 1] = res[i];
    }
    for (int i = 1;i <= 26;++i) {
        int mid = (cct[i] >> 1);
        while (mid--) {
            a.push_back(i + 'a' - 1);
            b.push_front(i + 'a' - 1);
        }
    }
    for (int i = 0;i < a.size();++i)cout << a[i];
    if (res.size() & 1)cout << (char)(res[res.size() / 2] + 'a' - 1);
    for (int i = 0;i < b.size();++i)cout << b[i];
}


#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<cmath>
#include<string>
#include<cstring>
#include<iostream>
#include<iomanip>

using namespace std;
typedef long long ll;

#define MOD 1000000007

double dist(double x1,double y1,double x2,double y2){
	double dx = x1-x2;
	double dy = y1-y2;
	return sqrt(dx*dx+dy*dy);
}
int main(){
	string s;
	cin>>s;
	int n=s.size();
	int m=n/2;
	vector<int>cnt(26,0);
	for(int i=0;i<n;i++){
		cnt[s[i]-'a']++;
	}
	deque<int> od;
	for(int i=0;i<26;i++){
		if(cnt[i]&1){
			od.push_back(i);
		}
	}
	while(od.size()>1){
		int i=od.back();od.pop_back();
		int j=od.front();od.pop_front();
		// cnt[0]+=2;
		cnt[i]--;cnt[j]++;
	}
	int mid=-1;
	if(od.size()==1){
		mid=od[0];
	}
	string r,res;
	for(int i=0;i<26;i++){
		r.append(cnt[i]/2, i+'a');
	}
	if(mid>=0) r.append(1, mid+'a');
	for(int i=25;i>=0;i--){
		r.append(cnt[i]/2, i+'a');
	}
	cout<<r<<endl;
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

char s[200010];
int a[30];

int main() {
    scanf("%s", s);
    for (int i = 0; s[i]; i++)
        a[s[i] - 'a']++;

    int p = 0, q = 25;
    while (1) {
        while (p < q && a[p] % 2 == 0)
            p++;
        while (q > p && a[q] % 2 == 0)
            q--;
        if (a[p]) {
            a[p]++;
            a[q]--;
        }
        if (p >= q)
            break;
    }

    int len = strlen(s);
    int z = -1;
    if (len % 2) {
        for (int i = 0; i < 26; i++)
            if (a[i] % 2)
                z = i;
		a[z]--;
    }

    for (int i = 0; i < 26; i++)
        for (int j = 0; 2 * j < a[i]; j++)
            printf("%c", i + 'a');

    if (len % 2)
        printf("%c", 'a' + z);

    for (int i = 25; i >= 0; i--)
        for (int j = 0; 2 * j < a[i]; j++)
            printf("%c", i + 'a');
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007

char str[200002];
char odd[55];
int cnt[256];

int main() {
	scanf("%s", str);
	int n = strlen(str);
	REP(i, n)cnt[str[i]]++;
	int oc = 0;
	FOR(c, 'a', 'z' + 1)if (cnt[c] & 1)odd[oc++] = c;
	if (n & 1)str[n/2] = odd[oc / 2];
	REP(i, oc / 2) {
		cnt[odd[i]]++;
		cnt[odd[oc - 1 - i]]--;
	}
	int idx = 0;
	FOR(c, 'a', 'z' + 1) {
		REP(i, cnt[c] / 2) {
			str[idx] = str[n - 1 - idx] = c;
			idx++;
		}
	}
	printf("%s\n", str);
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007

char str[200002];
char odd[55];
int cnt[256];

int main() {
	scanf("%s", str);
	int n = strlen(str);
	REP(i, n)cnt[str[i]]++;
	int oc = 0;
	FOR(c, 'a', 'z' + 1)if(cnt[c] & 1)odd[oc++]=c;
	REP(i, oc / 2) {
		cnt[odd[i]]++;
		cnt[odd[oc-1-i]]--;
	}
	int idx = 0;
	FOR(c, 'a', 'z' + 1) {
		REP(i, (cnt[c]+1) / 2) {
			str[idx] = str[n - 1 - idx] = c;
			idx++;
		}
	}
	printf("%s\n", str);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <map>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
using namespace std;
int main()
{
#ifdef _DEBUG
    FILE* fin = freopen("in.txt","rt", stdin);
#endif
    char tmp[200010];
    memset(tmp, 0, sizeof(tmp));
    scanf("%s", tmp);
    string str = tmp;
    int cnt[26];
    memset(cnt, 0, sizeof(cnt));

    FOR(xx,0,str.size())
        cnt[str[xx] - 'a']++;

    int i = 0;
    int j = 25;

    while (i < j)
    {
        while(cnt[i] % 2 == 0)
            i++;
        while(cnt[j] % 2 == 0)
            j--;

        if (i >= j)
            break;

        cnt[i]++;
        cnt[j]--;
    }

    string ret(str.size(), ' ');
    int pos = 0;
    FOR(i,0,26)
    {
        FOR(j,0,cnt[i]/2)
        {
            int lastpos = pos + j;
            ret[lastpos] = 'a' + i;
            ret[str.length() -1 -lastpos] = 'a' + i;
        }
        pos += cnt[i]/2;
    }

    if (i == j)
        ret[str.size() / 2] = 'a' + i;

    printf("%s\n", ret.c_str());
#ifdef _DEBUG
    fclose(fin);
#endif
    return 0;
}


#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <map>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
using namespace std;
int main()
{
#ifdef _DEBUG
    FILE* fin = freopen("in.txt","rt", stdin);
#endif
    char tmp[200010] = {0,};
    scanf("%s", tmp);
    string str = tmp;
    int cnt[26];
    memset(cnt, 0, sizeof(cnt));

    FOR(i,0,str.size())
        cnt[str[i] - 'a']++;

    //int oddCnt = 0;
    //FOR(i,0,26)
    //  if (cnt[i] % 2 != 0)
    //      oddCnt++;

    //if (){}

    int i = 0;
    while(cnt[i] % 2 == 0)
        i++;

    int j = 25;
    while(cnt[j] % 2 == 0)
        j--;

    while (i < j)
    {
        while(cnt[i] % 2 == 0)
            i++;

        cnt[i]++;
        cnt[j]--;
        if (cnt[j] <= 1)
            j--;
    }

    string ret(str.size(), ' ');
    int pos = 0;
    FOR(i,0,26)
    {
        FOR(j,0,cnt[i]/2)
        {
            int lastpos = pos + j;
            ret[lastpos] = 'a' + i;
            ret[str.length() -1 -lastpos] = 'a' + i;
        }
        pos += cnt[i]/2;
        if (cnt[i] % 2 == 1)
            ret[pos++] = 'a' + i;
    }
    printf("%s\n", ret.c_str());
#ifdef _DEBUG
    fclose(fin);
#endif
    return 0;
}


#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <map>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
using namespace std;
int main()
{
#ifdef _DEBUG
    FILE* fin = freopen("in.txt","rt", stdin);
#endif
    char tmp[200010] = {0,};
    scanf("%s", tmp);
    string str = tmp;
    int cnt[26];
    memset(cnt, 0, sizeof(cnt));

    FOR(xx,0,str.size())
        cnt[str[xx] - 'a']++;

    //int oddCnt = 0;
    //FOR(i,0,26)
    //  if (cnt[i] % 2 != 0)
    //      oddCnt++;

    //if (){}

    int i = 0;
    while(cnt[i] % 2 == 0)
        i++;

    int j = 25;
    while(cnt[j] % 2 == 0)
        j--;

    while (i < j)
    {
        while(i < j && cnt[i] % 2 == 0)
            i++;

        cnt[i]++;
        cnt[j]--;
        if (cnt[j] <= 1)
            j--;
    }

    string ret(str.size(), ' ');
    int pos = 0;
    FOR(i,0,26)
    {
        FOR(j,0,cnt[i]/2)
        {
            int lastpos = pos + j;
            ret[lastpos] = 'a' + i;
            ret[str.length() -1 -lastpos] = 'a' + i;
        }
        pos += cnt[i]/2;
        if (cnt[i] % 2 == 1)
            ret[pos++] = 'a' + i;
    }
    printf("%s\n", ret.c_str());
#ifdef _DEBUG
    fclose(fin);
#endif
    return 0;
}


#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <map>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
using namespace std;
int main()
{
#ifdef _DEBUG
    FILE* fin = freopen("in.txt","rt", stdin);
#endif
    char tmp[200010] = {0,};
    scanf("%s", tmp);
    string str = tmp;
    int cnt[26];
    memset(cnt, 0, sizeof(cnt));

    FOR(xx,0,str.size())
        cnt[str[xx] - 'a']++;

    //int oddCnt = 0;
    //FOR(i,0,26)
    //  if (cnt[i] % 2 != 0)
    //      oddCnt++;

    //if (){}

    int i = 0;
    while(cnt[i] % 2 == 0)
        i++;

    int j = 25;
    while(cnt[j] % 2 == 0)
        j--;

    while (i < j)
    {
        while(i < j && cnt[i] % 2 == 0)
            i++;

        cnt[i]++;
        cnt[j]--;
        if (cnt[j] <= 1)
            j--;
    }

    int oddCnt = 0;
    FOR(i,0,26)
        if (cnt[i] % 2 == 1)
            oddCnt++;

    if (oddCnt > 1)
        printf("fail!!!\n");

    string ret(str.size(), ' ');
    int pos = 0;
    FOR(i,0,26)
    {
        FOR(j,0,cnt[i]/2)
        {
            int lastpos = pos + j;
            ret[lastpos] = 'a' + i;
            ret[str.length() -1 -lastpos] = 'a' + i;
        }
        pos += cnt[i]/2;
        if (cnt[i] % 2 == 1)
            ret[pos++] = 'a' + i;
    }
    printf("%s\n", ret.c_str());
#ifdef _DEBUG
    fclose(fin);
#endif
    return 0;
}


//////// Kelvin 2016
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <unordered_map>
#include <complex>
#include <ctime>
#include <fstream>
#include <sstream>
//#include <windows.h>
//#include <stdint.h>
using namespace std;
#define INF 0x3f3f3f3f
#define EPS 1e-9
const double PI = (acos(-1.0));
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
#define forn(i,s,n) i = (s); for( int _n = (int)(n), _di = (i > _n)?-1:1; i != _n; i += _di)
#define foreach(it,c) for ( auto it = (c).begin(); it!=(c).end(); it++)

int main()
{
	string s;
	cin>>s;
	int a[26];
	memset(a,0,26*4);
	int i, j;
	forn(i,0,s.size())
	{
		a[s[i]-'a']++;
	}
	for(i=0, j=25; i<j; i++)
	{
		if(a[i]&1)
		{
			while(j>0 && (a[j]&1) == 0)j--;
			if(i<j)
			{
				a[i]++;
				a[j]--;
			}
		}
	}

	s = "";
	forn(i,0,26)
	{
		forn(j,0,a[i]/2)
		{
			s += char(i+'a');
		}
	}
	forn(i,0,26)
	{
		if(a[i]&1)
		{
			s += char(i+'a');
		}
	}
	forn(i,25,-1)
	{
		forn(j,0,a[i]/2)
		{
			s += char(i+'a');
		}
	}

	cout<<s<<endl;
	return 0;
}


#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <set>
#include <cstring>
#include <map>
#include <bitset>
#include <random>
#include <stack>
#include <list>

using namespace std;

#define ll long long
#define sc second
#define fs first
#define mp make_pair
#define pb push_back

string s;
int n, c[30];

int main()
{
	cin >> s;
	n = s.size();
	memset(c, 0, sizeof(c));
	for (int i = 0; i < n; i++)
		c[s[i] - 'a']++;
	char add = ' ';
	for (int i = 0; i < 30; i++){
		if (c[i] % 2 == 1){
			for (int j = 30; j >= i; j--){
				if (j == i){
					add = j + 'a';
					break;
				}
				if (c[j] % 2 == 1){
					c[j]--, c[i]++;
					break;
				}
			}
		}
	}
	string res, end;
	for (int i = 0; i < 30; i++){
		for (int j = 0; j < c[i] / 2; j++)
			res += 'a' + i;
	}
	end = res;
	reverse(end.begin(), end.end());
	if (add != ' ')
		res += add;
	cout << res << end;
	return 0;
}


#include <iostream>
#include <vector>
#include <queue>
#include <math.h>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <string.h>
#include <iomanip>

#define For(i,a,b) for(int i = a;i<b;i++)
#define roF(i,b,a) for(int i = b;i>=a;i--)
#define trace(x) cout<<#x<<": "<<x<<endl;
#define allof(x) x.begin(),x.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;

int alph[30];

int main()
{
	char c;
	int cnt = 0;
	string s;
	cin>>s;
	For(i,0,s.size())
	{
		alph[s[i]-'a']++;
	}
	int beg = 0;
	int end = 25;

	while(1)
	{
		if(alph[beg]%2 == 0)
		{
			beg++;
			continue;
		}
		if(alph[end]%2 == 0)
		{
			end--;
			continue;
		}
		if(beg >= end) break;
		alph[end]--;
		alph[beg]++;
	}
	For(i,0,30)
	{
		For(j,0,alph[i]/2)
		{
			cout<<char('a' + i);
		}
	}
	if(s.size()%2 == 1)
	{
		cout<<char('a' + end);
	}
	roF(i,25,0)
	{
		For(j,0,alph[i]/2)
		{
			cout<<char('a' + i);
		}
	}
	cout<<endl;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <list>
#include <math.h>
#include <vector>
#include <set>
#include <cstring>
#include <vector>
#include <stdlib.h>
#include <string.h>
#include <ctime>
#include <random>
#include <stack>
#include <map>
#include <queue>

#define ll long long int
#define mp make_pair
#define endl '\n'

using namespace std;

ll INF = 1e10, n, m, k, sum, c[100100],x,y,z, mx,mn=INF, ans,l, ind;
bool marked[100100], station[110],  b[1010][1010];
double M_PI = 3.1415926535897932384626433832795;
string ansstr;
char a[200100];

struct chis
{
    ll n, place;
    bool t;
}ch[200100];

bool cmp(chis x, chis y)
{
    if(x.n>y.n)
    {
        bool swp = x.t;
        x.t = y.t;
        y.t = swp;
        ll swp1 = x.place;
        x.place = y.place;
        y.place = swp1;
    }
    return x.n < y.n;
}

int main()
{
    //freopen("parade.in", "r",stdin);
    //freopen("parade.txt", "w",stdout);
    string str, str1="";
    cin >> str;
    n = str.length();
    for(int i = 0; i < n; i++)
    {
        a[i] = str[i];
    }
    sort(a,a+str.length());
    for(int i = 0; i < n; i++)
    {
        if(i==n-1)
        {
            sum++;
            break;
        }
        if(a[i]==a[i+1])
        {
            i++;
        }
        else
        {
            sum++;
        }
    }
    bool t = false;
    if(n%2!=0)
        t = true;
    char c = '!';
    for(int i = 0; i < n; i++)
    {
        if(i==n-1)
        {
            if(ind < sum/2)
                str1+=a[i];
            else
                if(t)
                {
                    c = a[i];
                    t = false;
                }
            break;
        }
        if(a[i]==a[i+1])
        {
            i++;
            str1+=a[i];
        }
        else
        {
            if(ind < sum/2)
            {
                str1+=a[i];
                ind++;
            }
            else
                if(t)
                {
                    c = a[i];
                    t = false;
                }
        }
    }
    cout << str1;
    if(c!='!')
        cout << c;
    for(int i = n/2-1; i >= 0; i--)
    {
        cout << str1[i];
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <list>
#include <math.h>
#include <vector>
#include <set>
#include <cstring>
#include <vector>
#include <stdlib.h>
#include <string.h>
#include <ctime>
#include <random>
#include <stack>
#include <map>
#include <queue>

#define ll long long int
#define mp make_pair
#define endl '\n'

using namespace std;

ll INF = 1e10, n, m, k, sum, c[100100],x,y,z, mx,mn=INF, ans,l, ind;
bool marked[100100], station[110],  b[1010][1010];
double M_PI = 3.1415926535897932384626433832795;
string ansstr;
char a[200100];

struct chis
{
    ll n, place;
    bool t;
}ch[200100];

bool cmp(chis x, chis y)
{
    if(x.n>y.n)
    {
        bool swp = x.t;
        x.t = y.t;
        y.t = swp;
        ll swp1 = x.place;
        x.place = y.place;
        y.place = swp1;
    }
    return x.n < y.n;
}

int main()
{
    //freopen("parade.in", "r",stdin);
    //freopen("parade.txt", "w",stdout);
    string str, str1="";
    cin >> str;
    n = str.length();
    for(int i = 0; i < n; i++)
    {
        a[i] = str[i];
    }
    sort(a,a+str.length());
    for(int i = 0; i < n; i++)
    {
        if(i==n-1)
        {
            sum++;
            break;
        }
        if(a[i]==a[i+1])
        {
            i++;
        }
        else
        {
            sum++;
        }
    }
    if(sum%2!=0)
        sum++;
    for(int i = 0; i < n; i++)
    {
        if(i==n-1)
        {
            if(ind < sum/2)
                str1+=a[i];
            break;
        }
        if(a[i]==a[i+1])
        {
            i++;
            str1+=a[i];
        }
        else
        {
            if(ind < sum/2)
            {
                str1+=a[i];
                ind++;
            }
        }
    }
    cout << str1;
    for(int i = n/2-1; i >= 0; i--)
    {
        cout << str1[i];
    }
    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<climits>
using namespace std;
char s[200005];
int cnt[26];
int main(){
    scanf("%s", s);
    int L = (int) strlen(s);
    for (int i=0; i<L; i++) cnt[s[i]-97]++;
    int odd = 0;
    for (int i=0; i<26; i++)
        if (cnt[i]%2 == 1)
            odd++;
    int u = 0, v = 25;
    while (odd > 1){
        while (cnt[v]%2 == 0) v--;
        while (cnt[u]%2 == 0) u++;
        cnt[v]--; cnt[u]++;
        odd -=2;
    }
    for (int i=0; i<26; i++)
        for (int j=0; j<cnt[i]/2; j++)
            printf("%c", i+97);
    for (int i=0; i<26; i++)
        if (cnt[i]%2 == 1)
            printf("%c", i+97);
    for (int i=25; i>=0; i--)
        for (int j=0; j<cnt[i]/2; j++)
            printf("%c", i+97);
    printf("\n");
    return 0;
}


#include "iostream"
#include "string"
using namespace std;
string s;
int ch[26], c[26];
int main()
{
	int num=0;
	cin >> s;
	for (int i = 0; i < s.length(); i++)
		ch[s[i] - 'a']++;
	for (int i = 0; i < 26; i++)
		if (ch[i] % 2)
			c[num++] = i;
	for (int i = 0, j = num-1; i < j; i++, j--)
		ch[c[j]]--, ch[c[i]]++;
	if (num%2)
		s[s.length() / 2] = c[num / 2] + 'a';
	for (int i = 0, j = s.length()-1, k = 0; i < j; i++, j--)
		for (; k < 26; k++)
			if (ch[k] > 1)
			{
				ch[k] =ch[k]- 2;
				s[i] = s[j] = k + 'a';
				break;
			}
	cout << s << endl;
	return 0;
}


#include "iostream"
#include "string"
using namespace std;
string s;
int ch[26], c[26];
int main()
{
	int num=0;
	cin >> s;
	for (int i = 0; i < s.length(); i++)
		ch[s[i] - 'a']++;
	for (int i = 0; i < 26; i++)
		if (ch[i] % 2)
			c[num++] = i;
	for (int i = 0, j = num-1; i < j; i++, j--)
		ch[c[j]]--, ch[c[i]]++;
	if (num%2)
		s[s.length() / 2+1] = c[num / 2+1] + 'a';
	for (int i = 0, j = s.length()-1, k = 0; i <= j; i++, j--)
		for (; k < 26; k++)
			if (ch[k] > 1)
			{
				ch[k] =ch[k]- 2;
				s[i] = s[j] = k + 'a';
				break;
			}
	cout << s << endl;
	return 0;
}


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

using namespace std;

int main()
{
    string s; cin >> s;
    int cc[26] = {};
    bool o[26] = {};
    int oc = 0;
    for (int i = 0; i < s.size(); i++)
    {
        cc[s[i] - 'a']++;
    }
    for (int i = 0; i < 26; i++)
    {
        if (cc[i] % 2 != 0)
            o[i] = true, oc++;
    }
    while (oc > 1)
    {
        int i, j;
        for (i = 0; i < 26; i++)
            if (o[i]) break;
        for (j = 25; j > 0; j--)
            if (o[j]) break;
        cc[i]++; cc[j]--;
        o[i] = o[j] = false; oc -= 2;
    }
    int oi = -1, ci = 0;
    for (int i = 0; i < 26; i++)
    {
        if (o[i]) oi = i;
        else
        {
            for (int k = 0; k < cc[i]; k+=2)
            {
                s[ci] = 'a' + i;
                s[s.size() - ci - 1] = 'a' + i;
                ci++;
            }
        }
    }
    if (oi != -1)
    {
        s[ci] = 'a' + oi;
    }
    cout << s;

    return 0;
}


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

using namespace std;

int main()
{
    string s; cin >> s;
    int cc[26] = {};
    bool o[26] = {};
    int oc = 0;
    for (int i = 0; i < s.size(); i++)
    {
        cc[s[i] - 'a']++;
    }
    for (int i = 0; i < 26; i++)
    {
        if (cc[i] % 2 != 0)
            o[i] = true, oc++;
    }
    while (oc > 1)
    {
        int i, j;
        for (i = 0; i < 26; i++)
            if (o[i]) break;
        for (j = 25; j > 0; j--)
            if (o[j]) break;
        cc[i]++; cc[j]--;
        o[i] = o[j] = false; oc -= 2;
    }
    int oi = -1, ci = 0;
    for (int i = 0; i < 26; i++)
    {
        if (o[i]) oi = i;
            for (int k = 2; k <= cc[i]; k+=2)
            {
                s[ci] = 'a' + i;
                s[s.size() - ci - 1] = 'a' + i;
                ci++;
            }
    }
    if (oi != -1)
    {
        s[ci] = 'a' + oi;
    }
    cout << s;

    return 0;
}


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

using namespace std;

int main()
{
    string s; cin >> s;
    int cc[26] = {};
    bool o[26] = {};
    int oc = 0;
    for (int i = 0; i < s.size(); i++)
    {
        cc[s[i] - 'a']++;
    }
    for (int i = 0; i < 26; i++)
    {
        if (cc[i] % 2 != 0)
            o[i] = true, oc++;
    }
    while (oc > 1)
    {
        int i, j;
        for (i = 0; i < 26; i++)
            if (o[i]) break;
        for (j = 25; j > 0; j--)
            if (o[j]) break;
        cc[i]++; cc[j]--;
        o[i] = o[j] = false; oc -= 2;
    }
    int oi = -1, ci = 0;
    for (int i = 0; i < 26; i++)
    {
        if (o[i]) oi = i;
        else
        {
            for (int k = 2; k <= cc[i]; k+=2)
            {
                s[ci] = 'a' + i;
                s[s.size() - ci - 1] = 'a' + i;
                ci++;
            }
        }
    }
    if (oi != -1)
    {
        s[ci] = 'a' + oi;
    }
    cout << s;

    return 0;
}


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

using namespace std;

int main()
{
    string s; cin >> s;
    int cc[26] = {};
    bool o[26] = {};
    int oc = 0;
    for (int i = 0; i < s.size(); i++)
    {
        cc[s[i] - 'a']++;
    }
    for (int i = 0; i < 26; i++)
    {
        if (cc[i] % 2 != 0)
            o[i] = true, oc++;
    }
    while (oc > 1)
    {
        int i, j;
        for (i = 0; i < 26; i++)
            if (o[i]) break;
        for (j = 25; j > 0; j--)
            if (o[j]) break;
        cc[i]++; cc[j]--;
        o[i] = o[j] = false; oc -= 2;
    }
    int oi = -1, ci = 0;
    for (int i = 0; i < 26; i++)
    {
        if (o[i] == 1) oi = i;
        else
        {
            for (int k = 2; k < cc[i]; k+=2)
            {
                s[ci] = 'a' + i;
                s[s.size() - ci - 1] = 'a' + i;
                ci++;
            }
        }
    }
    if (oi != -1)
    {
        s[ci] = 'a' + oi;
    }
    cout << s;

    return 0;
}


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

using namespace std;

int main()
{
    string s; cin >> s;
    int cc[26] = {};
    bool o[26] = {};
    int oc = 0;
    for (int i = 0; i < s.size(); i++)
    {
        cc[s[i] - 'a']++;
    }
    for (int i = 0; i < 26; i++)
    {
        if (cc[i] % 2 != 0)
            o[i] = true, oc++;
    }
    while (oc > 1)
    {
        int i, j;
        for (i = 0; i < 26; i++)
            if (o[i]) break;
        for (j = 25; j > 0; j--)
            if (o[j]) break;
        cc[i]++; cc[j]--;
        o[i] = o[j] = false; oc -= 2;
    }
    int oi = -1, ci = 0;
    for (int i = 0; i < 26; i++)
    {
        if (o[i]) oi = i;
        else
        {
            for (int k = 2; k < cc[i]; k+=2)
            {
                s[ci] = 'a' + i;
                s[s.size() - ci - 1] = 'a' + i;
                ci++;
            }
        }
    }
    if (oi != -1)
    {
        s[ci] = 'a' + oi;
    }
    cout << s;

    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<string>
#include<set>
#include<algorithm>
typedef long long ll;
using namespace std;
map <char, int> mp;
int main()
{
	/*freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);*/
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
		mp[s[i]]++;
	if (s.size() % 2 == 0)
	{
		bool fl = false;//false without pair
		char ch;//pair
		auto it2 = mp.end();
		auto it = mp.begin();
		it2--;
		for (; it != it2;)
		{
			if (fl)
			{
				if (it2->second % 2 == 1)
				{
					fl = false;
					mp[ch]++;
					it2->second--;
				}
				it2--;
			}
			else
			{
				if (it->second % 2 == 1)
				{
					fl = true;
					ch = it->first;
				}
				it++;
			}
		}
		if (fl)
		{
			if (it2->second % 2 == 1)
			{
				fl = false;
				mp[ch]++;
				it2->second--;
			}
			it2--;
		}
		else
		{
			if (it->second % 2 == 1)
			{
				fl = true;
				ch = it->first;
			}
			it++;
		}
		string ans;
		for (auto it = mp.begin(); it != mp.end(); it++)
		{
			for (int i = 0; i < (*it).second / 2; i++)
				ans.push_back((*it).first);
		}
		cout << ans;
		reverse(ans.begin(), ans.end());
		cout << ans;
	}
	else
	{
		bool fl = false;//false without pair
		char ch;//pair
		char id;
		int p = 0;
		for (auto it = mp.begin(); it != mp.end(); it++)
		{
			if ((*it).second % 2 != 0)
			{
				p++;
			}
		}
		int t = 0;
		for (auto it = mp.begin(); it != mp.end(); it++)
		{
			if ((*it).second % 2 != 0)
			{
				t++;
				if (t == (p + 1) / 2)
				{
					id = it->first;
					break;
				}
			}
		}
		mp[id]--;
		auto it2 = mp.end();
		auto it = mp.begin();
		it2--;
		for (; it != it2;)
		{
			if (fl)
			{
				if (it2->second % 2 == 1)
				{
					fl = false;
					mp[ch]++;
					it2->second--;
				}
				it2--;
			}
			else
			{
				if (it->second % 2 == 1)
				{
					fl = true;
					ch = it->first;
				}
				it++;
			}
		}
		if (fl)
		{
			if (it2->second % 2 == 1)
			{
				fl = false;
				mp[ch]++;
				it2->second--;
			}
			it2--;
		}
		else
		{
			if (it->second % 2 == 1)
			{
				fl = true;
				ch = it->first;
			}
			it++;
		}
		string ans;
		for (auto it = mp.begin(); it != mp.end(); it++)
		{
			for (int i = 0; i < (*it).second / 2; i++)
				ans.push_back((*it).first);
		}
		cout << ans << id;
		reverse(ans.begin(), ans.end());
		cout << ans;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int ap[30] = { 0, };

int main() {
	string k;
	cin >> k;
	for (int i = 0; i < k.size(); i++)
		ap[k[i] - 'a']++;

	vector<int> v;
	for (int i = 0; i <= 'z' - 'a'; i++) {
		if (ap[i] % 2 == 1)
			v.push_back(i);
	}

	if (v.size() % 2 == 0) {
		string t;
		for (int i = 0; i < v.size() / 2; i++) {
			ap[v[i]]++;
			ap[v[v.size() - i - 1]]--;
		}
		for (int i = 0; i <= 'z' - 'a'; i++) {
			for (int j = 0; j < ap[i] / 2; j++) {
				t.push_back('a' + i);
			}
		}
		cout << t;
		reverse(t.begin(), t.end());
		cout << t;
	}
	else {
		string t;
		for (int i = 0; i < v.size() / 2; i++) {
			ap[v[i]]++;
			ap[v[v.size() - i - 1]]--;
		}
		int that = v[v.size() / 2];
		ap[v[v.size() / 2]]--;
		for (int i = 0; i <= 'z' - 'a'; i++) {
			for (int j = 0; j < ap[i] / 2; j++) {
				t.push_back('a' + i);
			}
		}
		cout << t;
		cout << char('a' + that);
		reverse(t.begin(), t.end());
		cout << t;
	}

}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int ap[30] = { 0, };

int main() {
	string k;
	cin >> k;
	for (int i = 0; i < k.size(); i++)
		ap[k[i] - 'a']++;

	vector<int> v;
	for (int i = 0; i <= 'z' - 'a'; i++) {
		if (ap[i] % 2 == 1)
			v.push_back(i);
	}

	if (v.size() % 2 == 0) {
		string t;
		for (int i = 0; i < v.size() / 2; i++) {
			ap[v[i]]++;
			ap[v[v.size() - i - 1]]--;
		}
		for (int i = 0; i <= 'z' - 'a'; i++) {
			for (int j = 0; j < ap[i] / 2; j++) {
				t.push_back('a' + i);
			}
		}
		cout << t;
		reverse(t.begin(), t.end());
		cout << t;
	}
	else {
		string t;
		for (int i = 0; i < v.size() / 2; i++) {
			ap[v[i]]++;
			ap[v[v.size() - i - 1]]--;
		}
		int that = v[v.size() / 2];
		ap[v[v.size() / 2 + 1]]--;
		for (int i = 0; i <= 'z' - 'a'; i++) {
			for (int j = 0; j < ap[i] / 2; j++) {
				t.push_back('a' + i);
			}
		}
		cout << t;
		cout << char('a' + that);
		reverse(t.begin(), t.end());
		cout << t;
	}

}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int ap[30] = { 0, };

int main() {
	string k;
	cin >> k;
	for (int i = 0; i < k.size(); i++)
		ap[k[i] - 'a']++;

	vector<int> v;
	for (int i = 0; i <= 'z' - 'a'; i++) {
		if (ap[i] % 2 == 1)
			v.push_back(i);
	}
	if (v.size() == 2) {
		string t;
		ap[v[1]]--;
		ap[v[0]]++;
		for (int i = 0; i <= 'z' - 'a'; i++) {
			for (int j = 0; j < ap[i] / 2; j++) {
				t.push_back('a' + i);
			}
		}
		cout << t;
		reverse(t.begin(), t.end());
		cout << t;
	}
	if (v.size() == 3) {
		string t;
		ap[v[2]]--;
		ap[v[0]]++;
		ap[v[1]] = 0;
		for (int i = 0; i <= 'z' - 'a'; i++) {
			for (int j = 0; j < ap[i] / 2; j++) {
				t.push_back('a' + i);
			}
		}
		cout << t;
		cout << char('a' + v[1]);
		reverse(t.begin(), t.end());
		cout << t;
	}

}


//#include "functions.h"

//#include "geo.h"
#include<iostream>
#include<fstream>
#include<vector>
#include<list>
#include<algorithm>
#include<string>
#include <cstdint>
#include<memory>
#include<cmath>
#include<queue>
#include<deque>
#include<stack>
#include<numeric>
#include<ctime>
#include<set>
#include<map>
#include<sstream>
#include<bitset>

//#include"functions.h"

using namespace std;

typedef unsigned long long ll;
typedef unsigned int uint;
typedef pair<int, int> ii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long double, int> di;

#define INF 1e9
#define EPS 1e-9
#define MOD 1000000007

#define REP(i,n) for(int i=0; i < n; i++)
#define REPR(i,x,y) for(int i = x; i < y; i++)
#define CINVEC(n, arr) REP(k,n) cin >> arr[k];
#define eqd(x,y) (fabs(x-y) < EPS)

#define pback push_back
#define F first
#define S second
#define mp make_pair

vi pset[3]; // remember: vi is vector<int>
void initSet(int N, int ind) { pset[ind].assign(N, 0);
for (int i = 0; i < N; i++) pset[ind][i] = i; }
int findSet(int i, int ind) { return (pset[ind][i] == i) ? i : (pset[ind][i] = findSet(pset[ind][i],ind)); }
bool isSameSet(int i, int j, int ind) { return findSet(i, ind) == findSet(j, ind); }
void unionSet(int i, int j, int ind) { pset[ind][findSet(i,ind)] = findSet(j,ind); }

#define NUM 4100

#define SIZE 100
#define ERR 1e6
#define RND 0.0089
#define RND2 19.572

int main()
{
    string s;

    cin >> s;

    vi freq(26,0);

    for(int i = 0; i < s.size(); i++)
        freq[(s[i]-'a') ]++;

    int lasti = -1;
    int left = 0;
    int right = 25;
    while(left < right)
    {
        if((freq[left] % 2) == 0)
        {
            left++;
            continue;
        }
        if((freq[right] % 2) == 0)
        {
            right--;
            continue;
        }

        freq[left]++;
        freq[right]--;
        left++;
        right--;
    }

    if(s.size() % 2 == 0)
    {
        for(int i = 0; i < 26; i++)
            for(int j = 0; j < freq[i]/2; j++)
                cout << (char)('a'+(char)i);
        for(int i = 25; i >= 0; i--)
            for(int j = 0; j < freq[i]/2; j++)
                cout << (char)('a'+(char)i);

    }
    else
    {

        for(int i = 0; i < 26; i++)
            for(int j = 0; j < freq[i]/2; j++)
                cout << (char)('a'+(char)i);

        cout << (char)('a'+(char)left);
        for(int i = 25; i >= 0; i--)
            for(int j = 0; j < freq[i]/2; j++)
                cout << (char)('a'+(char)i);

    }
    cin.get();
    cin.get();

}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <cstring>
#include <fstream>
#define ll long long int
using namespace std;
int ar[30];
int main()
{
   //freopen("in.txt", "r", stdin);
   string s;
   getline(cin, s);
   for(int i = 0; i < s.size(); i++) ar[s[i] - 'a']++;
   int l = 0;
   int r = 29;
   while(l < r)
   {
	   while(ar[l]%2 == 0 && l <= 29) l++;
	   while(ar[r]%2 == 0 && r >= 0) r--;
	   if(l < r)
	   {
		   ar[l]++;
		   ar[r]--;
	   }
   }
   char c = -1;
   string res;
   for(int i = 0; i < 30; i++)
   {
	   if(ar[i] != 0)
	   {
		   for(int j = 0; j < ar[i] / 2; j++) res.push_back('a'+i);
		   if(ar[i] % 2 != 0) c = 'a'+i;
	   }
   }
   if(c != -1) res.push_back(c);
   for(int i = 30; i >= 0; i--)
   {
	   if(ar[i] != 0)
	   {
		   for(int j = 0; j < ar[i] / 2; j++) res.push_back('a'+i);
	   }
   }
   printf("%s\n", res.c_str());
   return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <cstring>
#include <fstream>
#define ll long long int
using namespace std;
int ar[30];
int main()
{
   //freopen("in.txt", "r", stdin);
   string s;
   getline(cin, s);
   for(int i = 0; i < s.size(); i++) ar[s[i] - 'a']++;
   int l = 0;
   int r = 29;
   while(l < r)
   {
	   while(ar[l]%2 == 0 && l <= 29) l++;
	   while(ar[r]%2 == 0 && r >= 0) r--;
	   if(l < r)
	   {
		   ar[l]++;
		   ar[r]--;
	   }
   }
   char c = -1;
   for(int i = 0; i < 30; i++)
   {
	   if(ar[i] != 0)
	   {
		   for(int j = 0; j < ar[i] / 2; j++) printf("%c", 'a'+i);
		   if(ar[i] % 2 != 0) c = 'a'+i;
	   }
   }
   if(c != -1) printf("%c", c);
   for(int i = 30; i >= 0; i--)
   {
	   if(ar[i] != 0)
	   {
		   for(int j = 0; j < ar[i] / 2; j++) printf("%c", 'a'+i);
	   }
   }
   printf("\n");
   return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <cstring>
#include <fstream>
#define ll long long int
using namespace std;
int ar[30];
int main()
{
   //freopen("in.txt", "r", stdin);
   string s;
   //getline(cin, s);
   while(true)
   {
	   char c;
	   scanf("%c", &c);
	   if(c < 'a' || c > 'z') break;
	   s.push_back(c);
   }
   for(int i = 0; i < s.size(); i++) ar[s[i] - 'a']++;
   int l = 0;
   int r = 29;
   while(l < r)
   {
	   while(ar[l]%2 == 0 && l <= 29) l++;
	   while(ar[r]%2 == 0 && r >= 0) r--;
	   if(l < r)
	   {
		   ar[l]++;
		   ar[r]--;
	   }
   }
   char c = -1;
   string res;
   for(int i = 0; i < 30; i++)
   {
	   if(ar[i] != 0)
	   {
		   char c2 = 'a' + char(i);
		   for(int j = 0; j < ar[i] / 2; j++) res.push_back(c2);
		   if(ar[i] % 2 != 0) c = c2;
	   }
   }
   if(c != -1) res.push_back(c);
   for(int i = 30; i >= 0; i--)
   {
	   if(ar[i] != 0)
	   {
		   char c2 = 'a' + char(i);
		   for(int j = 0; j < ar[i] / 2; j++) res.push_back(c2);
	   }
   }
   printf("%s\n", res.c_str());
   return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <cstring>
#include <fstream>
#define ll long long int
using namespace std;
int ar[30];
int main()
{
   //freopen("in.txt", "r", stdin);
   string s;
   getline(cin, s);
   for(int i = 0; i < s.size(); i++) ar[s[i] - 'a']++;
   int l = 0;
   int r = 29;
   while(l < r)
   {
	   while(ar[l]%2 == 0 && l <= 29) l++;
	   while(ar[r]%2 == 0 && r >= 0) r--;
	   if(l < r)
	   {
		   ar[l]++;
		   ar[r]--;
	   }
   }
   char c = -1;
   string res;
   for(int i = 0; i < 30; i++)
   {
	   if(ar[i] != 0)
	   {
		   char c2 = 'a' + char(i);
		   for(int j = 0; j < ar[i] / 2; j++) res.push_back(c2);
		   if(ar[i] % 2 != 0) c = c2;
	   }
   }
   if(c != -1) res.push_back(c);
   for(int i = 30; i >= 0; i--)
   {
	   if(ar[i] != 0)
	   {
		   char c2 = 'a' + char(i);
		   for(int j = 0; j < ar[i] / 2; j++) res.push_back(c2);
	   }
   }
   printf("%s\n", res.c_str());
   return 0;
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <string>
#include <locale>
#include <algorithm>
#include <math.h>

# define M_PI           3.1415926535897932384626433832795  /* pi */

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef vector<pi> vp;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s;
    cin >> s;

    vi ch(26, 0);

    for (int i = 0; i < s.size(); i++)
    {
        ch[s[i] - 'a']++;
    }

    int j = 25;
    for (int i = 0; i < 26; i++)
    {
        if (ch[i] % 2)
        {
            while (ch[j] % 2 == 0)
                j--;

            ch[i]++;
            ch[j]--;
        }
    }

    string res;
    int c = 0;
    for (int i = 0; i < s.size()/2;)
    {
        int am = ch[c] / 2;
        for (int j = 0; j < am; j++)
            res += (char)(c + 'a');

        i += am;
        c++;
    }

    char center;
    if (s.size() % 2)
        for (int i = 0; i < 25; i++)
            if (ch[i] % 2)
                center = i + 'a';

    cout << res;
    if (s.size() % 2)
        cout << center;
    reverse(res.begin(), res.end());
    cout << res << endl;

    return 0;
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <string>
#include <locale>
#include <algorithm>
#include <math.h>

# define M_PI           3.1415926535897932384626433832795  /* pi */

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef vector<pi> vp;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s;
    cin >> s;

    vi ch(26, 0);

    for (int i = 0; i < s.size(); i++)
    {
        ch[s[i] - 'a']++;
    }

    int j = 25;
    for (int i = 0; i < 26; i++)
    {
        if (ch[i] % 2)
        {
            while (ch[j] % 2 == 0)
                j--;

            ch[i]++;
            ch[j]--;
        }
    }

    string res;
    int c = 0;
    char center = '0';
    for (int i = 0; i < s.size()/2;)
    {
        if (ch[c] % 2)
            center = c + 'a';

        int am = ch[c] / 2;
        for (int j = 0; j < am; j++)
            res += (char)(c + 'a');

        i += am;
        c++;
    }
    if (center == '0')
        center = c + 'a';

    cout << res;
    if (s.size() % 2)
        cout << center;
    reverse(res.begin(), res.end());
    cout << res << endl;

    return 0;
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <string>
#include <locale>
#include <algorithm>
#include <math.h>

# define M_PI           3.1415926535897932384626433832795  /* pi */

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef vector<pi> vp;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s;
    cin >> s;

    vi ch(26, 0);

    for (int i = 0; i < s.size(); i++)
    {
        ch[s[i] - 'a']++;
    }

    int j = 25;
    for (int i = 0; i < 26; i++)
    {
        if (ch[i] % 2)
        {
            while (ch[j] % 2 == 0)
                j--;

            ch[i]++;
            ch[j]--;
        }
    }

    string res;
    int c = 0;
    char center;
    for (int i = 0; i < s.size()/2;)
    {
        if (ch[c] % 2)
            center = c + 'a';

        int am = ch[c] / 2;
        for (int j = 0; j < am; j++)
            res += (char)(c + 'a');

        i += am;
        c++;
    }

    cout << res;
    if (s.size() % 2)
        cout << center;
    reverse(res.begin(), res.end());
    cout << res << endl;

    return 0;
}


#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
const int MAX_ALPHA = 30;

int a[MAX_ALPHA];

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string s;
	getline(cin, s);
	int n = (int)s.length();
	for (int i = 0; i < n; i++)
		a[s[i] - 'a']++;

	int p = -1;
	for (int i = 0; i < MAX_ALPHA; i++)
		if (a[i] % 2 != 0)
		{
			int j = MAX_ALPHA - 1;
			while (j >= i && a[j] % 2 == 0)
				j--;
			if (i != j)
			{
				a[i]++;
				a[j]--;
			}
			else p = i;
		}

	for (int i = 0; i < MAX_ALPHA; i++)
		for (int j = 0; j < a[i] / 2; j++)
			cout << (char)(i + 'a');
	if (p != -1)
		cout << (char)(p + 'a');
	for (int i = MAX_ALPHA - 1; i >= 0; i--)
		for (int j = 0; j < a[i] / 2; j++)
			cout << (char)(i + 'a');
	return 0;
}


#include <string>
#include <iostream>
#include <vector>
using namespace std;

int main()
{
	string s;
	cin >> s;

	int count[26];
	for (int i = 0; i < 26; i++) count[i] = 0;
	for (int i = 0; i < s.length(); i++)
	{
		count[s[i] - 'a']++;
	}

	vector<int> oddIndexList;
	for (int i = 0; i < 26; i++)
	{
		if (count[i] % 2 == 1) oddIndexList.push_back(i);
	}

	int lastCharIndex = -1;
	if (oddIndexList.size() > 1)
	{
		int i = 0;
		int j = oddIndexList.size() - 1;
		for (; i < j; i++, j--)
		{
			int increaseIndex = oddIndexList[i];
			int decreaseIndex = oddIndexList[j];

			count[increaseIndex]++;
			count[decreaseIndex]--;
		}

		if (i == j) lastCharIndex = oddIndexList[i];
	}
	else if (oddIndexList.size() == 1)
	{
		lastCharIndex = oddIndexList[0];
	}

	string ans(s.c_str());
	int index = 0;
	for (int i = 0; i < 26; i++)
	{
			for (int j = 0; j < count[i] / 2; j++)
			{
				char ch = (char)('a' + i);
				ans[index] = ch;
				ans[s.length() - 1 - index] = ch;
				index++;
			}
	}

	if (lastCharIndex >= 0) ans[index++] = (char)('a' + lastCharIndex);

	cout << ans << endl;

	return 0;
}


#include <string>
#include <iostream>
#include <vector>
using namespace std;

int main()
{
	string s;
	cin >> s;

	int count[26];
	for (int i = 0; i < 26; i++) count[i] = 0;
	for (int i = 0; i < s.length(); i++)
	{
		count[s[i] - 'a']++;
	}

	vector<int> oddIndexList;
	for (int i = 0; i < 26; i++) if (count[i] % 2 == 1) oddIndexList.push_back(i);

	int lastCharIndex = -1;
	if (oddIndexList.size() > 1)
	{
		int i = 0;
		int j = oddIndexList.size() - 1;
		for (; i < j; i++, j--)
		{
			int increaseIndex = oddIndexList[i];
			int decreaseIndex = oddIndexList[j];

			count[increaseIndex]++;
			count[decreaseIndex]--;
		}

		if (i == j) lastCharIndex = oddIndexList[i];
	}
	else if (oddIndexList.size() == 1)
	{
		lastCharIndex = oddIndexList[0];
	}

	string ans(s.c_str());
	int index = 0;
	for (int i = 0; i < 26; i++)
	{
		if (count[i] > 0 && count[i] % 2 == 0)
		{
			for (int j = 0; j < count[i] / 2; j++)
			{
				char ch = (char)('a' + i);
				ans[index] = ch;
				ans[s.length() - 1 - index] = ch;
				index++;
			}
		}
	}

	if (lastCharIndex >= 0) ans[index++] = (char)('a' + lastCharIndex);

	cout << ans << endl;

	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>
#include <utility>
#include <cmath>
#include <limits>
#include <iomanip>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <memory>
#include <exception>
#include <sstream>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef size_t sz;

typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;

typedef vector<int> vi;
typedef vector<sz> vsz;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<string> vs;

typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<pull> vpull;

#define cal(c) (c).cbegin(), (c).cend()
#define al(c) (c).begin(), (c).end()

const ull MOD = 1000 * 1000 * 1000ULL + 7;

/////////////////////////////////////////////////////////////////////

bool num(string& s)
{
	if (s.empty())
		return false;
	if (s.size() == 1 && s[0] == '0')
		return true;
	if (s[0] == '0')
		return false;
	bool r = true;
	for (sz i = 0; i < s.size(); ++i)
	{
		if (s[i] < '0' || s[i] > '9')
		{
			r = false;
			break;
		}
	}
	return r;
}

int main()
{
	cout.precision(17);

	string s;
	cin >> s;

	unordered_map<char, sz> m;
	for (sz i = 0; i < s.size(); ++i)
		++m[s[i]];

	vector<char> odd;
	for (auto it = m.begin(); it != m.end(); ++it)
	{
		if (it->second % 2)
			odd.push_back(it->first);
	}
	sort(al(odd));
	sort(al(s));

	auto tmp = s;

	for (int i = 0, j = odd.size() - 1; i < odd.size() / 2; ++i, --j)
	{
		auto p = lower_bound(al(s), odd[j]) - s.begin();
		tmp[p] = odd[i];
	}
	s = tmp;
	sort(al(s));

	string pref;
	for (sz i = 1; i < s.size(); i += 2)
		pref.push_back(s[i]);

	string r = pref;
	if (odd.size() % 2)
		r.push_back(odd[odd.size() / 2]);
	reverse(al(pref));
	r += pref;

	cout << r << endl;

    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>
#include <utility>
#include <cmath>
#include <limits>
#include <iomanip>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <memory>
#include <exception>
#include <sstream>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef size_t sz;

typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;

typedef vector<int> vi;
typedef vector<sz> vsz;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<string> vs;

typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<pull> vpull;

#define cal(c) (c).cbegin(), (c).cend()
#define al(c) (c).begin(), (c).end()

const ull MOD = 1000 * 1000 * 1000ULL + 7;

/////////////////////////////////////////////////////////////////////

bool num(string& s)
{
	if (s.empty())
		return false;
	if (s.size() == 1 && s[0] == '0')
		return true;
	if (s[0] == '0')
		return false;
	bool r = true;
	for (sz i = 0; i < s.size(); ++i)
	{
		if (s[i] < '0' || s[i] > '9')
		{
			r = false;
			break;
		}
	}
	return r;
}

int main()
{
	cout.precision(17);

	string s;
	cin >> s;

	unordered_map<char, sz> m;
	for (sz i = 0; i < s.size(); ++i)
		++m[s[i]];

	vector<char> odd;
	for (auto it = m.begin(); it != m.end(); ++it)
	{
		if (it->second % 2)
			odd.push_back(it->first);
	}
	sort(al(odd));
	sort(al(s));

	for (int i = 0, j = odd.size() - 1; i < odd.size() / 2; ++i, --j)
	{
		auto it = lower_bound(al(s), odd[j]);
		*it = odd[i];
	}
	sort(al(s));

	string pref;
	for (sz i = 1; i < s.size(); i += 2)
		pref.push_back(s[i]);

	string r = pref;
	if (odd.size() % 2)
		r.push_back(odd[odd.size() / 2]);
	reverse(al(pref));
	r += pref;

	cout << r << endl;

    return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
using namespace std;
typedef long long ll;
int freq[27];
int freq2[27];
int main(){
	string s;
	cin >> s;
	vector<char>v((int)s.size(), ' ');

	for (int i = 0; i < s.size(); i++){
		++freq[s[i] - 'a'];
	}
	int c = 0;

	string ans;
	int i = 0;
	set<char>x;
	for (int j = 0; j<26; j++)
	{
		while (freq[j]>1)
		{
			v[i] = char('a' + j);
			v[s.size() - i - 1] = char('a' + j);
			freq[j] -= 2;
			++i;
			c += 2;
		}
		if (freq[j] > 0)
			x.insert(char('a' + j));
	}
	s = "";
	for (int i = 0; i < v.size(); i++)
	{
		if (v.size() - i - 1 < v.size() && v[i] == ' '  && v[v.size() - i - 1] == ' ')
		{
			v[i] = v[v.size() - i - 1] = *x.begin();
			x.erase(x.begin());
		}
		else if (v[i] == ' ')
			v[i] = *x.begin();

		s += v[i];//cout << v[i];
	}
	for (int i = 0; i < s.size(); i++)
		freq2[s[i] - 'a']++;
	 i = 0;
//	set<char>x;
	 for (int j = 0; j<26; j++)
	 {
		 while (freq2[j]>1)
		 {
			 v[i] = char('a' + j);
			 v[s.size() - i - 1] = char('a' + j);
			 freq2[j] -= 2;
			 ++i;
			 c += 2;
		 }
		 if (freq2[j] > 0)
			 x.insert(char('a' + j));
	 }
	 for (int i = 0; i < v.size(); i++)
		 cout << v[i];
	 cout << endl;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
using namespace std;
typedef long long ll;
int freq[27];

int main(){
	string s;
	cin >> s;
	vector<char>v((int)s.size(), ' ');

	for (int i = 0; i < s.size(); i++){
		++freq[s[i] - 'a'];
	}
	int c = 0;

	string ans;
	int i = 0;
	set<char>x;
	for (int j = 0; j<26; j++)
	{
		while (freq[j]>1)
		{
			v[i] = char('a' + j);
			v[s.size() - i - 1] = char('a' + j);
			freq[j] -= 2;
			++i;
			c += 2;
		}
		if (freq[j] > 0)
			x.insert(char('a' + j));
	}
	for (int i = 0; i < v.size(); i++)
	{
		if (v.size() - i - 1 < v.size() && v[i] == ' '  && v[v.size() - i - 1] == ' ')
		{
			v[i] = v[v.size() - i - 1] = *x.begin();
			x.erase(x.begin());
		}
		else if (v[i] == ' ')
			v[i] = *x.begin();
		cout << v[i];
	}
	cout << endl;

}


#include <functional>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <sstream>
#include <assert.h>
#include <fstream>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstdio>
#include <complex>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <set>
#include <map>

using namespace std;

const int N = 200001;

int c[26];
int cTmp[26];
string s;

pair < int, string > solve(char ch = '?')
{
    pair < int, string > ans(0, "");
    for (int i = 0; i < 26; ++i)
        cTmp[i] = c[i];
    int l = 0, r = 25;
    while (l < r)
    {
        if (cTmp[l] % 2 == 0)
        {
            l++;
            continue;
        }
        if (cTmp[r] % 2 == 0)
        {
            r--;
            continue;
        }
        cTmp[r]--;
        cTmp[l]++;
        ans.first++;
    }
    for (int i = 0; i < 26; ++i)
    {
        for (int j = 1; j <= cTmp[i] / 2; ++j)
            ans.second += char(i + 'a');
    }
    string tmp = ans.second;
    reverse(tmp.begin(), tmp.end());
    if (ch == '?')
        ans.second += tmp;
    else
        ans.second += ch + tmp;
    return ans;
}

int main()
{
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    memset(c, 0, sizeof(c));
    cin >> s;
    for (int i = 0; i < s.size(); ++i)
        c[s[i] - 'a']++;
    pair < int, string > ans(10000001, "");
    if (s.size() % 2 == 0)
        ans = solve();
    else
    {
        for (int i = 0; i < 26; ++i)
        {
            if (c[i] % 2 == 1)
            {
                c[i]--;
                pair < int, string > tmp = solve(i + 'a');

                c[i]++;
                if (ans.first > tmp.first || (ans.first == tmp.first && ans.second > tmp.second))
                    ans = tmp;
            }
        }
    }
    cout << ans.second << endl;
    return 0;
}


#include<cstdio>
#include<iostream>
#include<queue>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int a[26],b[26];
char s[200000+5];
int main()
{
    cin>>s;
    int len=strlen(s);
    for(int i=0;i<len;i++){
        a[s[i]-'a']++;
    }
    int cnt=0;
    for(int i=0;i<26;i++){
        if(a[i]&1){
            a[i]--;
            b[cnt++]=i;
        }
    }
    int t = cnt / 2;
    for(int i=0;i<t;i++){
        a[b[i]]+=2;
    }
    if(cnt&1){
        a[b[cnt/2]]++;
    }
    int i=0;
    while(i<26){
        if((a[i]&1)==0){
            int Time=a[i]/2;
            while(a[i]>Time){
                printf("%c",i+'a');
                a[i]--;
            }
        }
        else {
            printf("%c",i+'a');
            a[i]--;
        }
        i++;
    }
    i=25;
    while(i>=0){
        while(a[i]>0){
            printf("%c",i+'a');
            a[i]--;
        }
        i--;
    }
    return 0;
}


#include<cstdio>
#include<iostream>
#include<queue>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int a[26],b[26];
char s[200000+5];
int main()
{
    cin>>s;
    int len=strlen(s);
    for(int i=0;i<len;i++){
        a[s[i]-'a']++;
    }
    int cnt=0;
    for(int i=0;i<26;i++){
        if(a[i]&1){
            a[i]--;
            b[cnt++]=i;
        }
    }
    int t = cnt / 2;
    for(int i=0;i<t;i++){
        a[b[i]]+=2;
    }
    if(cnt&1){
        a[b[cnt/2]]++;
    }
    int sign=-1;
    for(int i=0;i<26;i++){
        if(a[i]&1){
            a[i]--;
            sign=i;
        }
    }
    int i=0;
    while(i<26){
        if((a[i]&1)==0){
            int Time=a[i]/2;
            while(a[i]>Time){
                printf("%c",i+'a');
                a[i]--;
            }
        }
        i++;
    }
    if(sign!=-1)printf("%c",sign+'a');
    i=25;
    while(i>=0){
        while(a[i]>0){
            printf("%c",i+'a');
            a[i]--;
        }
        i--;
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <cassert>

using namespace std;

typedef unsigned long long int uint;
typedef long long int iint;

int main()
{
    string s;
    s.reserve(200000);

    getline(cin, s);

    vector<uint> count(26, 0);

    for (int i = 0; i < s.size(); i++)
    {
        count[s[i] - 'a']++;
    }

    int e = 25;
    for (int i = 0; i < 26; i++)
    {
        if ((count[i] % 2) != 0)
        {
            for (int j = e; j >= 0; j--)
            {
                if ((count[j] % 2) != 0)
                {
                    count[i]++;
                    count[j]--;

                    e = j;
                    goto done;
                }
            }
        }
    done:;
    }

    string half, center;
    half.reserve(100000);

    for (int i = 0; i < 26; i++)
    {
        half += string(count[i] / 2, 'a' + i);

        if ((count[i] % 2) == 1)
        {
            assert(s.size() % 2 == 1);
            assert(center.empty());

            center = 'a' + i;
        }
    }

    cout << half;
    cout << center;
    reverse(half.begin(), half.end());
    cout << half << endl;

    return 0;
}


#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <cassert>

using namespace std;

typedef unsigned long long int uint;
typedef long long int iint;

int main()
{
    string s;
    s.reserve(200000);

    getline(cin, s);

    vector<uint> count(26, 0);

    for (int i = 0; i < s.size(); i++)
        count[s[i] - 'a']++;

    int e = 25;
    for (int i = 0; i < 26; i++)
    {
        if ((count[i] % 2) != 0)
        {
            for (int j = e; j >= 0; j--)
            {
                if ((count[j] % 2) != 0)
                {
                    count[i]++;
                    count[j]--;

                    e = j;
                    goto done;
                }
            }
        }
    done:;
    }

    string half, center;
    half.reserve(100000);

    for (int i = 0; i < 26; i++)
    {
        if ((count[i] % 2) == 1)
        {
            assert(s.size() % 2 == 1);
            assert(center.empty());

            center = string(count[i], 'a' + i);
        }
        else
        {
            for (int j = 0; j < count[i] / 2; j++)
                half += 'a' + i;
        }
    }

    cout << half;
    cout << center;
    reverse(half.begin(), half.end());
    cout << half << endl;

    return 0;
}