const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

class Info {
    constructor(newTeamName, newPoints, newGoalDiff, newScoredGoals) {
        this.TeamName = newTeamName;
        this.Points = newPoints;
        this.GoalDiff = newGoalDiff;
        this.ScoredGoals = newScoredGoals;
    }
}

var indicator = 0, N, cont = [];

rl.on('line', (input) => {
    if (indicator == 0) {
        N = parseInt(input);
        indicator++;
    }
    else if (indicator <= N) {
        //var obj=new Info(input,0,0,0);
        cont.push(new Info(input, 0, 0, 0));
        indicator++;
    }
    else {
        var dashIndex = input.indexOf('-');
        var spaceIndex = input.indexOf(' ');
        var colonIndex = input.indexOf(':');

        var Team1Name = input.substring(0, dashIndex);
        var Team2Name = input.substring(dashIndex + 1, spaceIndex);

        var Goal1 = parseInt(input.substring(spaceIndex + 1, colonIndex));
        var Goal2 = parseInt(input.substring(colonIndex + 1));

        var Team1Index = cont.findIndex(item => item.TeamName == Team1Name);
        var Team2Index = cont.findIndex(item => item.TeamName == Team2Name);

        //Update Points

        if (Goal1 > Goal2)
            cont[Team1Index].Points += 3;
        else if (Goal1 < Goal2)
            cont[Team2Index].Points += 3;
        else {
            cont[Team1Index].Points++;
            cont[Team2Index].Points++;
        }
        //Update Goal Difference
        cont[Team1Index].GoalDiff += (Goal1 - Goal2);
        cont[Team2Index].GoalDiff += (Goal2 - Goal1);

        //Update Scored Goals
        cont[Team1Index].ScoredGoals += Goal1;
        cont[Team2Index].ScoredGoals += Goal2;

    }

}).on('close', () => {
    //sort by points, then by GoalDiff and then by ScoredGoals in descending order
    cont.sort((obj1, obj2) => {
        if (obj1.Points != obj2.Points)
            return obj2.Points - obj1.Points;

        if (obj1.GoalDiff != obj2.GoalDiff)
            return obj2.GoalDiff - obj1.GoalDiff;

        return obj2.ScoredGoals - obj1.ScoredGoals;
    });

    //delete second half of our array
    cont.splice(N/2);
    //sort by Team name in ascending order
    cont.sort( (obj1,obj2) => {
       // return obj1.TeamName.localeCompare(obj2.TeamName);
       return obj1.TeamName > obj2.TeamName ? 1 : -1;
    });
    //output
    cont.forEach(item => {
        console.log(item.TeamName);
    });
});

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

class Info {
    constructor(newTeamName, newPoints, newGoalDiff, newScoredGoals) {
        this.teamName = newTeamName;
        this.points = newPoints;
        this.goalDiff = newGoalDiff;
        this.scoredGoals = newScoredGoals;
    }
}

var findIndexByName = function (cont, searchName) {
    for (let i = 0; i < cont.length; i++) {
        if (cont[i].teamName == searchName)
            return i;
    }
    return -1;
}
var cont = [];
var indicator = 0, N;

rl.on('line', (input) => {
    if (indicator == 0) {
        N = parseInt(input);
        indicator++;
    }
    else if (indicator <= N) {
        cont.push(new Info(input, 0, 0, 0));
        indicator++;
    }
    else {
        let dashIndex = input.indexOf("-");
        let spaceIndex = input.indexOf(" ");
        let colonIndex = input.indexOf(":");
        let team1Name = input.substring(0, dashIndex);
        let team2Name = input.substring(dashIndex + 1, spaceIndex);
        let goal1 = parseInt(input.substring(spaceIndex + 1, colonIndex));
        let goal2 = parseInt(input.substring(colonIndex + 1));
        let team1Index = findIndexByName(cont, team1Name);
        let team2Index = findIndexByName(cont, team2Name);
        // update points
        if (goal1 > goal2)
            cont[team1Index].points += 3;
        else if (goal1 < goal2)
            cont[team2Index].points += 3;
        else {
            cont[team1Index].points++;
            cont[team2Index].points++;
        }
        // update goalDiff
        cont[team1Index].goalDiff += (goal1 - goal2);
        cont[team2Index].goalDiff += (goal2 - goal1);
        // update scoredGoals
        cont[team1Index].scoredGoals += goal1;
        cont[team2Index].scoredGoals += goal2;
    }
}).on('close', function () {
    // sort by points, then by goalDiff, then by scoredGoals in descending order:
    cont.sort((obj1, obj2) => {
        if (obj1.points != obj2.points)
            return obj2.points - obj1.points;

        if (obj1.goalDiff != obj2.goalDiff)
            return obj2.goalDiff - obj1.goalDiff;

        return obj2.scoredGoals - obj1.scoredGoals;
    });
    // delete second half of cont
    cont.splice(N / 2);
    // sort by teamName in lexicographical order
    cont.sort((obj1, obj2) => {
        let s1 = obj1.teamName;
        let s2 = obj2.teamName;
        let s1Len = s1.length;
        let s2Len = s2.length;
        let minLen = Math.min(s1Len, s2Len);
        for (let i = 0; i < minLen; i++) {
            if (s1[i] != s2[i])
                return s1.charCodeAt(i) - s2.charCodeAt(i);
        }
        return s1Len - s2Len;
    });

    cont.forEach(item => {
        console.log(item.teamName);
    });
});

/*
    0123456789.........
s= 'barcelona-real 15:10'

4
A
B
C
D
A-B 1:1
A-C 2:2
A-D 1:0
B-C 1:0
B-D 0:3
C-D 0:3

Points                 goalDiff                           scoredGoals
A => 1+1+3=5           A=> (1+2+1) - (1+2+0)= 4-3=1       A=> 4
B => 1+3+0=4           B=> (1+1+0) - (1+0+3)= 2-4=-2      B=> 2
C => 1+0+0=1           C=> (2+0+0) - (2+1+3)= 2-6=-4      C=> 2
D => 0+3+3=6           D=> (0+3+3) - (1+0+0)= 6-1=5       D=> 6

A, B, C, D => D, A, B, C => D, A =>A, D

cont:
    0               1
|teamName: 'A' |teamname: 'B'|
|point: 5      |point: 5     |
|goalDiff: 1   |
|scoredGoals: 4|
*/

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
  });

class Info{
    constructor(newTeamName, newPoint, newGoalDiff, newScoredGoals){
        this.teamName=newTeamName;
        this.point=newPoint;
        this.goalDiff=newGoalDiff;
        this.scoredGoals=newScoredGoals;
    }
}
/*
  var findIndexByName = function(cont, searchName){
         for(let i=0; i<cont.length;i++){
             if(cont[i] == searchName)
                  return i;
         }
       return -1;
  }
  */

  var cont=[],indicator=0, N=0;
  rl.on('line', (input) => {
    if(indicator == 0){
        N = parseInt(input);
        indicator++;
    }
    else if(indicator <= N){
      cont.push(new Info(input,0,0,0));
      indicator++;
    }
    else{
        let dashInd = input.indexOf('-');
        let spaceInd = input.indexOf(' ');
        let colonInd = input.indexOf(':');

        let team1Name = input.substring(0,dashInd);
        let team2Name = input.substring(dashInd+1, spaceInd);
        let goal1=parseInt(input.substring(spaceInd+1, colonInd));
        let goal2=parseInt(input.substring(colonInd+1));

        let team1Index = cont.findIndex(obj => obj.teamName == team1Name);
        let team2Index = cont.findIndex(obj => obj.teamName == team2Name);

        //update points
        if(goal1>goal2)
          cont[team1Index].point +=3;
        else if(goal1<goal2)
          cont[team2Index].point+=3;
        else{
           cont[team1Index].point++;
           cont[team2Index].point++;
        }

        // update goal difference
        cont[team1Index].goalDiff += (goal1-goal2);
        cont[team2Index].goalDiff += (goal2-goal1);

        // update scored goals
        cont[team1Index].scoredGoals += goal1;
        cont[team2Index].scoredGoals += goal2;

    }
  }).on('close',function(){
     // sort by descending order first of all by points, thenby goalDiff and then by scoredGoals
     cont.sort((obj1, obj2)=>{

        if(obj1.point != obj2.point)
             return obj2.point - obj1.point;

        if(obj1.goalDiff != obj2.goalDiff)
           return obj2.goalDiff - obj1.goalDiff;

        return obj2.scoredGoals - obj1.scoredGoals;
     });

     // remove second half of array
    cont.splice(N/2);

    //sort by lexicographical order
    cont.sort((obj1, obj2)=>{

        if(obj1.teamName > obj2.teamName)
           return 1;
        else if(obj1.teamName < obj2.teamName)
           return -1;
        else
           return 0;
    });

    cont.forEach(element => {
        console.log(element.teamName);
    });

  });

/*

           0               1             2  ........
cont=|teamName: "A" |teamName: "B"|.......
     |point: 5      |
     |goalDiff: 1   |
     |scoredGoals: 4|
*/
  /*

4
A
B
C
D
A-B 1:1
A-C 2:2
A-D 1:0
B-C 1:0
B-D 0:3
C-D 0:3

Points             GoalDifference                 ScoredGoals

A=>1+1+3=5         A=>(1+2+1)-(1+2)=4-3=1         A=>4
B=>1+3+0=4         B=>(1+1)-(1+3)=2-4=-2          B=>2
C=>1+0+0=1         C=>(2)-(2+1+3)=2-6=-4          C=>2
D=>0+3+3=6         D=>(3+3)-(1)=6-1=5             D=>6

A B C D => D A B C => D A => A D
  */

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

class Info {
    constructor(newTeamName, newPoints, newGoalDiff, newScoredGoals) {
        this.teamName = newTeamName;
        this.points = newPoints;
        this.goalDiff = newGoalDiff;
        this.scoredGoals = newScoredGoals;
    }
}
var indexOfByName = function (cont,N, searchName) {
    for (let i = 0; i < N; i++)
        if (cont[i].teamName == searchName)
            return i;
    return -1;
}
var indicator = 0, N, cont = [];

rl.on('line', (input) => {
    if (indicator == 0) {
        N = parseInt(input);
        indicator++;
    }
    else if (indicator <= N) {
        cont.push(new Info(input, 0, 0, 0));
        indicator++;
    }
    else {
        let dashIndx = input.indexOf('-');
        let spaceIndx = input.indexOf(' ');
        let colonIndx = input.indexOf(':');

        let team1Name = input.substring(0, dashIndx);
        let team2Name = input.substring(dashIndx + 1, spaceIndx);
        let Goal1 = parseInt(input.substring(spaceIndx + 1, colonIndx));
        let Goal2 = parseInt(input.substring(colonIndx + 1));

        let team1Indx = indexOfByName(cont,N, team1Name);
        let team2Indx = indexOfByName(cont,N, team2Name);

        //update points

        if (Goal1 > Goal2)
            cont[team1Indx].points += 3;
        else if (Goal1 < Goal2)
            cont[team2Indx].points += 3;
        else {
            cont[team1Indx].points++;
            cont[team2Indx].points++;
        }

        //update goal diff

        cont[team1Indx].goalDiff += (Goal1 - Goal2);
        cont[team2Indx].goalDiff += (Goal2 - Goal1);

        //update scored goals

        cont[team1Indx].scoredGoals += Goal1;
        cont[team2Indx].scoredGoals += Goal2;

    }
}).on('close', () => {
    //sort by points then by GoalDiff then by scored goals in descending order
    cont.sort((obj1, obj2) => {
        if (obj1.points != obj2.points)
            return obj2.points - obj1.points;

        if (obj1.goalDiff != obj2.goalDiff)
            return obj2.goalDiff - obj1.goalDiff;

       return obj2.scoredGoals - obj1.scoredGoals;
    });

    // delete the second half of array
    cont.splice(N / 2);
    //order by teamName in lexicographical order ascending order
    cont.sort((obj1, obj2) => {
        let s1 = obj1.teamName;
        let s2 = obj2.teamName;
        let s1Len = s1.length;
        let s2Len = s2.length;
        let minLen = Math.min(s1Len, s2Len);
        for (let i = 0; i < minLen; i++) {
            if (s1[i] != s2[i])
                return s1.charCodeAt(i) - s2.charCodeAt(i);
        }
        return s1Len - s2Len;
    });

    //output ans
    cont.forEach(element => {
        console.log(element.teamName);
    });
});

/*
       0123456789...
input="Barcelona-Real 15:10"
4
A
B
C
D
A-B 1:1
A-C 2:2
A-D 1:0
B-C 1:0
B-D 0:3
C-D 0:3

Points            GoalDiff                     ScoredGoals
A=>1+1+3=5        A=>(1+2+1)-(1+2)=4-3=1       A=>4
B=>1+3=4          B=>(1+1)-(1+3)=2-4=-2        B=>2
C=>1              C=>(2)-(2+1+3)=2-6=-4        C=>2
D=>3+3=6          D=>(3+3)-(1)=6-1=5           D=>6

{D,A,B,C} => {D,A} => {A,D}

  0
|teamName: "A" |teamName
|Points: 5     |
|GoalDiff: -2  |
|scoredGoals: 4|

*/

const readline = require("readline");

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});

class Info {
  constructor(newTeamName, newPoints, newGoalDiff, newScoredGoals) {
    this.teamName = newTeamName;
    this.points = newPoints;
    this.goalDiff = newGoalDiff;
    this.scoredGoals = newScoredGoals;
  }
}

var indexOfByName = function (cont, searchName) {
  for (let i = 0; i < cont.length; i++) {
    if (cont[i].teamName == searchName) return i;
  }
  return -1;
};
/*

4
A
B
C
D
A-B 1:1
A-C 2:2
A-D 1:0
B-C 1:0
B-D 0:3
C-D 0:3

*/

var cont = [],
  indicator = 0,
  N = 0;
rl.on("line", (input) => {
  if (indicator == 0) {
    N = parseInt(input);
    indicator++;
  } else if (indicator <= N) {
    cont.push(new Info(input, 0, 0, 0));
    indicator++;
  } else {
    // 0123456789....
    //"Barcelona-Real 15:10"
    let dashIndex = input.indexOf("-");
    let spaceIndex = input.indexOf(" ");
    let colonIndex = input.indexOf(":");
    let team1Name = input.substring(0, dashIndex);
    let team2Name = input.substring(dashIndex + 1, spaceIndex);
    let goal1 = parseInt(input.substring(spaceIndex + 1, colonIndex));
    let goal2 = parseInt(input.substring(colonIndex + 1));
    let team1Index = indexOfByName(cont, team1Name);
    let team2Index = indexOfByName(cont, team2Name);
    // Update Points
    if (goal1 > goal2) cont[team1Index].points += 3;
    else if (goal1 < goal2) cont[team2Index].points += 3;
    else {
      cont[team1Index].points++;
      cont[team2Index].points++;
    }
    //update goal diff
    cont[team1Index].goalDiff += goal1 - goal2;
    cont[team2Index].goalDiff += goal2 - goal1;
    //update Score goals
    cont[team1Index].scoredGoals += goal1;
    cont[team2Index].scoredGoals += goal2;
  }
}).on("close", function () {
  // sort by point then by goalDiff and then by scored goals in descending order
  cont.sort((obj1, obj2) => {
    if (obj1.points != obj2.points) return obj2.points - obj1.points;

    if (obj1.goalDiff != obj2.goalDiff) return obj2.goalDiff - obj1.goalDiff;

    return obj2.scoredGoals - obj1.scoredGoals;
  });

  //erse second half of an array
  cont.splice(N / 2);

  //sort by teamname in ascending order
  cont.sort((obj1, obj2) => {
    let s1 = obj1.teamName;
    let s2 = obj2.teamName;
    let s1Len = s1.length;
    let s2Len = s2.length;
    let minLen = Math.min(s1Len, s2Len);
    for (let i = 0; i < minLen; i++) {
      if (s1[i] != s2[i]) return s1.charCodeAt(i) - s2.charCodeAt(i);
    }
    return s1Len - s2Len;
  });

  //output answer
  cont.forEach((element) => {
    console.log(element.teamName);
  });
});

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

class Info {
    constructor(teamName, points, goalDiff, scoredGoals) {
        this.teamName = teamName;
        this.points = points;
        this.goalDiff = goalDiff;
        this.scoredGoals = scoredGoals;
    }

}

var outputInfoObj = function (obj) {
    console.log("************************");
    console.log("teamName=%s ", obj.teamName);
    console.log("points  = %d", obj.points);
    console.log("goaldiff  = %d", obj.goalDiff);
    console.log("scoredgoals  = %d", obj.scoredGoals);
    console.log("************************");
}

var customCompare = function (obj1, obj2) {
    if (obj1.points != obj2.points)
        return obj2.points - obj1.points;

    if (obj1.goalDiff != obj2.goalDiff)
        return obj2.goalDiff - obj1.goalDiff;

    return obj2.scoredGoals - obj1.scoredGoals;
}

var compareByName = function (obj1, obj2) {
    var s1 = obj1.teamName;
    var s2 = obj2.teamName;
    var s1Len = s1.length;//<=problem was here. error caused: Length instead of length
    var s2Len = s2.length;// note that js
    var minLen = (s1Len > s2Len) ? s2Len : s1Len;
    for (let i = 0; i < minLen; i++) {
        let cd1 = s1.charCodeAt(i);
        let cd2 = s2.charCodeAt(i);
        //console.log("inside compare func s1=%s s2=%s  cd1=%d  cd2=%d",s1,s2,cd1,cd2);
        if (cd1 != cd2)
            return  cd1-cd2;
        /*
                if(s1[i]!=s2[i])
                    //return s1[i]-s2[i];
                    return s1.charCodeAt(i) - s2.charCodeAt(i);
        */
    }
    return s1Len - s2Len;
}

var n, indicator = 0,
    cont = [];

rl.on('line', (input) => {
    if (indicator == 0) {
        n = parseInt(input);
        indicator++;
    } else if (indicator <= n) {
        cont.push(new Info(input, 0, 0, 0));
        indicator++;
    } else {
        var dashIndex = input.indexOf('-');
        var spaceIndex = input.indexOf(' ');
        var colonIndex = input.indexOf(':');
        var team1Name = input.substring(0, dashIndex);
        var team2Name = input.substring(dashIndex + 1, spaceIndex);
        var goal1 = parseInt(input.substring(spaceIndex + 1, colonIndex));
        var goal2 = parseInt(input.substring(colonIndex + 1));
        var team1Index = cont.findIndex(item => item.teamName == team1Name);
        var team2Index = cont.findIndex(item => item.teamName == team2Name);

        //Update points
        if (goal1 > goal2)
            cont[team1Index].points += 3;
        else if (goal2 > goal1)
            cont[team2Index].points += 3;
        else {
            cont[team1Index].points++;
            cont[team2Index].points++;
        }
        //Update Goal Difference
        cont[team1Index].goalDiff += (goal1 - goal2);
        cont[team2Index].goalDiff += (goal2 - goal1);
        //Update Scored Goals
        cont[team1Index].scoredGoals += goal1;
        cont[team2Index].scoredGoals += goal2;

    }
}).on('close', () => {
    /* cont.forEach(item => {
         outputInfoObj(item);
     });*/
    cont.sort(customCompare);
    cont.splice(n / 2);
    //cont.sort((obj1, obj2) => obj1.teamName.localeCompare(obj2.teamName));
    cont.sort(compareByName);
    cont.forEach(item => {
        console.log(item.teamName);
    });

});

'use strict'

let lll

const N = +readline()

let ts = {}

for (let i = 0; i < N; i++) {
  const n = readline()
  ts[n] = [0, 0, 0, n]
}

while (lll = readline()) {
  const fn = lll.slice(0, lll.indexOf('-'))
  const sn = lll.slice(lll.indexOf('-') + 1, lll.indexOf(' '))
  const scr = lll.slice(lll.indexOf(' ') + 1).split(':').map(v => parseInt(v))
  const fs = scr[0]
  const ss = scr[1]
  if (fs > ss) {
    ts[fn][0] += 3
  } else if (ss > fs) {
    ts[sn][0] += 3
  } else {
    ts[fn][0] += 1
    ts[sn][0] += 1
  }
  ts[fn][1] += fs
  ts[fn][1] -= ss
  ts[sn][1] += ss
  ts[sn][1] -= fs
  ts[fn][2] += fs
  ts[sn][2] += ss
}

const ns = Object.keys(ts)
const tsa = []

for (let i = 0; i < ns.length; i++) {
  tsa.push(ts[ns[i]])
}

tsa.sort((ft, st) => ft[0] - st[0] || ft[1] - st[1] || ft[2] - st[2])

const pots = tsa.slice(tsa.length / 2).map(v => v[3]).sort()

pots.forEach(v => print(v))

'use strict'

let lll

const N = +readline()

let ts = {}

for (let i = 0; i < N; i++) {
  const n = readline()
  ts[n] = [0, 0, 0, n]
}

while (lll = readline()) {
  const fn = lll.slice(0, lll.indexOf('-'))
  const sn = lll.slice(lll.indexOf('-') + 1, lll.indexOf(' '))
  const scr = lll.slice(lll.indexOf(' ') + 1).split(':').map(v => parseInt(v))
  const fs = scr[0]
  const ss = scr[1]
  if (fs > ss) {
    ts[fn][0] += 3
  } else if (ss > fs) {
    ts[sn][0] += 3
  } else {
    ts[fn][0] += 1
    ts[sn][0] += 1
  }
  ts[fn][1] += fs
  ts[fn][1] -= ss
  ts[sn][1] += ss
  ts[sn][1] -= fs
  ts[fn][2] += fs
  ts[sn][2] += ss
}

const ns = Object.keys(ts)
const tsa = []

for (let i = 0; i < ns.length; i++) {
  tsa.push(ts[ns[i]])
}

tsa.sort((ft, st) => ft[0] - st[0] || ft[1] - st[1] || ft[2] - st[2])

for (let i = tsa.length / 2 | 0; i < tsa.length; i++) print(tsa[i][3])

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

class Info {
    constructor(newTeamName, newPoints, newGoalDiff, newScoredGoals) {
        this.TeamName = newTeamName;
        this.Points = newPoints;
        this.GoalDiff = newGoalDiff;
        this.ScoredGoals = newScoredGoals;
    }
}

var indicator = 0, N, cont = [];

rl.on('line', (input) => {
    if (indicator == 0) {
        N = parseInt(input);
        indicator++;
    }
    else if (indicator <= N) {
        //var obj=new Info(input,0,0,0);
        cont.push(new Info(input, 0, 0, 0));
        indicator++;
    }
    else {
        var dashIndex = input.indexOf('-');
        var spaceIndex = input.indexOf(' ');
        var colonIndex = input.indexOf(':');

        var Team1Name = input.substring(0, dashIndex);
        var Team2Name = input.substring(dashIndex + 1, spaceIndex);

        var Goal1 = parseInt(input.substring(spaceIndex + 1, colonIndex));
        var Goal2 = parseInt(input.substring(colonIndex + 1));

        var Team1Index = cont.findIndex(item => item.TeamName == Team1Name);
        var Team2Index = cont.findIndex(item => item.TeamName == Team2Name);

        //Update Points

        if (Goal1 > Goal2)
            cont[Team1Index].Points += 3;
        else if (Goal1 < Goal2)
            cont[Team2Index].Points += 3;
        else {
            cont[Team1Index].Points++;
            cont[Team2Index].Points++;
        }
        //Update Goal Difference
        cont[Team1Index].GoalDiff += (Goal1 - Goal2);
        cont[Team2Index].GoalDiff += (Goal2 - Goal1);

        //Update Scored Goals
        cont[Team1Index].ScoredGoals += Goal1;
        cont[Team2Index].ScoredGoals += Goal2;

    }

}).on('close', () => {
    //sort by points, then by GoalDiff and then by ScoredGoals in descending order
    cont.sort((obj1, obj2) => {
        if (obj1.Points != obj2.Points)
            return obj2.Points - obj1.Points;

        if (obj1.GoalDiff != obj2.GoalDiff)
            return obj2.GoalDiff - obj1.GoalDiff;

        return obj2.ScoredGoals - obj1.ScoredGoals;
    });

    //delete second half of our array
    cont.splice(N/2);
    //sort by Team name in ascending order
    cont.sort( (obj1,obj2) => {
        return obj1.TeamName.localeCompare(obj2.TeamName);
    });
    //output
    cont.forEach(item => {
        console.log(item.TeamName);
    });
});

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

class Info {
    constructor(newTeamName, newPoints, newGoalDiff, newScoredGoals) {
        this.teamName = newTeamName;
        this.points = newPoints;
        this.goalDiff = newGoalDiff;
        this.scoredGoals = newScoredGoals;
    }
}
var indexOfByName = function (cont, searchName) {
    for (let i = 0; i < cont.length; i++)
        if (cont[i].teamName == searchName)
            return i;
    return -1;
}
var indicator = 0, N, cont = [];

rl.on('line', (input) => {
    if (indicator == 0) {
        N = parseInt(input);
        indicator++;
    }
    else if (indicator <= N) {
        cont.push(new Info(input, 0, 0, 0));
        indicator++;
    }
    else {
        let dashIndx = input.indexOf('-');
        let spaceIndx = input.indexOf(' ');
        let colonIndx = input.indexOf(':');

        let team1Name = input.substring(0, dashIndx);
        let team2Name = input.substring(dashIndx + 1, spaceIndx);
        let Goal1 = parseInt(input.substring(spaceIndx + 1, colonIndx));
        let Goal2 = parseInt(input.substring(colonIndx + 1));

        let team1Indx = indexOfByName(cont, team1Name);
        let team2Indx = indexOfByName(cont, team2Name);

        //update points

        if (Goal1 > Goal2)
            cont[team1Indx].points += 3;
        else if (Goal1 < Goal2)
            cont[team2Indx].points += 3;
        else {
            cont[team1Indx].points++;
            cont[team2Indx].points++;
        }

        //update goal diff

        cont[team1Indx].goalDiff += (Goal1 - Goal2);
        cont[team2Indx].goalDiff += (Goal2 - Goal1);

        //update scored goals

        cont[team1Indx].scoredGoals += Goal1;
        cont[team2Indx].scoredGoals += Goal2;

    }
}).on('close', () => {
    //sort by points then by GoalDiff then by scored goals in descending order
    cont.sort((obj1, obj2) => {
        if (obj1.points != obj2.points)
            return obj2.points - obj1.points;
        if (obj1.goalDiff != obj2.goalDiff)
            return obj2.goalDiff - obj1.goalDiff;

        obj2.scoredGoals - obj1.scoredGoals;
    });

    // delete the second half of array
    cont.splice(N / 2);
    //order by teamName in lexicographical order ascending order
    cont.sort((obj1, obj2) => {
        let s1 = obj1.teamName;
        let s2 = obj2.teamName;
        let s1Len = s1.length;
        let s2Len = s2.length;
        let minLen = Math.min(s1Len, s2Len);
        for (let i = 0; i < minLen; i++) {
            if (s1[i] != s2[i])
                return s1.charCodeAt(i) - s2.charCodeAt(i);
        }
        return s1Len - s2Len;
    });

    //output ans
    cont.forEach(element => {
        console.log(element.teamName);
    });
});

const readline = require("readline");

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});

class Info {
  constructor(newTeamName, newPoints, newGoalDiff, newScoredGoals) {
    this.teamName = newTeamName;
    this.points = newPoints;
    this.goalDiff = newGoalDiff;
    this.scoredGoals = newScoredGoals;
  }
}

var indexOfByName = function (cont, searchName) {
  for (let i = 0; i < cont.length; i++) {
    if (cont[i].teamName == searchName) return i;
  }
  return -1;
};
/*

4
A
B
C
D
A-B 1:1
A-C 2:2
A-D 1:0
B-C 1:0
B-D 0:3
C-D 0:3

*/

var cont = [],
  indicator = 0,
  N = 0;
rl.on("line", (input) => {
  if (indicator == 0) {
    N = parseInt(input);
    indicator++;
  } else if (indicator <= N) {
    cont.push(new Info(input, 0, 0, 0));
    indicator++;
  } else {
    // 0123456789....
    //"Barcelona-Real 15:10"
    let dashIndex = input.indexOf("-");
    let spaceIndex = input.indexOf(" ");
    let colonIndex = input.indexOf(":");
    let team1Name = input.substring(0, dashIndex);
    let team2Name = input.substring(dashIndex + 1, spaceIndex);
    let goal1 = parseInt(input.substring(spaceIndex + 1, colonIndex));
    let goal2 = parseInt(input.substring(colonIndex + 1));
    let team1Index = indexOfByName(cont, team1Name);
    let team2Index = indexOfByName(cont, team2Name);
    // Update Points
    if (goal1 > goal2) cont[team1Index].points += 3;
    else if (goal1 < goal2) cont[team2Index].points += 3;
    else {
      cont[team1Index].points++;
      cont[team2Index].points++;
    }
    //update goal diff
    cont[team1Index].goalDiff += goal1 - goal2;
    cont[team2Index].goalDiff += goal2 - goal1;
    //update Score goals
    cont[team1Index].scoredGoals += goal1;
    cont[team2Index].scoredGoals += goal2;
  }
}).on("close", function () {
  // sort by point then by goalDiff and then by scored goals in descending order
  cont.sort((obj1, obj2) => {
    if (obj1.points != obj2.points) return obj2.points - obj1.points;

    if (obj1.goalDiff != obj2.goalDiff) return obj2.goalDiff - obj1.goalDiff;

    return obj2.scoredGoals - obj2.scoredGoals;
  });

  //erse second half of an array
  cont.splice(N / 2);

  //sort by teamname in ascending order
  cont.sort((obj1, obj2) => {
    let s1 = obj1.teamName;
    let s2 = obj2.teamName;
    let s1Len = s1.length;
    let s2Len = s2.length;
    let minLen = Math.min(s1Len, s2Len);
    for (let i = 0; i < minLen; i++) {
      if (s1[i] != s2[i]) return s1.charCodeAt(i) - s2.charCodeAt(i);
    }
    return s1Len - s2Len;
  });

  //output answer
  cont.forEach((element) => {
    console.log(element.teamName);
  });
});

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

class Info {
    constructor(teamName, points, goalDiff, scoredGoals) {
        this.teamName = teamName;
        this.points = points;
        this.goalDiff = goalDiff;
        this.scoredGoals = scoredGoals;
    }

}

var outputInfoObj = function (obj) {
    console.log("************************");
    console.log("teamName=%s ", obj.teamName);
    console.log("points  = %d", obj.points);
    console.log("goaldiff  = %d", obj.goalDiff);
    console.log("scoredgoals  = %d", obj.scoredGoals);
    console.log("************************");
}

var customCompare = function (obj1, obj2) {
    if (obj1.points != obj2.points)
        return obj2.points - obj1.points;

    if (obj1.goalDiff != obj2.goalDiff)
        return obj2.goalDiff - obj1.goalDiff;

    return obj2.scoredGoals - obj1.scoredGoals;
}

var compareByName = function (obj1, obj2) {
    var s1 = obj1.teamName;
    var s2 = obj2.teamName;
    var s1Len = s1.Length;
    var s2Len = s2.Length;
    var minLen = (s1Len>s2Len)?s2Len:s1Len;
    for(let i=0;i<minLen;i++){
        if(s1[i]!=s2[i])
            return s1[i]-s2[i];
    }
    return s1Len-s2Len;
}

var n, indicator = 0,
    cont = [];

rl.on('line', (input) => {
    if (indicator == 0) {
        n = parseInt(input);
        indicator++;
    } else if (indicator <= n) {
        cont.push(new Info(input, 0, 0, 0));
        indicator++;
    } else {
        var dashIndex = input.indexOf('-');
        var spaceIndex = input.indexOf(' ');
        var colonIndex = input.indexOf(':');
        var team1Name = input.substring(0, dashIndex);
        var team2Name = input.substring(dashIndex + 1, spaceIndex);
        var goal1 = parseInt(input.substring(spaceIndex + 1, colonIndex));
        var goal2 = parseInt(input.substring(colonIndex + 1));
        var team1Index = cont.findIndex(item => item.teamName == team1Name);
        var team2Index = cont.findIndex(item => item.teamName == team2Name);

        //Update points
        if (goal1 > goal2)
            cont[team1Index].points += 3;
        else if (goal2 > goal1)
            cont[team2Index].points += 3;
        else {
            cont[team1Index].points++;
            cont[team2Index].points++;
        }
        //Update Goal Difference
        cont[team1Index].goalDiff += (goal1 - goal2);
        cont[team2Index].goalDiff += (goal2 - goal1);
        //Update Scored Goals
        cont[team1Index].scoredGoals += goal1;
        cont[team2Index].scoredGoals += goal2;

    }
}).on('close', () => {
    /* cont.forEach(item => {
         outputInfoObj(item);
     });*/
    cont.sort(customCompare);
    cont.splice(n / 2);
    //cont.sort((obj1, obj2) => obj1.teamName.localeCompare(obj2.teamName));
    cont.sort(compareByName);
    cont.forEach(item => {
        console.log(item.teamName);
    });

});

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

class Info {
    constructor(teamName, points, goalDiff, scoredGoals) {
        this.teamName = teamName;
        this.points = points;
        this.goalDiff = goalDiff;
        this.scoredGoals = scoredGoals;
    }

}

var outputInfoObj = function(obj){
    console.log("************************");
    console.log("teamName=%s ",obj.teamName);
    console.log("points  = %d",obj.points);
    console.log("goaldiff  = %d",obj.goalDiff);
    console.log("scoredgoals  = %d",obj.scoredGoals);
    console.log("************************");
}

var customCompare = function (obj1, obj2) {
    if (obj1.points != obj2.points)
        return obj2.points - obj1.points;

    if (obj1.goalDiff != obj2.goalDiff)
        return obj2.goalDiff - obj1.goalDiff;

    return obj2.scoredGoals - obj1.scoredGoals;
}

var n, indicator = 0,
    cont = [];

rl.on('line', (input) => {
    if (indicator == 0) {
        n = parseInt(input);
        indicator++;
    } else if (indicator <= n) {
        cont.push(new Info(input, 0, 0, 0));
        indicator++;
    } else {
        var dashIndex = input.indexOf('-');
        var spaceIndex = input.indexOf(' ');
        var colonIndex = input.indexOf(':');
        var team1Name = input.substring(0, dashIndex);
        var team2Name = input.substring(dashIndex + 1, spaceIndex);
        var goal1 = parseInt(input.substring(spaceIndex + 1, colonIndex));
        var goal2 = parseInt(input.substring(colonIndex+1));
        var team1Index = cont.findIndex(item => item.teamName == team1Name);
        var team2Index = cont.findIndex(item => item.teamName == team2Name);

        //Update points
        if (goal1 > goal2)
            cont[team1Index].points += 3;
        else if (goal2 > goal1)
            cont[team2Index].points += 3;
        else {
            cont[team1Index].points++;
            cont[team2Index].points++;
        }
        //Update Goal Difference
        cont[team1Index].goalDiff += (goal1 - goal2);
        cont[team2Index].goalDiff += (goal2 - goal1);
        //Update Scored Goals
        cont[team1Index].scoredGoals += goal1;
        cont[team2Index].scoredGoals += goal2;

    }
}).on('close', () => {
   /* cont.forEach(item => {
        outputInfoObj(item);
    });*/
    cont.sort(customCompare);
    cont.splice(n / 2);
    cont.sort((obj1, obj2) => obj1.teamName.localeCompare(obj2.teamName));
    cont.forEach(item => {
        console.log(item.teamName);
    });

});


'use strict';
 /*jslint node:true, browser:true, es6:true*/
const print = console.log
const E = {};
const lines = []
if (!process.env.JEST_WORKER_ID){
  const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
  rl.on('line', line => {
      lines.push(line);
  });
  rl.on('close', main)
}
let rli = 0;
function readline() {
    return lines[rli++];
}
const l = process.env.DEBUG ? console.log : ()=>{};

module.exports = E;

const ra = ()=>readline().split(' ').map(a=>+a)

const MOD = 1e9+7;

class SegmTree {

}

const calc = (n, arr)=>{
  let cnt = new Map();
  for (let a of arr)
    cnt.set(a, (cnt.get(a)||0)+1)
  let max = 0;
  for (let [k, v] of cnt){
    if (v>max){
      max = v;
    }
  }
  let ans = 0;
  let eq = max;
  let potential = 0;
  while (eq<n){
    if (potential==0){
      ans++;
      potential = eq;
    }
    potential--;
    ans++;
    eq++;
  }

  return ans;
};

function main() {
    let T = +readline()
    while (T--){
      let [n] = ra();
      let arr = ra();
      l('ans')
      print(calc(n, arr));
    }
}

E.calc = calc;

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    var n = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            n = lines[i];
        }else{
            var a = lines[i].split(' ').map(Number);
            var m = new Map();
            var max = 0;
            for(j = 0; j < n; j++){
                if(m.has(a[j])){
                    var temp = m.get(a[j]);
                    temp++;
                    m.set(a[j], temp);
                }else{
                    m.set(a[j], 1);
                }
            }
            for(var [key, value] of m){
                if(value > max){
                    max = value;
                }
            }
            var ans = 0;
            while(max < n){
                var c = Math.min(n - max, max);
                ans += 1 + c;
                max += c;
            }
            console.log(ans);
        }
    }
});

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
function readLine() {
    return inputString[currentLine++];
};
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    main();
    // cmd(not powershell): node cp.js < input.txt
});

function main() {
    let t = parseInt(readLine());
    while (t-- > 0) {
        console.log(solve());
    }
}
function solve() {
    let n = parseInt(readLine());
    let arr = readLine().split(" ");
    counter = 0;
    return solution(arr)
}
function solution(arr) {
    if (arr.length == 1) {
        return 0;
    }
    let same = true;
    for (let i = 0; i < arr.length; i++) {
        if (arr[0] != arr[i]) same = false;
    }
    if (same) {
        return 0;
    }
    let maxRep = -1;
    let map = new Map();
    for (const val of arr) {
        if (map.has(val)) map.set(val, map.get(val) + 1);
        else map.set(val, 1);
    }
    maxRep = Array.from(map.values()).sort((a, b) => a - b);
    maxRep = maxRep[maxRep.length - 1];
    let cnt = 0;
    while (maxRep !== arr.length) {
        let temp = Math.min(Math.abs(arr.length - maxRep), maxRep);
        cnt += 1 + temp
        maxRep += temp
    }
    return cnt;
}

var total = +readline();
while (total--) {
    var len = +readline();
    var map = new Map();
    readline().split(" ").map(Number).forEach(function (x) {
        if (map.has(x)) {
            map.set(x, map.get(x) + 1);
        } else {
            map.set(x, 1);
        }
    });
    var anst = 0;
    var val = -1;
    map.forEach(function (v, k) {
        if (v > val) {
            val = v;
            anst = k;
        }
    });
    var longest = val;
    var ans = 0;
    while (len > longest) {
        ans += 1 + longest;
        longest += longest;
    }
    ans += len - longest;
    print(ans);
}

const fs = require('fs')
const inputs = fs.readFileSync(0, 'utf-8').split('\n')

void (function main() {
  const _ = Number(inputs[0])
  let res = []
  for (let __ = 0; __ < _; __++) {
    let n = Number(inputs[__ * 2 + 1])
    const data = inputs[__ * 2 + 2].trim().split(' ')
    let map = new Map()
    for (let num of data) {
      if (!map.has(num)) map.set(num, 0)
      map.set(num, map.get(num) + 1)
    }

    let max = [...map.values()].sort((a, b) => b - a)[0]
    n -= max
    let ans = 0

    while (n > 0) {
      ans++
      ans += Math.min(max, n)
      n -= max
      max *= 2
    }
    res.push(ans)
  }
  console.log(res.join('\n'))
})()

const fs = require('fs')
const inputs = fs.readFileSync(0, 'utf-8').split('\n')

void (function main() {
  const _ = Number(inputs[0])
  let res = []
  for (let __ = 0; __ < _; __++) {
    let n = Number(inputs[__ * 2 + 1])
    const data = inputs[__ * 2 + 2].trim().split(' ').map(Number)
    const h = new Array(n).fill(-1),
      e = [],
      ne = [],
      d = new Array(n).fill(0)
    let idx = 0
    const add = (i, j) => {
      ;(e[idx] = j), (ne[idx] = h[i]), (h[i] = idx++), d[j]++
    }
    for (let i = 2; i <= n; i++) {
      add(data[i - 2] - 1, i - 1)
    }
    const queue = [0]
    const g = new Array(n).fill(0).map(() => [])
    for (let i of queue) {
      for (let k = h[i]; k !== -1; k = ne[k]) {
        const j = e[k]
        if (--d[j] === 0) {
          g[i].push(j)
          queue.push(j)
        }
      }
    }
    let hasSon = 0,
      maxSon = 0
    for (let children of g) {
      if (children.length) hasSon++
      maxSon = Math.max(maxSon, children.length)
    }

    maxSon -= hasSon + 1
    let ans = 1 + hasSon + Math.ceil(Math.max(maxSon, 0) / 2)
    res.push(ans)
  }

  console.log(res.join('\n'))
})()

const fs = require('fs')
const inputs = fs.readFileSync(0, 'utf-8').split('\n')

void (function main() {
  const _ = Number(inputs[0])
  let res = []
  for (let __ = 0; __ < _; __++) {
    let n = Number(inputs[__ * 2 + 1])
    const data = inputs[__ * 2 + 2].split(' ')
    let map = new Map()
    for (let num of data) {
      map.set(num, (map.get(num) || 0) + 1)
    }

    let max = [...map.values()].sort((a, b) => b - a)[0]
    n -= max
    let ans = 0
    while (n > 0) {
      ans++
      ans += Math.min(max, n)
      n -= max
      max *= 2
    }
    res.push(ans)
  }
  console.log(res.join('\n'))
})()


var result = '1';
var i = 1;
const numbers = readline().split(' ').map(function(v){return +v;});
const n = numbers[0];

function first() {
    while (result.length < n) {
        i = Number(!i);
        result += i;
    }
}

first();

print(result);

const numbers = readline().split(' ').map(function(v){return +v;});
const n = numbers[0];

var result = '1';
var i = 1;
while (result.length < n) {
    i = Number(!i);
    result += i;
}

print(result);


var n = parseInt(readline(), 10);
for(var i=1;i<=n;i++)
{
    var seq = readline().split(" ").map(function(x) { return parseInt(x); });
    var k=seq[0],x=seq[1];
    if(x==9)
        print(k*9);
    else
        print((k-1)*9+x);
}

'use strict';
const io = (function() {
  process.stdin.resume(); process.stdin.setEncoding('utf-8');
  let inputString = '', currentLine = 0, curTok = 0, input = [];
  function _check() { if (currentLine >= input.length) throw 'EOF!'; }
  process.stdin.on('data', data => { inputString += data; });
  process.stdin.on('end', _ => {
      for (const i of inputString.split('\n')) { input.push(i.split(' ')); }
      main();
  });
  function nextLine() {
    _check();
    const ret = input[currentLine++].slice(curTok).join(' ');
    curTok = 0;
    return ret;
  }
  function next() {
    _check();
    while (curTok == input[currentLine].length) {
      currentLine++;
      curTok = 0;
      _check()
    }
    return input[currentLine][curTok++];
  }
  function nextInt() { return parseInt(next()); }
  return {
    nextLine: nextLine,
    next: next,
    nextInt: nextInt,
  };
})();

const deal = () => {
  let k = io.nextInt();
  let x = io.nextInt();
  let ans = x + (k-1)*9;
  console.log(ans);
};

function main() {
  const n = io.nextInt();
  for (const i of Array(n).keys()) {
    deal();
  }
}

var qq = readline().split(" ").map(function(x) { return parseInt(x); });
//var numbers = prompt("Enter data: ").split(" ").map(function(x) { return parseInt(x); });   // Chrome run

var T = qq[0];
for (var i=0; i<T; i++) {
	qq = readline().split(" ").map(function(x) { return parseInt(x); });
	var K = qq[0];
	var DIG = qq[1];
	var res = (K-1)*9 + DIG;
	write(res,"\n");
}

(function() {
    var n = +readline();
    var r = '';
    for(var i = 0; i < n; i++) {
        var l = readline().split(' ');
        var k = +l[0];
        var x = +l[1];

        var d = 0;
        var arr = [x];
        var index = 0;

        while(arr.length < k) {
            for(var j = 0; j <=  arr.length; j++) {
                var newV  = arr[j] - d;
                if(newV != x && newV >= 0 && newV < 10) {
                    arr.push(+(d.toString() + newV));
                }
            }
            d++;
        }
        print(arr);
        r += arr[k - 1] + '\n';
    }
    print(r);

   // 2 11 20 29 38
   // 1 10 19 28 30
}());

(function() {
    var n = +readline();
    var r = '';
    for(var i = 0; i < n; i++) {
        var l = readline().split(' ');
        var k = +l[0];
        var x = +l[1];

        var d = 0;
        var arr = [x];
        var index = 0;

        while(arr.length < k) {
            for(var j = 0; j <=  arr.length; j++) {
                var newV  = arr[j] - d;
                if(newV != x && newV >= 0 && newV < 10) {
                    arr.push(+(d.toString() + newV));
                }
            }
            d++;
        }
        r += arr[k - 1] + '\n';
    }
    print(r);

   // 2 11 20 29 38
   // 1 10 19 28 30
}());

(function() {
    var q = +readline();
    var res = '';
    for(var i = 0; i < q; i++) {
        var t = readline().split(' ');
        res += t[1] + '\n'
    }
    print(res);
}());


function readStringArray() {
  return readline().split(" ");
}
function readNumArray() {
  return readStringArray().map(Number);
}

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var search = 'a'
    var len = +readline();
    var word = readline();
    while (word.indexOf(search) > -1) {
      search = updateSearch(search);
    }
    print(search);
  }
}

function updateSearch(str) {
  var result = '';
  var lastNotZ = -1;
  for (var k = str.length - 1; k > -1; k--) {
    if (str[k] !== 'z') {
      lastNotZ = k;
      break;
    }
  }
  if (lastNotZ > -1) {
    result = str.slice(0, lastNotZ) +
      String.fromCharCode(str.charCodeAt(lastNotZ) + 1);
    for (var k = lastNotZ + 1; k < str.length; k++) {
      result += 'a';
    }
  } else {
    for (var k = 0; k < str.length + 1; k++) {
      result += 'a';
    }
  }
  return result;
}
main();

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    let str = readline().trim().split("");
    let ans;
    let arr = new Array(26)
      .fill(97)
      .map((cur, ind) => String.fromCharCode(cur + ind));
    const subStr = (str, find) => {
      let flag = false;
      for (let i = 0; i < n; i++) {
        if (str[i] === find[0]) {
          flag = true;
          let j = i,
            k = 0;
          while (k < find.length) {
            if (find[k] !== str[j]) flag = false;
            k++;
            j++;
          }
          if (flag) {
            return false;
          }
        }
      }
      ans = find;
      return true;
    };
    const isPr = (str, find) => {
      let flag = true;
      for (let i = 0; i < 26; i++) {
        let k = find + arr[i];
        if (subStr(str, k)) return true;
      }
      return false;
    };
    if (isPr(str, "")) console.log(ans);
    else {
      let check = "";
      for (let i = 0; i < 27; i++) {
        let flag = false;
        for (let j = 0; j < 26; j++) {
          if (isPr(str, check + arr[j])) {
            flag = true;
            break;
          }
        }
        if (flag) break;
        check = arr[i];
      }
      console.log(ans);
    }
  }
};
solve();

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main()
});

function readline() {
  return inputString[currentLine++]
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  let testCases = readline()
  while(testCases--)
    solve()
}

// function to solve problems
function solve (){
  let n = readline()
  let str = readline()

  let substr = 'a',
    ansFound = 0
  while (ansFound != -1) {
    ansFound = str.indexOf(substr)
    if (ansFound != -1) {
      substr = getNextSubstring(substr)
    }
  }
  // console.log('==========\nANS = ', substr)
  console.log(substr)
}

function getNextSubstring (substr) {
  if (!substr) return 'a'
  // console.log('substr:', substr)
  let index = substr.length - 1,
    lastChar = substr[index]
    // console.log('index:', index)
    // console.log('lastChar:', lastChar)
  if (substr.charCodeAt(index) == 'z'.charCodeAt(0)) {
    // console.log('Inside if')
    return getNextSubstring(substr.substring(0, index)) + 'a'
  } else {
    return substr.substring(0, index) + String.fromCharCode(lastChar.charCodeAt(0) + 1)
  }
}

function sortAscending(a, b) {
  return a[0] - b[0]
}
// String.prototype.replaceAt = function (index, replacement) {
//   return this.substring(0, index) + replacement + this.substring(index + replacement.length)
// }

var timer = 0;
function dfs(v, prev) {
   var h = {};
   v.__h = h;
   h.tin = ++timer;
   h.up = [];
   var i = 0;
   var next = prev;
   while (next) {
      h.up[i] = next;
      next = next.__h.up[i++];
   }
   var children = v.childNodes;
   for (i = 0; i < children.length; i++) {
      dfs(children[i], v);
   }
   h.tout = ++timer;
}

function gcd(x, y) {
   if (y === 0) {
      return x;
   }
   return gcd(y, x % y);
}
var all = [];
var acode = 'a'.charCodeAt(0);
var zcode = 'z'.codePointAt(0);
var count = zcode - acode + 1;
for (var i = acode; i <= zcode; i++) {
   all.push(String.fromCharCode(i));
}
for (var i = 0; i < count; i++) {
   for (var j = 0; j < count; j++) {
      all.push(all[i] + all[j]);
   }
}
for (var i = 0; i < count; i++) {
   for (var j = 0; j < count; j++) {
      for (var k = 0; k < count; k++) {
         all.push(all[i] + all[j] + all[k]);
      }
   }
}

function solve() {
   read();
   var str = read();
   for (var i = 0; i < all.length; i++) {
      if (str.indexOf(all[i]) === -1) {
         write(all[i]);
         return;
      }
   }
}

function init() {
   var T;
   T = 1;
   T = Number(read());
   for (var t = 0; t < T; t++) {
      solve();
   }
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function readArray(f) {
   return read().split(' ').map(f);
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;

   var needWriteFile = false;

   var writeResult = '';
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   return isNode && MEMORY;
}

function readStringArray() {
  return readline().split(" ");
}
function readNumArray() {
  return readStringArray().map(Number);
}

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var search = 'a'
    var len = +readline();
    var word = readline();
    while (word.indexOf(search) > -1) {
      search = updateSearch(search);
    }
    print(search);
  }
}

function updateSearch(str) {
  var result = '';
  var lastNotZ = -1;
  for (var k = str.length - 1; k > -1; k--) {
    if (str[k] !== 'z') {
      lastNotZ = k;
      break;
    }
  }
  if (lastNotZ > -1) {
    result = str.slice(0, lastNotZ) +
      String.fromCharCode(str.charCodeAt(lastNotZ) + 1) +
      str.slice(lastNotZ + 1);
  } else {
    for (var k = 0; k < str.length + 1; k++) {
      result += 'a';
    }
  }
  return result;
}
main();


'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', function(inputStdin) {
    inputString += inputStdin;
});

process.stdin.on('end', function() {
    inputString = inputString.split('\n');

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function gcd(a,b )
{
    if (!b)
        return a

    return gcd( b , a%b )
}

function main() {

    let t = parseInt(readLine());

    //let mod = 10**9+7
    loopwhile:
    while(t--)
    {

        let n = parseInt(readLine());

        let s = readLine().trim().split(" ").map(x=>parseInt(x));

        let max = Math.max(...s)
        let index = s.indexOf(max)
        //console.log("index " + index)
        ///console.log("s.slice() " + s.slice())
        let copy = s.slice()
        copy.splice(index,1)
        //console.log("copy " +copy)
        let secondmax = Math.max(...copy)
        //console.log("secondmax " + secondmax)

        let line=""
        s[index] += max - secondmax
        for(let i=0;i<n;i++)
        {
            line+=(s[i]-max) + " "
        }
        console.log(line.trim())
    }
}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const n = +lines[l++]
        const arr = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(n, arr)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, arr) {
    const sorted = arr.map((x, i) => [x, i])
        .sort((a, b) => b[0] - a[0])
    const a = sorted[0][0]
    const b = sorted[1][0]
    const r = Array(n)
    // console.log(sorted, a)
    for (let i = 0; i < sorted.length; i++) {
        const [x, j] = sorted[i]
        if (x === a) {
            r[j] = a - b
        } else {
            r[j] = x - a
        }
    }
    return r.join(' ')
}

var t = +readline();

for(var i = 0; i< t; i ++) {

      var nums = [];
    var arr = readline()
    var arr = readline().split(' ').map((t) => +t)

    print(alphabet(arr).join(' '))

}

function alphabet(arr){

 var res = [];
    var max = Math.max(...arr);
    var count = 0;
    var second = -Infinity;
    for(var each of arr){
        if (max == each){
            count++;
        }else {
            second = Math.max(second,each);
        }
    };
    //
    if (count >= 2){
        for(var num of arr){
            res.push(num - max);
        }
    }else {
        for(var num of arr){
            if (num == max){
                res.push(num-second)
            }else {
                res.push(num-max)
            }
        }
    }

    return res;
}

t = +readline()

while(t--) {
    readline()
    s = readline().split(' ').map(value => +value)

    maxFirst = Math.max(...s)
    foundIndex = s.findIndex(value => value === maxFirst)
    maxSecond = Math.max(...[...s.slice(0, foundIndex), ...s.slice(foundIndex + 1, s.length)])

    difference = s.map((value, index) => {
        if (index === foundIndex) {
            return value - maxSecond
        }

        return value - maxFirst
    })

    print(difference.join(' '))
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function main(){
    const testNumbers = readline();

    for(let i = 0; i<testNumbers; i++){
        solve(parseInt(readline()), readline().split(" ").map(x=>parseInt(x)));
    }
}

function solve(size, input){
    let max=0, secondMax = 0;
    for (let i = 0; i<size; i++){
        if(input[i] >= max){
            secondMax = max;
            max = input[i];
        }

        if(secondMax <= input[i] && input[i] !== max){
            secondMax = input[i]
        }
    }
    let ans = "";
    for (let j = 0; j<size; j++){
        if(input[j] !== max){
            ans += `${input[j] - max}`;
        }else{
            ans += `${max-secondMax}`;
        }

        if(j !== size-1){
            ans += ' ';
        }
    }
    console.log(ans)
}

let buf='';

process.stdin.on('readable', function(){
    let chunk=process.stdin.read();
    if(chunk) buf+=chunk.toString();
})

process.stdin.on('end', function(){
    const {EOL}=require('os');
    let line=buf.split(EOL);
    let t=parseInt(line[0]);
    for(let _=1;_<=t;_++)
    {
        let n=parseInt(line[2*_-1]);
        let a=line[2*_].split(' ').map(x=>{return parseInt(x)});
        let b=[];
        for(let x of a) b.push(x);
        b.sort(function(a,b){
            return a-b;
        });
        // console.log(b);
        let ans='';
        for(let i=0;i<n;i++)
        {
            if(a[i]===b[n-1]) ans+=(a[i]-b[n-2])+' ';
            else ans+=(a[i]-b[n-1])+' ';
        }
        console.log(ans);
    }
})

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function main() {
    const testCases = Number(readline());
    for (let i = 0; i < testCases; i++) {
        let len = Number(readline());
        let arr = readline().split(" ").map(elem => Number(elem))
        console.log(calculateAdvantage(len, arr).join(" "))
    }
}

function calculateAdvantage(len, arr) {
    let arrcopy = [...arr]
    arrcopy.sort((a, b) => a - b)
    console.log()
    let max = arrcopy[len - 1]
    let ans = []
    for (let i = 0; i < len; i++) {
        if (arr[i] === max) {
            ans.push(max - arrcopy[len - 2])
        } else
            ans.push(arr[i] - max)
    }
    return ans
}

const fs = require("fs");
const input = fs.readFileSync(0, 'utf8').trim().split('\r\n');
let currentline = 0;
function readline(){
      return input[currentline++];
}
function alph() {
  var f = 'abcdefghijklmnopqrstuvwxyz';
  return f;
}
function Alph() {
  var f = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  return f;
}
function max(x,y) {
  return x >=y ? x : y;
}
function min(x,y) {
  return x <=y ? x : y;
}
function abs(x) {
  return x < 0 ? x*(-1) : x;
}
var T = readline();
var inf = 1000000000000;
for(var tc=1;tc<=T;tc++) {
	var n = readline();
	var a = readline().split(" ").map(w => parseInt(w));
	var b = [...a].sort((x,y) => y-x)
	var ans = []
	for(var i=0;i<n;i++) {
		if(a[i] == b[0]) ans[i] = a[i]-b[1];
		else ans[i] = a[i]-b[0]
	}
	console.log(ans.join(" "))
}

const readline = require('readline');
const { stdin: input, stdout: output } = require('process')
const rl = readline.createInterface({ input, output })

let lines = []

const createReadLine = () => {
  i = 0;
  return () => lines[i++]
}
const int = (num, radix=10) => parseInt(num, radix)

rl.on('line', line => lines.push(line))

rl.on("close", () => {
  const readLine = createReadLine();
  // const alphabet = "abcdefghijklmnopqrstuvwxyz".toUpperCase();
  let t = int(readLine());
  let alphabet = "abcdefghijklmnopqrstuvwxyz"
  while (t--) {
    let n = int(readLine());
    let arr = readLine().split(' ').map(a => int(a))
    // let maxx = Math.max(arr)
    let maxx = 0
    let prevmaxx = 0
    let cnt = -1
    let ans = ''
    for (let i = 0; i < n; i++) {
      if (arr[i] >= maxx) {
        prevmaxx = maxx
        maxx = arr[i]
      }
      else if (arr[i] > prevmaxx) {
        prevmaxx = arr[i]
      }
    }

    for (let i = 0; i < n; i++) {
      cnt += arr[i] == maxx ? 1 : 0
    }

    for (let i = 0; i < n; i++) {
      if (arr[i] == maxx) {
        if (!cnt) {
          ans += `${(arr[i] - prevmaxx)} `
        } else {
          ans += `0 `
        }
      }
      else {
        ans += `${(arr[i] - maxx)} `
      }
    }
    console.log(ans)
  }
});

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = nextLong();
		}else if(code == 'double'){
			ret[i] = nextDouble();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');} function nextDoubleArray(size){return nextArray(size, 'double');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());} function nextDouble(){return parseFloat(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	var alpha = "abcdefghijklmnopqrstuvwxyz";
	while(hasNext()){
		var N = nextInt();
		var list = nextIntArray(N);
		var map = getCountMap(list);
		var tmp = Array.from(new Set(makeClone(list)));
		tmp.sort(function(a,b){
			return b - a;
		});
		var max = tmp[0];
		var nx = tmp[0];
		if(tmp.length > 1){
			nx = tmp[1];
		}
		var output = new Array(N);
		for(var i = 0; i < N; i++){
			if(list[i] == max){
				if(map[list[i]] > 1){
					output[i] = 0;
				}else{
					output[i] = list[i] - nx;
				}
			}else{
				output[i] = list[i] - max;
			}
		}
		myout(myconv(output, 8));
	}
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function main(){
    const testNumbers = readline();

    for(let i = 0; i<testNumbers; i++){
        solve(parseInt(readline()), readline().split(" ").map(x=>parseInt(x)));
    }
}

function solve(size, input){
    let max=0, secondMax = 0;
    for (let i = 0; i<size; i++){
        if(input[i] >= max){
            secondMax = max;
            max = input[i];
        }
    }
    let ans = "";
    for (let j = 0; j<size; j++){
        if(input[j] !== max){
            ans += `${input[j] - max}`;
        }else{
            ans += `${max-secondMax}`;
        }

        if(j !== size-1){
            ans += ' ';
        }
    }
    console.log(ans)
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function main(){
    const testNumbers = readline();

    for(let i = 0; i<testNumbers; i++){
        solve(parseInt(readline()), readline().split(" ").map(x=>parseInt(x)));
    }
}

function solve(size, input){
    let max=0, secondMax = 0;
    for (let i = 0; i<size; i++){
        if(input[i] >= max){
            secondMax = max;
            max = input[i];
        }
    }
    let ans = "";
    for (let j = 0; j<size; j++){
        if(input[j] !== max){
            ans += `${input[j] - max}`;
        }else{
            ans += `${max-secondMax}`;
        }

        if(j !== size-1){
            ans += ' ';
        }
    }
}

let buf='';

process.stdin.on('readable', function(){
    let chunk=process.stdin.read();
    if(chunk) buf+=chunk.toString();
})

process.stdin.on('end', function(){
    const {EOL}=require('os');
    let line=buf.split(EOL);
    let t=parseInt(line[0]);
    for(let _=1;_<=t;_++)
    {
        let n=parseInt(line[2*_-1]);
        let a=line[2*_].split(' ').map(x=>{return parseInt(x)});
        let b=[];
        for(let x of a) b.push(x);
        // console.log(b);
        b.sort();
        let ans='';
        for(let i=0;i<n;i++)
        {
            if(a[i]===b[n-1]) ans+=(a[i]-b[n-2])+' ';
            else ans+=(a[i]-b[n-1])+' ';
        }
        console.log(ans);
    }
})

var t = +readline();

for(var i = 0; i< t; i ++) {

      var nums = [];
    var arr = readline()
    var arr = readline().split(' ').map((t) => +t)

    print(alphabet(arr))

}

function alphabet(arr){

 var res = [];
    var max = Math.max(...arr);
    var count = 0;
    var second = -Infinity;
    for(var each of arr){
        if (max == each){
            count++;
        }else {
            second = Math.max(second,each);
        }
    };
    //
    if (count >= 2){
        for(var num of arr){
            res.push(num - max);
        }
    }else {
        for(var num of arr){
            if (num == max){
                res.push(num-second)
            }else {
                res.push(num-max)
            }
        }
    }

    return res;
}

t = +readline()

while(t--) {
    readline()
    s = readline().split(' ').map(value => +value)

    maxFirst = Math.max(...s)
    foundIndex = s.findIndex(value => value === maxFirst)
    maxSecond = Math.max(...[...s.slice(0, foundIndex), ...s.slice(foundIndex + 1, s.length)])

    difference = s.map((value, index) => {
        if (index === foundIndex) {
            return value - maxSecond
        }

        return value - maxFirst
    })

    print(difference)
}


var nk = readline().split(' ').map(Number);
var robots = readline().split(' ').map(Number);

var n = nk[0];
var k = nk[1];

var array = [];
var m = 0;

for (var i = 0; i < n; i++) {
	m += i + 1;
	array[i] = m;
}

var index = 0;

for (var i = 0; i < array.length; i++) {
	if (k == 1) {
		index = 1;
		break;
	} else if (k <= array[i]) {
		index = (array[i] - array[i - 1]) - (array[i] - k);
		break;
	}
}

print(robots[index - 1]);

var firstLine = readline().split(' ');

var IDs = readline().split(' ');

var n = +firstLine[0];
var k = +firstLine[1];

var x = 0;
var max = 0;

for(var i = 1; i <= n; i ++) {
	x += i;
	if(x >= k) {
		max = i;
		break;
	}
}

var s = k - ((max*(max-1))/2);

print(IDs[s-1]);

var nk = readline().trim().split(' ').map((_x)=>parseInt(_x));
var n=nk[0],k=nk[1];
var t = readline().trim().split(' ').map((_x)=>parseInt(_x));

var m=0;
k--;
while(true){
    if(k>=(m*(m+1)/2) && k<((m+1)*(m+2)/2)){
        break;
    }
    m++;
}
var i = k-m*(m+1)/2

print(t[i]);

var meta = readline().split(" ");
    ids = readline().split(" ");

    k = meta[1];

var i = k, n = 1;

while (i > n) {
    i -= n++;
}

print(ids[i-1]);

var nk = readline().split(' ').map(Number);
var n = nk[0];
var k = nk[1];
var id = readline().split(' ').map(Number);

var s = Math.floor(Math.sqrt(k * 2));
while ((s + 1) * s / 2 >= k)
    s--;

print(id[k - 1 - (s + 1) * s / 2]);

var be = readline().split(' ');

var n = be[0];
var k = be[1];

var x = Math.floor(Math.sqrt(1/4+2*k) - 1/2);
var y = k - x*(x+1)/2;
if(y<=0) y = x;

print(readline().split(' ')[y-1]);

var nk = readline().split(' ').map(Number);
var robots = readline().split(' ').map(Number);

var n = nk[0];
var k = nk[1];

var array = [];
var m = 0;

for (var i = 0; i < n; i++) {
	m += i + 1;
	array[i] = m;
}

print(array);

var index = 0;

for (var i = 0; i < array.length; i++) {
	if (k == 1) {
		index = 1;
		break;
	} else if (k <= array[i]) {
		index = (array[i] - array[i - 1]) - (array[i] - k);
		break;
	}
}

print(robots[index - 1]);

var n = readline();
var k = readline();

var x = Math.floor(Math.sqrt(1+4*k)/2 - 1/2);
var y = k - x*(x+1);

for(var i=0; i<y; i++){
    var id = readline();
}
print(id);

var be = readline().split(' ');

var n = be[0];
var k = be[1];

var x = Math.floor(Math.sqrt(1+4*k)/2 - 1/2);
var y = k - x*(x+1)/2;
if(y===0) y = n;

print(readline().split(' ')[y-1]);

var be = readline().split(' ');

var n = be[0];
var k = be[1];

var x = Math.floor(Math.sqrt(1/4+2*k) - 1/2);
var y = k - x*(x+1)/2;
if(y===0) y = n;

print(readline().split(' ')[y-1]);

var n = readline();
var k = readline();

var x = Math.floor(Math.sqrt(1+4*k)/2 - 1/2);
var y = k - x*(x+1);

var id;
for(var i=0; i<y; i++){
    id = readline();
}
print(id);

var be = readline().split(' ');

var n = be[0];
var k = be[1];

var x = Math.floor(Math.sqrt(1+4*k)/2 - 1/2);
var y = k - x*(x+1);

print(readline().split(' ')[y-1]);


//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
	};
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	var output = new Array(t);
	for(var i = 0; i < t; i++){
		var one = nextIntArray();
		var a = one[0];
		var b = one[1];
		output[i] = a ^ b;
	}
	myout(myconv(output, 9));
}

function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b);
  if (b < a) return [];
  let arr = Array(b - a + 1)
  for (let i = a; i <= b; i++) arr[i - a] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.bin = function (comp, a, b) {
  let mid;
  while (a < b) {
    mid = (a + b) / 2 | 0;
    if (typeof comp == 'function' ? comp(this[mid]) : this[mid] < comp) a = mid + 1;
    else b = mid;
  }
  return a;
}
Array.prototype.cut = function (fn, a, b) {
  let arr = [];
  a = a || 0;
  b = b || (this.length - 1);
  let prev = a;
  for (let i = a; i <= b; i++) {
    if (i == b || fn(this[i], this[i + 1], i, this)) {
      arr.push(this.slice(prev, i + 1));
      prev = i + 1;
    }
  }
  return arr;
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
function inv(b, m) {
  for (var a = m, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + m) % m;
}

// let MOD = 1e9 + 7
// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[MOD % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

// let p = [2];
// for (let i = 3; i < 1e5; i += 2) {
//   let j, x = Math.sqrt(i);
//   for (j = 0; p[j] <= x; j++) if (i % p[j] == 0) break;
//   if (i % p[j] != 0) p.push(i);
// }

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }
// az = "abcdefghijklmnopqrstuvwxyz"

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
async function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, { min, max, ceil, floor, sqrt, abs, log2, hypot } = Math,
    bi = BigInt, rand = n => Math.random() * n | 0;

  let t = $()
  while (t--) {
    let [a, b] = $(2)
    log(a^b)
  }
}

const readline = require('readline').createInterface({
  input: process.stdin
});

let values = [];

readline.on('line', line => {
  values.push(line.split` `)
  // var [a,b] = line.split` `
  // console.log( a ^ b )
})
.on('close', () => {
  values = values.slice(1)
  for( var val in values ){
    console.log(values[val][0] ^ values[val][1])
  }
})

var tc = parseInt(readline());
while(tc--){
    var A1 = readline().split(' ').map(x => parseInt(x));

    var n = A1[0];
    var m = A1[1];
    print(n ^ m);
}

var c = +readline() + 1;
for (var i = 1; i < c; i++) {
    var line = readline().split(" ");
    print(line[0] ^ line[1]);
}

var tc = parseInt(readline());
for(; tc--; ){
    var Ar = readline().split(' ').map(x => parseInt(x));
    var a = Ar[0], b = Ar[1];
    print(a ^ b);
}

const solve = (a, b) => {
    let x = selectX(a, b)
    return (a ^ x) + (b ^ x);
};

const selectX = (A, B) => {
    let j = 0;
    let x = 0;
    while (A || B) {
        if ((A & 1) && (B & 1)) {
            x += (1 << j);
        }
        A >>= 1;
        B >>= 1;
        j += 1;
    }
    return x;
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(line.split(" ").map(x => Number(x)));
    });
    rl.on('close', () => {
        let t = Number(input[0][0]);
        let i = 1;
        while (t > 0) {
            let data = input.slice(i, i + 1);
            console.log(solve(data[0][0], data[0][1]));
            t--;
            i++;
        }
    });
};

main()

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}
function pow(base, n) {
  if (n === 0) return 1;
  let p = pow(base, Math.floor(n / 2));
  let res = mul(mod(p), mod(p));
  if (n % 2 === 1) res = mul(mod(res), base);
  return res;
}
function highestOneBit(i) {
  i |= i >> 1;
  i |= i >> 2;
  i |= i >> 4;
  i |= i >> 8;
  i |= i >> 16;
  return i - (i >>> 1);
}
function permutation(arr, len, store = "", permutations = []) {
  if (store.length === len) {
    permutations.push(store);
    return;
  }
  for (let i = 0; i < arr.length; i++) {
    const newArr = [...arr];
    const newChar = newArr.splice(i, 1);
    permutation(newArr, len, store.concat(newChar), permutations);
  }
  return permutations;
}

function main() {
  let t = +readLine();
  while (t--) {
    const [a, b] = readLine().split(" ").map(Number);
    console.log(a ^ (0 + b) ^ 0);
  }
}

//gets the x needed for smallest value
var findX = (a, b) => ((a + b) - (a ^ b)) / 2;

//note: I noticed the smallest value is the same as A and B varaibles xored
//computes the eqation
var result = (a, b, x) => (a ^ x) + (b ^ x);

function problem(a, b) {
    //same as a ^ b lol
    return result(a, b, findX(a, b));
}


var n = +readline();
var s = readline().split('');

var c = 0;

function getColor(l,r) {
    c++;
    return ['R','G','B'].filter(i => i != l && i != r)[0];
}

for(var i = 1; i < n; i++) {
    if(s[i] == s[i-1]) {
        s[i] = getColor(s[i-1], s[i+1]);
    }
}

print(c);
print(s.join(''));

var n = +readline();
var s = readline().split('');
var min = 0;
var color = ['R', 'G', 'B'];
for (var i=1; i<n; i++){
	if (s[i] == s[i-1])	{
		min++;
		for (var j=0; j<3; j++){
			if (color[j] != s[i-1] && color[j] != s[i+1]) s[i] = color[j];
		}
	}
}
print (min);
print (s.join(''));

 readline(); var prm = readline().split("");
var mx =0;
var st = "";

for(var i=0;i<prm.length-1;i++)
if(prm[i]===prm[i+1]){
		mx++;
		var s = "RGB".replace(prm[i],"");
		if(prm.length - i >= 3){s = s.replace(prm[i+2],"")}
		   prm[i+1] = s[0];}

print(mx);
print(prm.join(""))

var cnt = 0;
var str = "";
var readliner = require('readline');
var rl = readliner.createInterface(process.stdin, process.stdout, null);
rl.on('line', function (cmd) {
                  //console.log('You just typed: '+cmd);
                  cnt++;
                  if (cnt > 1) str = cmd;
              }).on('close', main);

function next_CH(x) {
	if (x === 'R') return 'B';
	if (x === 'B') return 'G';
	if (x === 'G') return 'R';
}

function main() {
	var res = [];
	res.push(str[0]);
	var cnt = 0;
	for (var i=1; i<str.length; i++)
		if (str[i] !== res[i-1])
			res.push(str[i]);
		else {
			cnt++;
			if (i === str.length-1) res.push(next_CH(res[i-1]));
			else {
				var x = next_CH(res[i-1]); var Q = 0;
				while (x === str[i+1] && Q < 5) {
					if (x === 'R') x = 'B';
					else if (x === 'B') x = 'G';
					else if (x === 'G') x = 'R';
					Q++;
				}
				res.push(x);
			}
		}
	console.log(cnt);
	process.stdout.write(res.join(''));

    //console.log(ans);
    //console.log(Q);

    //var x = 1.2345678;
    //console.log('x = ',Number(x).toFixed(5));

    process.exit(0);
}

//var lines = data.split(/\r?\n/);

var cnt = 0;
var str = "";
var readliner = require('readline');
var rl = readliner.createInterface(process.stdin, process.stdout, null);
rl.on('line', function (cmd) {
                  //console.log('You just typed: '+cmd);
                  cnt++;
                  if (cnt > 1) str = cmd;
              }).on('close', main);

function next_CH(x) {
	if (x === 'R') return 'B';
	if (x === 'B') return 'G';
	if (x === 'G') return 'R';
}

function main() {
	var res = [];
	res.push(str[0]);
	var cnt = 0;
	var N = str.length;
	for (var i=1; i<N; i++)
		if (str[i] !== res[i-1])
			res.push(str[i]);
		else {
			cnt++;
			if (i === N-1) res.push(next_CH(res[i-1]));
			else {
				var x = next_CH(res[i-1]); var Q = 0;
				while (x === str[i+1] && Q < 5) {
					if (x === 'R') x = 'B';
					else if (x === 'B') x = 'G';
					else if (x === 'G') x = 'R';
					Q++;
				}
				res.push(x);
			}
		}
	console.log(cnt);
	process.stdout.write(res.join(''));

    //console.log(ans);
    //console.log(Q);

    //var x = 1.2345678;
    //console.log('x = ',Number(x).toFixed(5));

    process.exit(0);
};

//var lines = data.split(/\r?\n/);

(()=>{"use strict";var t={675:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),Array.numbersMatrix=(t,e,r)=>{let n=[];null==t&&(e=t),null==r&&(r=0);for(let i=0;i<t;++i){let t=[];for(let n=0;n<e;++n)t.push(r);n.push(t)}return n},Array.prototype.sortAsc=function(){return this.sort(((t,e)=>t-e))},Array.prototype.sortDesc=function(){return this.sort(((t,e)=>e-t))},Array.prototype.max=function(){if(0==this.length)return 0;let t=this[0];for(let e=1;e<this.length;++e)t=Math.max(t,this[e]);return t},Array.prototype.min=function(){if(0==this.length)return 0;let t=this[0];for(let e=1;e<this.length;++e)t=Math.min(t,this[e]);return t},Array.prototype.sum=function(){let t=0;for(let e=0;e<this.length;++e)t+=this[e];return t},Array.prototype.modSum=function(t){let e=0;for(let r=0;r<this.length;++r)e+=this[r],e%=t;return e},Array.prototype.avg=function(){return this.sum()/this.length},Array.prototype.groupBy=function(t){let e=new Map;for(let r=0;r<this.length;++r){const n=t(this[r]);e.has(n)?e.get(n).push(this[r]):e.set(n,[this[r]])}return e},Array.prototype.deepCopy=function(){let t=[];if(0==this.length)return t;let e=!1;Array.isArray(this[0])&&(e=!0);for(let r=0;r<this.length;++r)e?t.push(this[r].deepCopy()):t.push(this[r]);return t},Array.prototype.transpose=function(){let t=[];if(0==this.length)return[[]];for(let e=0;e<this[0].length;++e){let r=[];for(let t=0;t<this.length;++t)r.push(this[t][e]);t.push(r)}return t},Array.prototype.toString=function(){if(0==this.length)return"";if(!Array.isArray(this[0]))return this.join(" ");let t="";for(let e=0;e<this.length;++e)t+=this[e].join(" "),e!=this.length-1&&(t+="\n");return t}},312:function(t,e,r){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(r(747));let s="",o=[],u=0,l="";const a="local"===process.argv[2],p=t=>{if(a){if(o=i.default.readFileSync("input.txt").toString().trim().split("\n").map((t=>t.trim())),t(),i.default.writeFileSync("output.txt",l),console.log(l),i.default.readFileSync("expected.txt").toString().trim()==l.trim()){const{exec:t}=r(129);t("osascript -e 'display notification \"✅ AC!!\"'")}}else process.stdin.resume(),process.stdin.setEncoding("utf-8"),process.stdin.on("data",(t=>{s+=t})),process.stdin.on("end",(e=>{o=s.trim().split("\n").map((t=>t.trim())),t(),console.log(l)}))};function f(){return o[u++]}function h(){return f().split(" ").map((t=>parseFloat(t)))}function c(){return f().split("")}e.default={runMain:p,runEachTest:t=>{p((()=>{let[e]=h();for(;e>0;)t(),e--}))},readline:f,nextNumbers:h,nextBigNumbers:function(){return f().split(" ").map((t=>BigInt(t)))},nextNumbersMatrix:function(t){let e=[];for(let r=0;r<t;++r)e.push(h());return e},nextCharacters:c,nextCharacterMatrix:function(t){let e=[];for(let r=0;r<t;++r)e.push(c());return e},nextIntervalArray:function(t){let e=[];for(let r=0;r<t;++r){const[t,r]=h();e.push({a:t,b:r})}return e},put:function(t){l+=t},puts:function(t){l+=t+"\n"},debug:function(t){a&&console.log(t)}}},965:function(t,e,r){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),r(675);const i=n(r(312));i.default.runMain((function(){let[t]=i.default.nextNumbers(),e=i.default.nextCharacters(),r=["R","G","B"],n=0;for(let i=1;i<t;++i)if(e[i]==e[i-1])if(n++,i==t-1)"R"==e[i]?e[i]="B":e[i]="R";else{let t=e[i-1]+e[i+1];e[i]=r.find((e=>!t.includes(e)))}i.default.puts(n),i.default.puts(e.join(""))}))},129:t=>{t.exports=require("child_process")},747:t=>{t.exports=require("fs")}},e={};!function r(n){if(e[n])return e[n].exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}(965)})();

// Solution written in typescript and compiled via webpack. Original source code below
// Happy Hacking 😜

// import './array'
//
// import io from './io'
//
// function main() {
//   let [n] = io.nextNumbers()
//   let s = io.nextCharacters()
//
//   let ss = ["R", "G", "B"]
//
//   let ch = 0
//
//   for (let i = 1; i < n; ++i) {
//     if (s[i] == s[i - 1]) {
//       ch++
//       if (i == n - 1) {
//         if (s[i] == "R") {
//           s[i] = "B"
//         } else {
//           s[i] = "R"
//         }
//       } else {
//         let b = s[i - 1] + s[i + 1]
//
//         s[i] = ss.find((x) => !b.includes(x))
//       }
//     }
//   }
//
//   io.puts(ch)
//   io.puts(s.join(""))
// }
//
// // io.runEachTest(main)
// io.runMain(main)

var x = parseInt(readline());

var seq = readline().split('');
var count=0;
for(var i=0; i<seq.length-1; i++){
  if(x===1) break;
  else{
    if(seq[i] === seq[i+1]){
      count++;
      if(x===2){
        if(seq[i]!=='R') seq[i+1]='R';
        else if(seq[i]!=='B') seq[i+1]='B';
        else seq[i+1]='G';
        break;
      }else{
        if(seq[i]!=='R' && seq[i+2]!=='R')
          seq[i+1]='R';
        else if(seq[i]!=='G' && seq[i+2]!=='G')
          seq[i+1]='G';
        else
          seq[i+1]='B';
      }
    }
  }
}

print(count);
print(seq.join(''));

function main(n,str){

      var cnt = 0;
      var s = [];
      var printer = '';

      for(var i = 0 ; i < n ; i++)s[i] = str[i];

      for(var i = 1 ; i < n ; i++){
        if(s[i] === s[i-1]){

          cnt++;

          if(s[i] === "R"){
            if(s[i+1] === "B"){
              s[i] = "G";
            }
            else if(s[i+1] === "G"){
              s[i] = "B";
            }
            else s[i] = 'B';
          }
          else if(s[i] === "G"){
            if(s[i+1] === "B"){
              s[i] = "R";
            }
            else if(s[i+1] === "R"){
              s[i] = "B";
            }
            else s[i] = "R";
          }
          else{
            if(s[i+1] === "R"){
              s[i] = "G";
            }
            else if(s[i+1] === "G"){
              s[i] = "R";
            }
            else s[i] = "R";
          }
        }
      }
      print(cnt);

      for(var i = 0 ; i < s.length ; i++)printer += s[i];

      print(printer);
}

var n = parseInt(readline());
var str = readline();

//for(var i = 0 ; i < arr.length ; i++)arr[i] = parseInt(arr[i]);

main(n,str);

var x = readline();var prm = readline();

prm = prm.replace(/RR/g,"").replace(/GG/g,"").replace(/BB/g,"");
var st = "";
var mx = (x - prm.length )/2
if(mx>0){
 for(var i=0;i<x;i+=2){st+="RG"}
if(prm.length%2!=0){st =st.slice(0,st.length-1)}
}else{st=prm}

print(mx);print(st);

		readline();var input = readline().split("");var maxx =0;var st = "";
for(var i=0;i<input.length-1;i++){
	if(input[i]===input[i+1]){
		maxx++;
		var s = "RGB".replace(input[i],"")
		if(i>0){s = s.replace(input[i-1],"")}
			input[1+i]=s[0];
	}
}

print(maxx);print(input);