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

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  const arr = d.split(' ').map(Number);

  let one = 0;
  let two = 0;

  for (let i = 0; i < arr.length; i++) {
    if (arr[i] === 0) {
      two = i + 1;
    }
    else {
      one = i + 1;
    }
  }

  if (one > two) {
    one = two;
  }

  console.log(one);

  c++;
});

const readline = require('readline');

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

function readLines(number, cb) {
    const lines = [];
    rl.on('line', function(line) {
        lines.push(line);
        if (lines.length === number) {
            rl.close();
            cb(lines);
        }
    });
};

function doIt(lines) {
    const n = parseInt(lines[0]);
    const doors = lines[1].split(" ").map(x => parseInt(x));
    const lastDoor = doors[n-1];
    for (let i = n-2; i >=0; i--) {
        if (lastDoor!==doors[i]) {
            console.log(i+1);
            return;
        }
    }
}

readLines(2, doIt);

//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 N = nextInt();
	var list = nextIntArray();
	var one = 0;
	var two = 0;
	for(var i = 0; i < N; i++){
		if(list[i] == 0){
			one++;
		}else{
			two++;
		}
	}
	for(var i = 0; i < N; i++){
		if(list[i] == 0){
			one--;
		}else{
			two--;
		}
		if(one == 0 || two == 0){
			myout(i + 1);
			return;
		}
	}
}

let input = [];

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

RL.on('line', (line) => {
    input.push(line);
});

RL.on('close', () => {
    let {0:n, 1:m} = {...input[0].split(' ')};
    n = parseInt(n); m = parseInt(m);

    let lastLeft = 0, lastRight = 0;
    let countLeft = 0, countRight = 0;
    input[1].split(' ').forEach( (i, j) => {
        i = parseInt(i);
        if (i === 1){
            countRight++; lastRight = j;
        } else {
            countLeft++; lastLeft = j;
        }
    });

    console.log( (lastLeft > lastRight) ? lastRight+1 : lastLeft+1);
});

var n = readline().split(" ");
var d = readline().split(" ");

var totalL = 0;
var totalR = 0;
var countL = 0;
var countR = 0;

for(var i = 0 ; i < n; i++) {
    if (d[i] == 0) {
        totalL++;
    }
}

totalR = n-totalL;

for(var i = 0 ; i < n; i++) {
    if (d[i] == 0) {
        countL++;
    } else
        countR++;
    if (countL == totalL || countR == totalR) {
        print(i+1);
        break;
    }
}

readline();
var doors = readline().split(' ').map(function(num) {
  return parseInt(num);
})

// var doors = [1,1,0]

var seq = doors[doors.length-1]

function main() {
  for (var i = doors.length-1; i > -1; i--) {
    if (doors[i] !== seq)
      return write(i + 1 + '');
  }
  write(doors.length)
}

main();

const readline = require('readline')

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

rl.question('', ans => {
  const n = Number(ans)
  rl.question('', ans2 => {
    rl.close()

    const doors = ans2.split(' ').map(x => Number(x))

    const lDoor = doors[doors.length - 1]
    for (let i = doors.length - 2; i >= 0; i--) {
      if (doors[i] !== lDoor) {
        console.log(i + 1)
        break
      }
    }
  })
})

var len = parseInt(readline());
var doorArr = readline().split(' ').map(_=>{return parseInt(_)});

var rightIndex = 1;
var leftIndex = 1;
for (var index = 0;index < doorArr.length;index ++)  {
    if (doorArr[index] == 0) {
        leftIndex = index + 1;
    } else if (doorArr[index] == 1) {
        rightIndex = index + 1;
    }

}
var result = rightIndex < leftIndex ? rightIndex : leftIndex;
print(parseInt(result));

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

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  const arr = d.split(' ').map(Number);

  let ans = 0;
  let idx = arr.indexOf(1);
  let idxLast = arr.lastIndexOf(1);

  if (idx === idxLast) {
    ans = idx + 1;
  }
  else {
    ans = idxLast - idx;
  }

  console.log(ans);

  c++;
});

const readline = require('readline')

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

rl.question('', ans => {
  const n = Number(ans)
  rl.question('', ans2 => {
    rl.close()

    const doors = ans2.split(' ').map(x => Number(x))

    const max = Math.floor(n/2)
    const min = {
      l: 0,
      r: 0
    }

    for (let i = 0; i < doors.length; i++) {
      item = doors[i]
      if (item === 0) { min.l += 1 }
      if (item === 1) { min.r += 1 }

      if ((min.l === max || min.r === max) && (min.l + min.r > max)) {
        console.log(min.l + min.r)
        break
      }
    }
  })
})

const readline = require('readline')

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

rl.question('', ans => {
  const n = Number(ans)
  rl.question('', ans2 => {
    rl.close()

    const doors = ans2.split(' ').map(x => Number(x))

    const max = Math.floor(n/2)
    const min = {
      l: 0,
      r: 0
    }

    for (let i = 0; i < doors.length; i++) {
      item = doors[i]
      if (item === 0) { min.l += 1 }
      if (item === 1) { min.r += 1 }
      // console.log(min.l, min.r, (min.l >= max || min.r >= max), ((min.l + min.r) > max))
      if ((min.l >= max || min.r >= max) && ((min.l + min.r) > max)) {
        console.log(min.l + min.r)
        break
      }
    }
  })
})

const readline = require('readline')

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

rl.question('', ans => {
  const n = Number(ans)
  rl.question('', ans2 => {
    rl.close()

    const doors = ans2.split(' ').map(x => Number(x))

    const max = Math.ceil(n/2)
    const min = {
      l: 0,
      r: 0
    }

    for (let i = 0; i < doors.length; i++) {
      item = doors[i]
      if (item === 0) min.l += 1
      if (item === 1) min.r += 1

      if (min.l === max || min.r === max) {
        console.log(min.l + min.r)
        break
      }
    }
  })
})

// readline();
// var doors = readline().split(' ').map(function(num) {
//   return parseInt(num);
// })

var doors = [1,1,0]

var seq = doors[doors.length-1]

function main() {
  for (var i = doors.length-1; i > -1; i--) {
    if (doors[i] !== seq)
      return write(i + 1 + '');
  }
  write(doors.length)
}

main();

var len = parseInt(readline());
var doorArr = readline().split('').map(_=>{return parseInt(_)});

var rightIndex = 1;
var leftIndex = 1;
for (var index = 0;index < doorArr.length;index ++)  {
    if (doorArr[index] == 0) {
        leftIndex = index + 1;
    } else if (doorArr[index] == 1) {
        rightIndex = index + 1;
    }

}
var result = rightIndex < leftIndex ? rightIndex : leftIndex;
print(parseInt(result));

var len = parseInt(readline());
var doorArr = readline().split('').map(_=>{return parseInt(_)});

var rightIndex = 1;
var leftIndex = 1;
for (var index = 0;index < len;index ++)  {
    if (doorArr[index] == 0) {
        leftIndex ++;
    } else if (doorArr[index] == 1) {
        rightIndex ++;
    }

}
var result = rightIndex > leftIndex ? rightIndex : leftIndex;
print(parseInt(result));

var len = parseInt(readline());
var doorArr = readline().split('').map(_=>{return parseInt(_)});

var rightIndex = 1;
var leftIndex = 1;
for (var index = 0;index < len;index ++)  {
    if (doorArr[index] == 0) {
        leftIndex = index + 1;
    } else if (doorArr[index] == 1) {
        rightIndex = index + 1;
    }

}
var result = rightIndex < leftIndex ? rightIndex : leftIndex;
print(parseInt(result));

 var len = parseInt(readline());
var doorArr = readline().split('').map(_=>{return parseInt(_)});

var rightIndex = 1;
var leftIndex = 1;
for (var index = 0;index < len;index ++)  {
    if (doorArr[index] == 0) {
        leftIndex ++;
    } else if (doorArr[index] == 1) {
        rightIndex ++;
    }

}
print(rightIndex > leftIndex ? rightIndex : leftIndex);

var len = parseInt(readline());
var doorArr = readline().split('').map(_=>{return parseInt(_)});

var rightIndex = 1;
var leftIndex = 1;
for (var index = 0;index < len;index ++)  {
    if (doorArr[index] == 0) {
        leftIndex = index + 1;
    } else if (doorArr[index] == 1) {
        rightIndex = index + 1;
    }

}
var result = rightIndex > leftIndex ? rightIndex : leftIndex;
print(parseInt(result));


var system,
  input,
  answer,
  hh,
  mm;

system = parseInt( readline(), 10 );
input = readline();
hh = parseInt( input.slice( 0, 2 ), 10 );
mm = parseInt( input.slice( 3 ), 10 );

if ( system == 12 ) {
  if ( hh === 0 ) {
    hh = 1;
  } else if ( hh > 12 ) {
    if ( hh % 10 !== 0 ) {
      hh = hh % 10;
    } else {
      hh = 10;
    }
  }
} else {
  if ( hh > 23 ) {
    hh = hh % 10;
  }
}
if ( mm > 59 ) {
  mm = mm % 10;
}

answer = "";
if ( hh.toString().length === 1 ) {
 answer += 0;
}
answer += hh + ":";
if ( mm.toString().length === 1 ) {
 answer += 0;
}
answer += mm;

print( answer );

var format = parseInt(readline()),
    times = readline().split(':'),
    hh = times[0],
    mm = times[1];

// 1. correct hours
if (format === 12) {
  if (hh === '00') hh = '01';
  else if (parseInt(hh) > 12) {
    //debugger;
    // a. Fix 1 number
    // if (hh[0] === '1') hh = hh[0] + 0;
    // else if (parseInt(hh[1]) <= 2) hh = 1 + hh[1];
    // // b. Fix 2 numbers
    // else hh = '01';
    hh = hh[1] !== '0' ? 0 + hh[1] : '10';
  }
} else if (format === 24 && parseInt(hh) > 23) {
  // a. Fix 1 number
  hh = 0 + hh[1];
}

// 2. Correct minutes
if (parseInt(mm) > 59) {
  mm = 0 + mm[1];
}

print(hh + ':' + mm);

//var arr = [{format: 24, value: '17:30'},{format: 12, value: '17:30'},{format: 24, value: '99:99'}];

function solve(obj){
	var ret = '';
	var str = obj.value;
	if(obj.format == 24){
		if((Number(str.charAt(0)) > 2) || ((Number(str.charAt(0)) == 2) && (Number(str.charAt(1)) > 3)))
			ret = '0' + str.charAt(1);
		else ret = str.substr(0, 2);
	}
	else if(obj.format == 12){
		if((Number(str.charAt(0)) == 0) && (Number(str.charAt(1)) == 0))
			ret = '10';
		else if((Number(str.charAt(0)) > 1) || ((Number(str.charAt(0)) == 1) && (Number(str.charAt(1)) > 2))){
			if(Number(str.charAt(1)) < 2) ret = '1';
			else ret = '0';
			ret = ret + str.charAt(1);
		}
		else ret = str.substr(0, 2);
	}
	ret = ret + ':';
	if(Number(str.charAt(3)) > 5){
		ret = ret + '0' + str.charAt(4);
	}
	else ret = ret + str.substr(3, 2);

	return ret;
}

var fmt = readline();
var val = readline();
var objetao = {format: Number(fmt), value: String(val)};
print(solve(objetao));

var format = parseInt(readline());
var clock = readline().replace(':', '').split('').map(Number);

// adjust clock
if(format === 12) {

    if(clock[0] === 0 && clock[1] === 0) {
        clock[1] = 1;
    } else if(clock[0] === 1 && clock[1] > 2) {
        clock[1] = 2;
    } else if(clock[0] > 1 && clock[1] !== 0) {
        clock[0] = 0;
    } else if(clock[0] > 1 && clock[1] === 0) {
        clock[0] = 1;
    }
}

if(format === 24) {

    if(clock[0] === 2 && clock[1] > 3) {
        clock[1] = 3;
    } else if(clock[0] > 2) {
        clock[0] = 0;
    }
}

// adjust minutes
if(clock[2] > 5) {
    clock[2] = 5;
}

print(clock[0] + '' + clock[1] + ':' + clock[2] + '' + clock[3]);

//Input

// var firstLine = "24" ; var secondLine = "17:30";     // pe: 17:30 (no changes)
// var firstLine = "12" ; var secondLine = "17:30";     // pe: 07:30 (1 change)
// var firstLine = "24" ; var secondLine = "99:99";     // pe: 19:19 (2 changes)
// var firstLine = "12" ; var  secondLine = "00:05";     // pe: 01:05 (1 changes)
// var firstLine = "12" ; var secondLine = "90:32";     // pe: 10:32 (1 changes)
// var firstLine = "12" ; var secondLine = "20:00";     // pe: 10:00 (1 changes)

var firstLine = readline(); var secondLine = readline();

retorno = eval(firstLine, secondLine);

//Solution
function eval(firstLine, secondLine){
    var format = firstLine;
    var hourMin = secondLine;

    write(correctTime(format, hourMin));
    // console.log(correctTime(format, hourMin));
    // return "Hola";
};

function correctTime(format, hourMin){
    //console.log( parseInt(hourMin.slice(3,5)) > 59 );
    if(parseInt(hourMin.slice(3,5)) > 59){
        hourMin = hourMin.slice(0, 3) + "1" + hourMin[4];
    };

    //if(format == "24" && parseInt(hourMin.slice(0,2)) > 23 ){
    if( parseInt(hourMin.slice(0,2)) > 23 ){
        if(hourMin[1] != "0"){
            hourMin = "1" + hourMin.slice(1, 5);
        }else{
            hourMin = "10" + hourMin.slice(2, 5);
        };
    };

    if (format == "12" && parseInt(hourMin.slice(0,2)) > 12){

        //hourMin = "0" + hourMin.slice(1, 5);
        if(hourMin[1] != "0"){
            hourMin = "0" + hourMin.slice(1, 5);
        }else{
            hourMin = "10" + hourMin.slice(2, 5);
        };

    };

    if (format == "12" && (hourMin.slice(0,2)) == "00"){
        hourMin = "01" + hourMin.slice(2, 5);
    };

    //console.log("hourMin: " + hourMin);
    return hourMin;
};

//Input

// var firstLine = "24" ; var secondLine = "17:30";     // pe: 17:30 (no changes)
// var firstLine = "12" ; var secondLine = "07:30";     // pe: 17:30 (1 change)
// var firstLine = "24" ; var secondLine = "99:99";     // pe: 09:09 (2 changes)

var firstLine = readline(); var secondLine = readline();

retorno = eval(firstLine, secondLine);

//Solution
function eval(firstLine, secondLine){
    var format = firstLine;
    var hourMin = secondLine;

    write(correctTime(format, hourMin));
    // console.log(correctTime(format, hourMin));
    // return "Hola";
};

function correctTime(format, hourMin){
    //console.log( parseInt(hourMin.slice(3,5)) > 59 );
    if(parseInt(hourMin.slice(3,5)) > 59){
        hourMin = hourMin.slice(0, 3) + "1" + hourMin[4];
    };
    //console.log("hourMin: " + hourMin);
    //console.log( parseInt(hourMin.slice(0,2)) > 23 );

    if(format == "24" && parseInt(hourMin.slice(0,2)) > 23 ){
        hourMin = "1" + hourMin.slice(1, 5);
    } else if (format == "12" && parseInt(hourMin.slice(0,2)) > 12){
        hourMin = "0" + hourMin.slice(1, 5);
    };
    //console.log("hourMin: " + hourMin);
    return hourMin;
};

//Input

// var firstLine = "24" ; var secondLine = "17:30";     // pe: 17:30 (no changes)
// var firstLine = "12" ; var secondLine = "07:30";     // pe: 17:30 (1 change)
// var firstLine = "24" ; var secondLine = "99:99";     // pe: 09:09 (2 changes)
// var firstLine = "12" ; var secondLine = "00:05";     // pe: 01:05 (1 changes)

var firstLine = readline(); var secondLine = readline();

retorno = eval(firstLine, secondLine);

//Solution
function eval(firstLine, secondLine){
    var format = firstLine;
    var hourMin = secondLine;

    write(correctTime(format, hourMin));
    // console.log(correctTime(format, hourMin));
    // return "Hola";
};

function correctTime(format, hourMin){
    //console.log( parseInt(hourMin.slice(3,5)) > 59 );
    if(parseInt(hourMin.slice(3,5)) > 59){
        hourMin = hourMin.slice(0, 3) + "1" + hourMin[4];
    };
    //console.log("hourMin: " + hourMin);
    //console.log( parseInt(hourMin.slice(0,2)) > 23 );

    if(format == "24" && parseInt(hourMin.slice(0,2)) > 23 ){
        hourMin = "1" + hourMin.slice(1, 5);
    };
    if (format == "12" && parseInt(hourMin.slice(0,2)) > 12){
        hourMin = "0" + hourMin.slice(1, 5);
    };
    if (format == "12" && (hourMin.slice(0,2)) == "00"){
        hourMin = "01" + hourMin.slice(2, 5);
    };
    //console.log("hourMin: " + hourMin);
    return hourMin;
};

//Input

// var firstLine = "24" ; var secondLine = "17:30";     // pe: 17:30 (no changes)
// var firstLine = "12" ; var secondLine = "17:30";     // pe: 07:30 (1 change)
// var firstLine = "24" ; var secondLine = "99:99";     // pe: 19:19 (2 changes)
// var firstLine = "12" ; var  secondLine = "00:05";     // pe: 01:05 (1 changes)
// var firstLine = "12" ; var secondLine = "90:32";     // pe: 10:32 (1 changes)
// var firstLine = "12" ; var secondLine = "20:00";     // pe: 01:00 (1 changes)

var firstLine = readline(); var secondLine = readline();

retorno = eval(firstLine, secondLine);

//Solution
function eval(firstLine, secondLine){
    var format = firstLine;
    var hourMin = secondLine;

    write(correctTime(format, hourMin));
    // console.log(correctTime(format, hourMin));
    // return "Hola";
};

function correctTime(format, hourMin){
    //console.log( parseInt(hourMin.slice(3,5)) > 59 );
    if(parseInt(hourMin.slice(3,5)) > 59){
        hourMin = hourMin.slice(0, 3) + "1" + hourMin[4];
    };
    //console.log("hourMin: " + hourMin);
    //console.log( parseInt(hourMin.slice(0,2)) > 23 );

    //if(format == "24" && parseInt(hourMin.slice(0,2)) > 23 ){
    if( parseInt(hourMin.slice(0,2)) > 23 ){
        if(hourMin[1] != "0"){
            hourMin = "1" + hourMin.slice(1, 5);
        }else{
            hourMin = "01" + hourMin.slice(2, 5);
        };
    };
    if (format == "12" && parseInt(hourMin.slice(0,2)) > 12){
        hourMin = "0" + hourMin.slice(1, 5);
    };
    if (format == "12" && (hourMin.slice(0,2)) == "00"){
        hourMin = "01" + hourMin.slice(2, 5);
    };
    //console.log("hourMin: " + hourMin);
    return hourMin;
};

//Input

// var firstLine = "24" ; var secondLine = "17:30";     // pe: 17:30 (no changes)
// var firstLine = "12" ; var secondLine = "17:30";     // pe: 07:30 (1 change)
// var firstLine = "24" ; var secondLine = "99:99";     // pe: 19:19 (2 changes)
// var firstLine = "12" ; var  secondLine = "00:05";     // pe: 01:05 (1 changes)
// var firstLine = "12" ; var secondLine = "90:32";     // pe: 10:32 (1 changes)
// var firstLine = "12" ; var secondLine = "20:00";     // pe: 01:00 (1 changes)

var firstLine = readline(); var secondLine = readline();

retorno = eval(firstLine, secondLine);

//Solution
function eval(firstLine, secondLine){
    var format = firstLine;
    var hourMin = secondLine;

    write(correctTime(format, hourMin));
    // console.log(correctTime(format, hourMin));
    // return "Hola";
};

function correctTime(format, hourMin){
    //console.log( parseInt(hourMin.slice(3,5)) > 59 );
    if(parseInt(hourMin.slice(3,5)) > 59){
        hourMin = hourMin.slice(0, 3) + "1" + hourMin[4];
    };

    //if(format == "24" && parseInt(hourMin.slice(0,2)) > 23 ){
    if( parseInt(hourMin.slice(0,2)) > 23 ){
        if(hourMin[1] != "0"){
            hourMin = "1" + hourMin.slice(1, 5);
        }else{
            hourMin = "10" + hourMin.slice(2, 5);
        };
    };

    if (format == "12" && parseInt(hourMin.slice(0,2)) > 12){
        hourMin = "0" + hourMin.slice(1, 5);
    };

    if (format == "12" && (hourMin.slice(0,2)) == "00"){
        hourMin = "01" + hourMin.slice(2, 5);
    };

    //console.log("hourMin: " + hourMin);
    return hourMin;
};

//Input

// var firstLine = "24" ; var secondLine = "17:30";     // pe: 17:30 (no changes)
// var firstLine = "12" ; var secondLine = "07:30";     // pe: 17:30 (1 change)
// var firstLine = "24" ; var secondLine = "99:99";     // pe: 09:09 (2 changes)

var firstLine = readline(); var secondLine = readline();

retorno = eval(firstLine, secondLine);

//Solution
function eval(firstLine, secondLine){
    var format = firstLine;
    var hourMin = secondLine;

    write(correctTime(format, hourMin));
    // console.log(correctTime(format, hourMin));
    // return "Hola";
};

function correctTime(format, hourMin){
    //console.log( parseInt(hourMin.slice(3,5)) > 59 );
    if(parseInt(hourMin.slice(3,5)) > 59){
        hourMin = hourMin.slice(0, 3) + "1" + hourMin[4];
    };
    //console.log("hourMin: " + hourMin);
    //console.log( parseInt(hourMin.slice(0,2)) > 23 );

    format = "12";
    if(format == "24" && parseInt(hourMin.slice(0,2)) > 23 ){
        hourMin = "1" + hourMin.slice(1, 5);
    } else if (format == "12" && parseInt(hourMin.slice(0,2)) > 12){
        hourMin = "0" + hourMin.slice(1, 5);
    };
    //console.log("hourMin: " + hourMin);

    return hourMin;
};

//Input

// var firstLine = "24" ; var secondLine = "17:30";     // pe: 17:30 (no changes)
// var firstLine = "12" ; var secondLine = "07:30";     // pe: 17:30 (1 change)
// var firstLine = "24" ; var secondLine = "99:99";     // pe: 09:09 (2 changes)
// var firstLine = "12" ; var secondLine = "00:05";     // pe: 01:05 (1 changes)
// var firstLine = "12" ; var secondLine = "90:32";     // pe: 10:32 (1 changes)

var firstLine = readline(); var secondLine = readline();

retorno = eval(firstLine, secondLine);

//Solution
function eval(firstLine, secondLine){
    var format = firstLine;
    var hourMin = secondLine;

    write(correctTime(format, hourMin));
    // console.log(correctTime(format, hourMin));
    // return "Hola";
};

function correctTime(format, hourMin){
    //console.log( parseInt(hourMin.slice(3,5)) > 59 );
    if(parseInt(hourMin.slice(3,5)) > 59){
        hourMin = hourMin.slice(0, 3) + "1" + hourMin[4];
    };
    //console.log("hourMin: " + hourMin);
    //console.log( parseInt(hourMin.slice(0,2)) > 23 );

    //if(format == "24" && parseInt(hourMin.slice(0,2)) > 23 ){
    if( parseInt(hourMin.slice(0,2)) > 23 ){
        hourMin = "1" + hourMin.slice(1, 5);
    };
    if (format == "12" && parseInt(hourMin.slice(0,2)) > 12){
        hourMin = "0" + hourMin.slice(1, 5);
    };
    if (format == "12" && (hourMin.slice(0,2)) == "00"){
        hourMin = "01" + hourMin.slice(2, 5);
    };
    //console.log("hourMin: " + hourMin);
    return hourMin;
};

var format = parseInt(readline()),
    times = readline().split(':'),
    hh = times[0],
    mm = times[1];

// 1. correct hours
if (format === 12) {
  if (hh === '00') hh = '01';
  else if (parseInt(hh) > 12) {
    //debugger;
    // a. Fix 1 number
    // if (hh[0] === '1') hh = hh[0] + 0;
    // else if (parseInt(hh[1]) <= 2) hh = 1 + hh[1];
    // // b. Fix 2 numbers
    // else hh = '01';
    hh = 0 + hh[1];
  }
} else if (format === 24 && parseInt(hh) > 23) {
  // a. Fix 1 number
  hh = 0 + hh[1];
}

// 2. Correct minutes
if (parseInt(mm) > 59) {
  mm = 0 + mm[1];
}

print(hh + ':' + mm);

var format = parseInt(readline()),
    times = readline().split(':'),
    hh = times[0],
    mm = times[1];

// 1. correct hours
if (format === 12) {
  if (hh === '00') hh = '01';
  else if (parseInt(hh) > 12) {
    //debugger;
    // a. Fix 1 number
    if (hh[0] === '1') hh = hh[0] + 0;
    else if (parseInt(hh[1]) <= 2) hh = 1 + hh[1];
    // b. Fix 2 numbers
    else hh = '01';
  }
} else if (format === 24 && parseInt(hh) > 23) {
  // a. Fix 1 number
  hh = 0 + hh[1];
}

// 2. Correct minutes
if (parseInt(mm) > 59) {
  mm = 0 + mm[1];
}

print(hh + ':' + mm);

//var arr = [{format: 24, value: '17:30'},{format: 12, value: '17:30'},{format: 24, value: '99:99'}];

function solve(obj){
	var ret = 0;
	var str = obj.value;
	if(obj.format == 24){
		if((Number(str.charAt(0)) > 2) || ((Number(str.charAt(0)) == 2) && (Number(str.charAt(1)) > 3)))
			ret = '0' + str.charAt(1);
		else ret = str.substr(0, 2);
	}
	else if(obj.format == 12){
		if((Number(str.charAt(0)) == 0) && (Number(str.charAt(1)) == 0))
			ret = '10';
		else if((Number(str.charAt(0)) > 1) || ((Number(str.charAt(0)) == 1) && (Number(str.charAt(1)) > 2)))
			ret = '0' + str.charAt(1);
		else ret = str.substr(0, 2);
	}
	ret = ret + ':';
	if(Number(str.charAt(3)) > 5){
		ret = ret + '0' + str.charAt(4);
	}
	else ret = ret + str.substr(3, 2);

	return ret;
}

var fmt = readline();
var val = readline();
var objetao = {format: Number(fmt), value: String(val)};
print(solve(objetao));

//var arr = [{format: 24, value: '17:30'},{format: 12, value: '17:30'},{format: 24, value: '99:99'}];

function solve(obj){
	var ret = 0;
	var str = obj.value;
	if(obj.format == 24){
		if((Number(str.charAt(0)) > 2) || ((Number(str.charAt(0)) == 2) && (Number(str.charAt(1)) > 3)))
			ret = '0' + str.charAt(1);
		else ret = str.substr(0, 2);
	}
	else if(obj.format == 12){
		if((Number(str.charAt(0)) == 0) && (Number(str.charAt(1)) == 0))
			ret = '10';
		else if((Number(str.charAt(0)) > 1) || ((Number(str.charAt(0)) == 1) && (Number(str.charAt(1)) > 2))){
			if(Number(str.charAt(1)) < 2) ret = ret + '1';
			else ret = ret + '0';
			ret = ret + str.charAt(1);
		}
		else ret = str.substr(0, 2);
	}
	ret = ret + ':';
	if(Number(str.charAt(3)) > 5){
		ret = ret + '0' + str.charAt(4);
	}
	else ret = ret + str.substr(3, 2);

	return ret;
}

var fmt = readline();
var val = readline();
var objetao = {format: Number(fmt), value: String(val)};
print(solve(objetao));

var format = parseInt(readline());
var clock = readline().replace(':', '').split('').map(Number);

// adjust clock
if(format === 12) {

    if(clock[0] === 0 && clock[1] === 0) {
        clock[1] = 1;
    } else if(clock[0] === 1 && clock[1] > 2) {
        clock[1] = 2;
    } else if(clock[0] > 1) {

        clock[0] = 0;
        if(clock[1] === 0)
            clock[1] = 1;
    }
}

if(format === 24) {

    if(clock[0] === 2 && clock[1] > 3) {
        clock[1] = 3;
    } else if(clock[0] > 2) {
        clock[0] = 0;
    }
}

// adjust minutes
if(clock[2] > 5) {
    clock[2] = 5;
}

print(clock[0] + '' + clock[1] + ':' + clock[2] + '' + clock[3]);

var format = parseInt(readline());
var clock = readline().replace(':', '').split('').map(Number);

// adjust clock
if(format === 12) {

    if(clock[0] === 0 && clock[1] === 0) {
        clock[1] = 1;
    } else if(clock[0] === 1 && clock[1] > 2) {
        clock[1] = 2;
    } else if(clock[0] > 1 && clock[1] <= 2) {
        clock[1] = 0;
    } else if(clock[0] > 1 && clock[1] > 2) {
        clock[0] = 0;
        clock[1] = 1;
    }
}

if(format === 24) {

    if(clock[0] === 2 && clock[1] > 3) {
        clock[1] = 3;
    } else if(clock[0] > 2) {
        clock[0] = 0;
    }
}

// adjust minutes
if(clock[2] > 5) {
    clock[2] = 5;
}

print(clock[0] + '' + clock[1] + ':' + clock[2] + '' + clock[3]);

var format = parseInt(readline());
var clock = readline().replace(':', '').split('').map(Number);

// adjust clock
if(format === 12) {

    if(clock[0] === 0 && clock[1] === 0) {
        clock[1] = 1;
    } else if(clock[0] === 1 && clock[1] > 2) {
        clock[1] = 2;
    } else if(clock[0] > 1 && clock[1] !== 0) {
        clock[1] = 0;
    } else if(clock[0] > 1 && clock[1] === 0) {
        clock[0] = 0;
        clock[1] = 1;
    }
}

if(format === 24) {

    if(clock[0] === 2 && clock[1] > 3) {
        clock[1] = 3;
    } else if(clock[0] > 2) {
        clock[0] = 0;
    }
}

// adjust minutes
if(clock[2] > 5) {
    clock[2] = 5;
}

print(clock[0] + '' + clock[1] + ':' + clock[2] + '' + clock[3]);

var format = parseInt(readline());
var clock = readline().replace(':', '').split('').map(Number);

// adjust clock
if(format === 12) {

    if(clock[0] === 0 && clock[1] === 0) {
        clock[1] = 1;
    } else if(clock[0] === 1 && clock[1] > 2) {
        clock[1] = 2;
    } else if(clock[0] > 1 && clock[1] !== 0) {
        clock[0] = 0;
    } else if(clock[0] > 1 && clock[1] === 0) {
        clock[0] = 0;
        clock[1] = 1;
    }
}

if(format === 24) {

    if(clock[0] === 2 && clock[1] > 3) {
        clock[1] = 3;
    } else if(clock[0] > 2) {
        clock[0] = 0;
    }
}

// adjust minutes
if(clock[2] > 5) {
    clock[2] = 5;
}

print(clock[0] + '' + clock[1] + ':' + clock[2] + '' + clock[3]);


/* eslint-disable no-continue */
/* eslint-disable no-param-reassign */
const readline = require('readline').createInterface({
  input: process.stdin,
});

const lines = [];

readline.on('line', (line) => {
  if (lines.length === 0) {
    lines.push(Number(line));
  } else {
    lines.push(line);
  }
});

const proccessLine = (len, arr) => {
  let count = 0;
  let count1 = 0;
  let count2 = 0;

  for (let i = 0; i < len; i += 1) {
    const v = arr[i];
    const rest = v % 3;
    if (rest === 0) {
      count += 1;
    } else if (rest === 1) {
      count1 += 1;
    } else {
      count2 += 1;
    }
  }

  count += Math.min(count1, count2) + Math.floor(Math.abs(count2 - count1) / 3);

  return count;
};

readline.on('close', () => {
  const [_, ...vars] = lines;

  for (let i = 0; i < vars.length; i += 2) {
    const len = Number(vars[i]);
    const numbers = vars[i + 1].split(' ').map(Number);

    console.log(proccessLine(len, numbers));
  }
});

(function () {
    var read = {
        number: function () {
            return +readline();
        },
        arr: function (divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function (divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    };

    var t = read.number();

    for(var i = 0; i < t; i++) {
        var n = read.number();
        var a = read.arrNumber(' ').filter(i => i % 3);
        var res = n - a.length;
        n = a.length;

        var c2 = 0;
        var c1 = 0;
        for(var j = 0; j < n;j++) {
           if(a[j] % 3 === 1) {
               c1 ++;
           }
           else if(a[j] %3 === 2) {
               c2++;
           }
        }
        res+= Math.min(c1,c2);
        res += Math.floor(Math.abs(c1 - c2) / 3);
        print(res);
    }

}());

/* eslint-disable no-continue */
/* eslint-disable no-param-reassign */
const readline = require('readline').createInterface({
  input: process.stdin,
});

const lines = [];

readline.on('line', (line) => {
  if (lines.length === 0) {
    lines.push(Number(line));
  } else {
    lines.push(line);
  }
});

const proccessLine = (len, arr) => {
  let count = 0;
  const rests = {
    1: 0,
    2: 0,
  };

  for (let i = 0; i < len; i += 1) {
    const v = arr[i];
    const rest = v % 3;
    if (rest === 0) {
      count += 1;
      continue;
    }

    rests[rest] += 1;
  }

  const restOne = Math.floor(rests[1] / 3);
  rests[1] -= restOne;

  const restTwo = Math.floor(rests[2] / 3);
  rests[2] -= restTwo;

  return count + restOne + restTwo + Math.min(...Object.values(rests));
};

readline.on('close', () => {
  const [_, ...vars] = lines;

  for (let i = 0; i < vars.length; i += 2) {
    const len = Number(vars[i]);
    const numbers = vars[i + 1].split(' ').map(Number);

    console.log(proccessLine(len, numbers));
  }
});

/* eslint-disable no-continue */
/* eslint-disable no-param-reassign */
const readline = require('readline').createInterface({
  input: process.stdin,
});

const lines = [];

readline.on('line', (line) => {
  if (lines.length === 0) {
    lines.push(Number(line));
  } else {
    lines.push(line);
  }
});

const proccessLine = (len, arr) => {
  let count = 0;
  const rests = {
    1: 0,
    2: 0,
  };

  for (let i = 0; i < len; i += 1) {
    const v = arr[i];
    const rest = v % 3;
    if (rest === 0) {
      count += 1;
      continue;
    }

    rests[rest] += 1;
  }

  const restCopy = { ...rests };
  let minTogether = Math.min(...Object.values(restCopy));
  const togetherOne = Math.max(restCopy[1] - minTogether * 3, 0);
  const togetherTwo = Math.max(restCopy[2] - minTogether * 3, 0);

  minTogether += togetherOne + togetherTwo;

  const restOne = Math.floor(rests[1] / 3);
  rests[1] -= restOne * 3;
  const restTwo = Math.floor(rests[2] / 3);
  rests[2] -= restTwo * 3;

  const minRest = restOne + restTwo + Math.min(...Object.values(rests));

  return count + (minTogether > minRest ? minTogether : minRest);
};

readline.on('close', () => {
  const [_, ...vars] = lines;

  for (let i = 0; i < vars.length; i += 2) {
    const len = Number(vars[i]);
    const numbers = vars[i + 1].split(' ').map(Number);

    console.log(proccessLine(len, numbers));
  }
});

/* eslint-disable no-continue */
/* eslint-disable no-param-reassign */
const readline = require('readline').createInterface({
  input: process.stdin,
});

const lines = [];

readline.on('line', (line) => {
  if (lines.length === 0) {
    lines.push(Number(line));
  } else {
    lines.push(line);
  }
});

const proccessLine = (len, arr) => {
  let count = 0;
  const rests = {
    1: 0,
    2: 0,
  };

  for (let i = 0; i < len; i += 1) {
    const v = arr[i];
    const rest = v % 3;
    if (rest === 0) {
      count += 1;
      continue;
    }

    rests[rest] += 1;
  }

  const restOne = Math.floor(rests[1] / 3);
  rests[1] -= restOne * 3;

  const restTwo = Math.floor(rests[2] / 3);
  rests[2] -= restTwo * 3;

  return count + restOne + restTwo + Math.min(...Object.values(rests));
};

readline.on('close', () => {
  const [_, ...vars] = lines;

  for (let i = 0; i < vars.length; i += 2) {
    const len = Number(vars[i]);
    const numbers = vars[i + 1].split(' ').map(Number);

    console.log(proccessLine(len, numbers));
  }
});

/* eslint-disable no-continue */
/* eslint-disable no-param-reassign */
const readline = require('readline').createInterface({
  input: process.stdin,
});

const lines = [];

readline.on('line', (line) => {
  if (lines.length === 0) {
    lines.push(Number(line));
  } else {
    lines.push(line);
  }
});

const proccessLine = (len, arr) => {
  let count = 0;
  const rests = {
    1: 0,
    2: 0,
  };

  for (let i = 0; i < len; i += 1) {
    const v = arr[i];
    const rest = v % 3;
    if (rest === 0) {
      count += 1;
      continue;
    }

    rests[rest] += 1;
  }

  const minTogether = Math.min(...Object.values(rests));

  const restOne = Math.floor(rests[1] / 3);
  rests[1] -= restOne * 3;
  const restTwo = Math.floor(rests[2] / 3);
  rests[2] -= restTwo * 3;

  const minRest = restOne + restTwo + Math.min(...Object.values(rests));

  return count + (minTogether > minRest ? minTogether : minRest);
};

readline.on('close', () => {
  const [_, ...vars] = lines;

  for (let i = 0; i < vars.length; i += 2) {
    const len = Number(vars[i]);
    const numbers = vars[i + 1].split(' ').map(Number);

    console.log(proccessLine(len, numbers));
  }
});

/* eslint-disable no-continue */
/* eslint-disable no-param-reassign */
const readline = require('readline').createInterface({
  input: process.stdin,
});

const lines = [];

readline.on('line', (line) => {
  if (lines.length === 0) {
    lines.push(Number(line));
  } else {
    lines.push(line);
  }
});

const proccessLine = (len, arr) => {
  let count = 0;
  const rests = {
    1: 0,
    2: 0,
  };

  for (let i = 0; i < len; i += 1) {
    const v = arr[i];
    const rest = v % 3;
    if (rest === 0) {
      count += 1;
      continue;
    }

    rests[rest] += 1;
  }

  const restCopy = { ...rests };
  let minTogether = Math.min(...Object.values(restCopy));
  const togetherOne = Math.max(Math.floor((restCopy[1] - minTogether * 3) / 3), 0);
  const togetherTwo = Math.max(Math.floor((restCopy[2] - minTogether * 3) / 3), 0);

  minTogether += togetherOne + togetherTwo;

  const restOne = Math.floor(rests[1] / 3);
  rests[1] -= restOne * 3;
  const restTwo = Math.floor(rests[2] / 3);
  rests[2] -= restTwo * 3;

  const minRest = restOne + restTwo + Math.min(...Object.values(rests));

  return count + (minTogether > minRest ? minTogether : minRest);
};

readline.on('close', () => {
  const [_, ...vars] = lines;

  for (let i = 0; i < vars.length; i += 2) {
    const len = Number(vars[i]);
    const numbers = vars[i + 1].split(' ').map(Number);

    console.log(proccessLine(len, numbers));
  }
});


var stdin_input = "";
var stdin_input_itr;
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function (input) { stdin_input += input; });
process.stdin.on("end", function () { stdin_input_itr = stdin_input.split('\n').values(); main(); });

const rl = () => stdin_input_itr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

var deb; const log = msg => (typeof deb != "undefined") && console.log("DEBUG", msg);

function shuffle(array) {
	let currentIndex = array.length,  randomIndex;

	// While there remain elements to shuffle...
	while (currentIndex != 0) {

		// Pick a remaining element...
		randomIndex = Math.floor(Math.random() * currentIndex);
		currentIndex--;

		// And swap it with the current element.
		[array[currentIndex], array[randomIndex]] = [
			array[randomIndex], array[currentIndex]];
	}

	return array;
}

const M = 5;

function main () {
	let T = rn();
	while (T--) {
		const n = rn();

		const r = [];
		for (let i = 0; i < n; i++) r[i] = rna();

		const ord = [];
		for (let i = 0; i < n; i++) ord[i] = i;

		shuffle(ord);
		let w = -1;
		for (let i = 0; i < n; i++) {
			let works = 1;
			for (let j = 0; j < n && works; j++) {
				let cnt = 0;
				for (let k = 0; k < M; k++) cnt += r[ord[i]][k] <= r[ord[j]][k];
				if (cnt < 3) works = 0;
			}
			if (works) { w = ord[i] + 1; break; }
		}

		console.log(w);
	}
}

var stdin_input = "";
var stdin_input_itr;
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function (input) { stdin_input += input; });
process.stdin.on("end", function () { stdin_input_itr = stdin_input.split('\n').values(); main(); });

const rl = () => stdin_input_itr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

var deb; const log = msg => (typeof deb != "undefined") && console.log("DEBUG", msg);

function main () {
	let T = rn();
	while (T--) {
		const n = rn();

		const r = [];
		for (let i = 0; i < n; i++) {
			r[i] = rna();
		}

		let w = 0;
		for (let i = 0; i < n; i++) {
			let cnt = 0;
			for (let j = 0; j < 5; j++) cnt += r[w][j] <= r[i][j];
			if (cnt < 3) w = i;
		}

		let ok = 1;
		for (let i = 0; i < n; i++) {
			let cnt = 0;
			for (let j = 0; j < 5; j++) cnt += r[w][j] <= r[i][j];
			if (cnt < 3) ok = 0;
		}

		console.log(ok ? w + 1 : -1);
	}
}


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 main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    let arr = readLine()
      .split(" ")
      .map((n) => parseInt(n));

    let ok = false;

    for (let i = 0; i < len - 1; i++) {
      if (arr[i] <= arr[i + 1]) {
        console.log("YES");
        ok = true;
        break;
      }
    }

    if (!ok) console.log("NO");
  }
}

var t = parseInt(readline());
while(t--){
    var n = parseInt(readline());
    var list = readline().split(" ").map(Number);
    var ok = true;
    for(var i=0;i<n-1;i++){
      if(list[i]<=list[i+1]){
        ok = false;
      }
    }
    if(ok==true){
        print("NO");
    }else print("YES");
}

//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 N = nextInt();
    var list = nextIntArray();
    var isOK = false;
    for(var j = 0; j < N - 1; j++){
      if(list[j] <= list[j + 1]){
        isOK = true;
      }
    }
    output[i] = (isOK) ? "YES" : "NO";
  }
  myout(myconv(output, 9));
}

let input = '';
let inputResolve;
let inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => inputResolve());

function For(a, b, fn) {
  let res;
  if (a < b) {
    for (let i = a; i <= b; i++) {
      if ((res = fn(i)) !== undefined) return res;
    }
  } else {
    for (let i = a; i >= b; i--) {
      if ((res = fn(i)) !== undefined) return res;
    }
  }
}

function Arr(a, b, fn, prev) {
  let p = prev || 0;
  if (a < b) return Array(b - a + 1).fill(0).map((v, i) => fn ? (p = fn(a + i, p)) : a + i);
  return Array(a - b + 1).fill(0).map((v, i) => fn ? (p = fn(a - i, p)) : a - i);
}

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(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = Math.min(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == min : v == min);
  return [this[i], i, min];
}
Array.prototype.max = function (fn) {
  let max = Math.max(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == max : v == max);
  return [this[i], i, max];
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}
// [m] = extendedEuclid(a, 998244353);

(async () => {
  await inputPromise;
  let inp = input.split(/\s+/).map(v => +v); r = 0;
  let t = inp[r++];
  while (t--) {
    let n = inp[r++];
    let a = inp.slice(r, r = r + n);
    console.log(For(0, n - 2, i => a[i] <= a[i + 1] ? 1 : undefined) ? 'YES' : 'NO')
  }
})();

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 main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    let arr = readLine()
      .split(" ")
      .map((n) => parseInt(n));

    const str = arr.join("");
    arr.sort((a, b) => b - a);

    const str2 = arr.join("");

    if (str === str2 && arr[0] !== arr[len - 1]) console.log("NO");
    else console.log("YES");
  }
}

var t = parseInt(readline());
while(t--){
    var n = parseInt(readline());
    var input = readline();
    var arr = input.split(' ').map(Number);
    var ok = true;
    if(ok==true){
        print("NO\n");
    }else print("YES\n");
}

var t = parseInt(readline());
while(t--){
    var n = parseInt(readline());
    var list = readline().split(" ").map(Number);
    for(var i=0;i<n-1;i++){
      if(list[i]<=list[i+1]){
        ok = false;
      }
    }
    var ok = true;
    if(ok==true){
        print("NO");
    }else print("YES");
}


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) ? 'Alice' : 'Bob'
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, arr) {
    const min = Math.min(...arr)
    if (arr[0] === min) {
        return false
    } else {
        return true
    }
}

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 f = a[0];
            a.sort(function(a, b){return a - b});
            console.log(a[0] == f ? 'Bob' : 'Alice');
        }
    }
});

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 minn = inf;
	for(var i=0;i<n;i++) minn = min(minn, a[i])
	if(minn !== a[0]) console.log("Alice");
	else console.log("Bob")
}

/*
* auther yeling
*
*
*/
'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 print(str) {
    console.log(str);
}

// const { readline, print, testOutput } = require('@ip-algorithmics/codeforces-io');
// main();
// testOutput();

function begin(n, nums) {
    let min = Number.MAX_SAFE_INTEGER;
    let minIndex = 0;
    for(let i = 0; i < nums.length; i++) {
        if(min > nums[i]) {
            min = nums[i];
            minIndex = i;
        }
    }
    if(minIndex > 0) {
        print("Alice");
    } else {
        print("Bob");
    }
}

function main() {
    var caseNum = parseInt(readline(), 10);
    for (var i = 0; i < caseNum; i++) {
        var n = parseInt(readline(), 10);
        var x = readline()
            .trim()
            .split(' ')
            .map((y) => parseInt(y, 10));
        begin(n, x);
    }
}

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  const n = rn(),
        a = rns();
  if (a[0] === 1) return 'Bob';
  for (let i = 1; i < n; i++) {
    if (a[i] < a[0]) return 'Alice';
  }
  return 'Bob';
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = () => read().split(/\s+/).map(Number);
  const re = () => read().split(/\s+/).map(s => Number(s) - 1);
  const rbs = () => read().split(/\s+/).map(BigInt);
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      let s = solve(r);
      if (s === undefined) s = '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\r?\n/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

process.stdin.resume();
process.stdin.setEncoding('utf8');

// your code goes here

// declare global variables
var input_stdin = "";
var lines = "";
var input_currentline = 0;

// standard input is stored into input_stdin
process.stdin.on('data', function (data) {
    input_stdin += data;
});

// standard input is done and stored into an array
process.stdin.on('end', function () {
    lines = input_stdin.split("\n");
    start();
});

function start() {
    const T = parseInt(lines[0])
    let line = 1
    for (let t = 1; t <= T; t++) {
        const n = parseInt(lines[line++].split(' ')[0], 10)
        const a = lines[line++].split(' ').map(x => parseInt(x, 10))
        let min = a[1];
        for(let i = 1; i < a.length; i++) {
            if (min > a[i])
                min = a[i]
        }
        if (a[0] > min) console.log('Alice')
        else console.log('Bob')
    }
}

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) ? 'Alice' : 'Bob'
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, arr) {
    const min = Math.min(...arr)
    if (min === 1) {
        return arr[0] !== 1
    }
    const sum = arr.reduce((s, x) => s + x, 0)
    return (sum - 2 * n) & 1
}


var firstInput = readline().split(' ');
var nCandidates = parseInt(firstInput[0]);
var nCities = parseInt(firstInput[1]);
var citiesWonByCandidates = [];
var i, j, highestVotePerCity, currentVote, winnerPerCityIdx, votesPerCity;
for (i = 0; i < nCities; i++) {
	votesPerCity = readline().split(' ');
	highestVotePerCity = -1;
	for (j = 0; j < nCandidates; j++) {
		currentVote = parseInt(votesPerCity[j]);
		if (currentVote > highestVotePerCity) {
			winnerPerCityIdx = j;
			highestVotePerCity = currentVote;
		}
	}
	if (citiesWonByCandidates[winnerPerCityIdx] == null) {
		citiesWonByCandidates[winnerPerCityIdx] = 1;
	} else {
		citiesWonByCandidates[winnerPerCityIdx] += 1;
	}
}
var highestVote = -1, winner = 1;
for (i = 0; i < citiesWonByCandidates.length; i++) {
	if (citiesWonByCandidates[i] > highestVote) {
		winner = i+1;
		highestVote = citiesWonByCandidates[i];
	}
}
print(winner);

nm = readline().split(' ').map(Number);

var n = nm[0];
var m = nm[1];

var arr = [];

for (var i = 0; i < m; i++) {
	str = readline().split(' ').map(Number);

	var max = 0;
	var maxPos = 0;

	for (var j = 0; j < n; j++) {
		if (str[j] > max) {
			max = str[j];
			maxPos = j;
		};
	};

	arr.push(maxPos + 1);
};

for (var j = 0; j < m - 1; j++) {
	for (var k = j + 1; k < m; k++) {
		if (arr[j] > arr[k]) {
			var temp = arr[j];
			arr[j] = arr[k];
			arr[k] = temp;
		};
	};
};

var maxCount = 0;
var res = 0;

for (var k = 0; k < m; k++) {
	var count = 0;

	for (var l = 0; l < m; l++) {
		if (arr[k] == arr[l]) {
			count++;
		};
	};

	if (count > maxCount) {
		maxCount = count;
		res = arr[k];
	};
};

print(res);

var input = readline().split(" "), n = +input[0], m = +input[1], a = [], win1 = [], store = {}, winners = [];
for(i = 0; i < m; i++){
	a.push(readline().split(" "));
}

a.forEach(function(v){
	var sorted = v.concat().sort(function(x,y){return y-x});
	var canNumber = v.indexOf(sorted[0]);
	win1.push(canNumber);
});

for (var i = 0; i < win1.length; i++) {
  var key = win1[i];
  store[key] = key;
}

for(i = 0; i < n; i++){
	winners[i] = 0;
}

for(key in store){
	for(i = 0; i < m; i++){
		if(win1[i] == key){
			winners[key]++;
		}
	}
}

winnerss = winners.concat().sort(function(x,y){return y-x});

write(winners.indexOf(winnerss[0]) + 1);

'use strict';
let _in = readline().split(/\s+/).map((s) => parseInt(s, 10));
let n = _in[0], m = _in[1];
let a = [];
for (let i = 0; i < m; i++) {
    a.push(readline().split(/\s+/).map((s) => parseInt(s, 10)));
}
let f = (acc, _, i, v) => (v[acc] < v[i]) ? i : acc;
a = a.map((v) => v.reduce(f, 0));
let ct = new Array(n).fill(0);
for (let i = 0; i < m; i++) {
    ct[a[i]]++;
}
print(ct.reduce(f, 0) + 1);

var data = readline().split(' ');
var candidates = parseInt(data[0]);
var cities = parseInt(data[1]);
var result_cities = [];

for (var i = 0; i < cities; i++) {
    var data = readline().split(' ');
    var result = 0;
    for (var x = 0; x < candidates; x++) {
        var temp_result = parseInt(data[x]+1);
        if(result<temp_result) { //если текущий кандидат набрал больше предыдущего
            result = parseInt(data[x]+1); //то его результат пишем
            result_cities[i] = x+1;//и запоминаем номер кандидата

        }
    }
}

//на выхоже массив с результатами голосования по городам
var candidate_list = [candidates];
for (var i = 0; i < candidates; i++) {
    candidate_list[i] = 0;
    for (var x = 0; x < cities; x++) {
        if((i+1) == result_cities[x]) {
            candidate_list[i]++;
        }
    }
    //print(candidate_list[i]);
}

result = 1;

//находим победителя
for (var i = 1; i < candidates; i++) {
    if(candidate_list[i] > candidate_list[result-1]) {
        result = i+1;
    }
}

write(result);

(function() {
    "use strict";
    var arr = readline().split(" ").map(function(x) {
        return parseInt(x);
    });
    var can = arr[0], cit = arr[1], mat = [];
    var canind = [], maxvotes = [];
    for(var i = 0; i < cit; i++)
    {
        mat[i] = readline().split(" ").map(function(x) {
           return parseInt(x);
        });

        maxvotes[i] = mat[i][0];
        canind[i] = 0;
        for(var j = 0; j < can; j++)
        {
            if(mat[i][j] > maxvotes[i])
            {
                maxvotes[i] = mat[i][j];
                canind[i] = j;
            }
        }
    }

    var Tarek = [];
    for(var i = 0; i < can; i++)
    {
        Tarek[i] = 0;
    }

    for(var i = 0; i < cit; i++)
    {
        Tarek[canind[i]]++;
    }

    var fin_max = 0, fin_ind = 0;
    for(var i = 0; i < Tarek.length; i++)
    {
        if(Tarek[i] > fin_max)
        {
            fin_max = Tarek[i];
            fin_ind = i;
        }
    }

    print(fin_ind + 1);
})();

var arr = [];
var numberCitiesCandidates = readline();
numberCitiesCandidates = numberCitiesCandidates.split(' ');
var cities = numberCitiesCandidates[1];
var candidates = numberCitiesCandidates[0];

for (var i = 0; i < cities; i++) {
    var line = readline();
    if (!line) {
        break;
    }
    var lineChars = line.split(' ');
    for (var j = 0; j < candidates; j++) {
        if (!arr[i]) {
            arr[i] = [];
        }
        arr[i][j] = lineChars[j];
    }
}

var filteration = [];
for (var i = 0; i < arr.length; i++) {
    var maxCanditate = {
        index: 0,
        value: Number(arr[i][0])
    };
    for (var j = 1; j < arr[i].length; j++) {
        var currVotes = Number(arr[i][j]);
        if (maxCanditate.value < currVotes) {
            maxCanditate = {
                index: j,
                value: arr[i][j]
            };
        }
    }

    filteration.push(maxCanditate);
}
var citiesStatistics = {};
filteration.map(function(a) {
    if (a.index in citiesStatistics) {
        citiesStatistics[a.index]++;
    } else {
        citiesStatistics[a.index] = 1;
    }
});
var winner;
for (var canditateIndex in citiesStatistics) {
    var canditateIndexNum = Number(canditateIndex);
    if (!winner) {
        winner = {
            index: canditateIndexNum,
            cities: citiesStatistics[canditateIndex]
        };
    } else {
        if ((winner.cities < citiesStatistics[canditateIndex]) || (winner.cities == citiesStatistics[canditateIndex] && winner.index > canditateIndexNum)) {
            winner = {
                index: canditateIndexNum,
                cities: citiesStatistics[canditateIndex]
            };
        }
    }
}

print(winner.index + 1);

'use strict';
let _in = readline().split(/\s+/).map((s) => parseInt(s, 10));
let n = _in[0], m = _in[1];
let a = [];
for (let i = 0; i < n; i++) {
    a.push(readline().split().map(parseInt));
}
let f = (acc, _, i, v) => v[acc] < v[i] ? i : acc;
a.map((v) => v.reduce(f, 0));
let ct = new Array(m).fill(0);
for (let i = 0; i < m; i++) {
    ct[a[i]]++;
}
print(ct.reduce(f, 0) + 1);

'use strict';
let _in = readline().split(/\s+/).map((s) => parseInt(s, 10));
let m = _in[0], n = _in[1];
let a = [];
for (let i = 0; i < n; i++) {
    a.push(readline().split().map(parseInt));
}
let f = (acc, _, i, v) => v[acc] < v[i] ? i : acc;
a.map((v) => v.reduce(f, 0));
let ct = new Array(m).fill(0);
for (let i = 0; i < m; i++) {
    ct[a[i]]++;
}
print(ct.reduce(f, 0) + 1);

'use strict';
let _in = readline().split(/\s+/).map((s) => parseInt(s, 10));
let n = _in[0], m = _in[1];
let a = [];
for (let i = 0; i < m; i++) {
    a.push(readline().split(/\s+/).map((s) => parseInt(s, 10)));
}
let f = (acc, _, i, v) => (v[acc] < v[i]) ? i : acc;
a = a.map((v) => v.reduce(f, 0));
let ct = new Array(m).fill(0);
for (let i = 0; i < m; i++) {
    ct[a[i]]++;
}
print(ct.reduce(f, 0) + 1);

var data = readline().split(' ');
var candidates = parseInt(data[0]);
var cities = parseInt(data[1]);
var result_cities = [];

for (var i = 0; i < cities; i++) {
    var data = readline().split(' ');
    var result = 0;
    for (var x = 0; x < candidates; x++) {
        var temp_result = parseInt(data[x]);
        if(result<temp_result) { //если текущий кандидат набрал больше предыдущего
            result = parseInt(data[x]); //то его результат пишем
            result_cities[i] = x+1;//и запоминаем номер кандидата

        }
    }
}

//на выхоже массив с результатами голосования по городам
var candidate_list = [candidates];
for (var i = 0; i < candidates; i++) {
    candidate_list[i] = 0;
    for (var x = 0; x < cities; x++) {
        if((i+1) == result_cities[x]) {
            candidate_list[i]++;
        }
    }
    print(candidate_list[i]);
}

result = 1;

//находим победителя
for (var i = 1; i < candidates; i++) {
    if(candidate_list[i] > candidate_list[result-1]) {
        result = i+1;
    }
}

write(result);

var data = readline().split(' ');
var candidates = parseInt(data[0]);
var cities = parseInt(data[1]);
var result_cities = [];

for (var i = 0; i < cities; i++) {
    var data = readline().split(' ');
    var result = 0;
    for (var x = 0; x < candidates; x++) {
        var temp_result = parseInt(data[x]);
        if(result<temp_result) { //если текущий кандидат набрал больше предыдущего
            result = parseInt(data[x]); //то его результат пишем
            result_cities[i] = x+1;//и запоминаем номер кандидата
        }
    }
}

//на выхоже массив с результатами голосования по городам
var candidate_list = [candidates];
for (var i = 0; i < candidates; i++) {
    candidate_list[i] = 0;
    for (var x = 0; x < cities; x++) {
        if((i+1) == result_cities[x]) {
            candidate_list[i]++;
        }
    }
}

result = 1;

//находим победителя
for (var i = 1; i < candidates; i++) {
    if(candidate_list[i] > candidate_list[result-1]) {
        result = i+1;
    }
}

write(result);

(function () {
    "use strict";
    var arr = readline().split(" ").map(function (x) {
        return parseInt(x, 10);
    }), can = arr[0], cit = arr[1], mat = [], maxi = [], index = [];
    for (var i = 0; i < cit; i++) {
        mat[i] = readline().split(" ").map(function(z) {
            return parseInt(z);
        });
        maxi[i] = 0;
        index[i] = null;
        for(var j = can - 1; j >= 0; j--) {
            if(mat[i][j] >= maxi[i]) {
                maxi[i] = mat[i][j];
                index[i] = j;
            }
        }
    }

    var maxcan = [];

    for(i = 0; i < cit; i++) {
        maxcan[i] = 0;
    }

    for(i = 0; i < cit; i++) {
        maxcan[index[i]]++;
    }

    var maxnum = maxcan[0], maxindex = 0;
    for(i = can - 1; i >= 0; i--) {
        if(maxcan[i] >= maxnum) {
            maxnum = maxcan[i];
            maxindex = i;
        }
    }

    print(maxindex+1);

})();

(function () {
    "use strict";
    var arr = readline().split(" ").map(function (x) {
        return parseInt(x, 10);
    }), can = arr[0], cit = arr[1], mat = [],
        maxi = [], index = [], maxcan = [],
        maxnum = maxcan[0], maxindex = 0;
    for (var i = 0; i < cit; i++) {
        mat[i] = readline().split(" ").map(function(z) {
            return parseInt(z);
        });
        maxi[i] = 0;
        index[i] = null;
        for(var j = can - 1; j >= 0; j--) {
            if(mat[i][j] >= maxi[i]) {
                maxi[i] = mat[i][j];
                index[i] = j;
            }
        }
    }
    for(i = 0; i < cit; i++) {
        maxcan[i] = 0;
    }
    for(i = 0; i < cit; i++) {
        maxcan[index[i]]++;
    }
    for(i = cit - 1; i >= 0; i--) {
        if(maxcan[i] >= maxnum) {
            maxnum = maxcan[i];
            maxindex = i;
        }
    }
    print(maxindex+1);
})();

var arr = [];
var numberCitiesCandidates = readline();
numberCitiesCandidates = numberCitiesCandidates.split(' ');
var cities = numberCitiesCandidates[1];
var candidates = numberCitiesCandidates[0];

for (var i = 0; i < cities; i++) {
    var line = readline();
    if (!line) {
        break;
    }
    var lineChars = line.split(' ');
    for (var j = 0; j < candidates; j++) {
        if (!arr[i]) {
            arr[i] = [];
        }
        arr[i][j] = lineChars[j];
    }
}

var filteration = [];
for (var i = 0; i < arr.length; i++) {
    var maxCanditate = {
        index: 0,
        value: Number(arr[i][0])
    };
    for (var j = 1; j < arr[i].length; j++) {
    	var currVotes = Number(arr[i][j]);
        if (maxCanditate.value < currVotes) {
            maxCanditate = {
                index: j,
                value: arr[i][j]
            };
        }
    }
    if(filteration.length === 0 || (filteration.length !== 0 && maxCanditate.value !== 0))
    	filteration.push(maxCanditate);
}
var citiesStatistics = {};
filteration.map(function(a) {
    if (a.index in citiesStatistics) {
        citiesStatistics[a.index]++;
    } else {
        citiesStatistics[a.index] = 1;
    }
});
var winner;
for(var canditateIndex in citiesStatistics){
	var canditateIndexNum = Number(canditateIndex);
	if(!winner){
		winner = {index: canditateIndexNum, cities: citiesStatistics[canditateIndex]};
	}else{
		if((winner.cities < citiesStatistics[canditateIndex]) || (winner.cities == citiesStatistics[canditateIndex] && winner.index > canditateIndexNum)){
			winner = {index: canditateIndexNum, cities: citiesStatistics[canditateIndex]};
		}
	}
}

print(winner.index + 1);

var arr = [];
var input = readline();
print(input);
var lines = input.split("\n");
for (var i = 0; i < lines.length; i++) {
    var line = lines[i];
    var lineChars = line.split(' ');
    for (var j = 0; j < lineChars.length; j++) {
        if (!arr[i]) {
            arr[i] = [];
        }
        arr[i][j] = lineChars[j];
    }
}

var arr = [];
for (var i = 0; i < 100; i++) {
    var line = readline();
    if (!line) {
        break;
    }
    var lineChars = line.split(' ');
    for (var j = 0; j < lineChars.length; j++) {
        if (!arr[i]) {
            arr[i] = [];
        }
        arr[i][j] = lineChars[j];
    }
}
var filteration = [];
for (var i = 0; i < arr.length; i++) {
    var maxCanditate = {
        index: 0,
        value: Number(arr[i][0])
    };
    for (var j = 1; j < arr[i].length; j++) {
        if (maxCanditate.value < Number(arr[i][j])) {
            maxCanditate = {
                index: j,
                value: arr[i][j]
            };
        }
    }
    filteration.push(maxCanditate);
}
var citiesStatistics = {};
filteration.map(function(a) {
    if (a.index in citiesStatistics) {
        citiesStatistics[a.index]++;
    } else {
        citiesStatistics[a.index] = 1;
    }
});
var winner;
for(var canditateIndex in citiesStatistics){
	var canditateIndexNum = Number(canditateIndex);
	if(!winner){
		winner = {index: canditateIndexNum, cities: citiesStatistics[canditateIndex]};
	}else{
		if((winner.cities < citiesStatistics[canditateIndex]) || (winner.cities == citiesStatistics[canditateIndex] && winner.index > canditateIndexNum)){
			winner = {index: canditateIndexNum, cities: citiesStatistics[canditateIndex]};
		}
	}
}

print(winner.index + 1);

var firstInput = readline().split(' ');
var nCandidates = parseInt(firstInput[0]);
var nCities = parseInt(firstInput[1]);
var citiesWonByCandidates = [];
var i, j, highestVotePerCity, currentVote, winnerPerCityIdx, votesPerCity;
for (i = 0; i < nCities; i++) {
    votesPerCity = readline().split(' ');
    highestVotePerCity = 0;
    for (j = 0; j < nCandidates; j++) {
        currentVote = parseInt(votesPerCity[j]);
        if (currentVote > highestVotePerCity) {
            winnerPerCityIdx = j;
            highestVotePerCity = currentVote;
        }
    }
    if (citiesWonByCandidates[winnerPerCityIdx] == null) {
        citiesWonByCandidates[winnerPerCityIdx] = 1;
    } else {
        citiesWonByCandidates[winnerPerCityIdx] += 1;
    }
}
var highestVote = 0, winner = 1;
for (i = 0; i < citiesWonByCandidates.length; i++) {
    if (citiesWonByCandidates[i] > highestVote) {
        winner = i+1;
        highestVote = citiesWonByCandidates[i];
    }
}
print(winner);

var firstInput = readline().split(' ');
var nCandidates = parseInt(firstInput[0]);
var nCities = parseInt(firstInput[1]);
var citiesWonByCandidates = [];
var i, j, highestVotePerCity, currentVote, winnerPerCityIdx, votesPerCity;
for (i = 0; i < nCities; i++) {
	votesPerCity = readline().split(' ');
	highestVotePerCity = 0;
	for (j = 0; j < nCandidates; j++) {
		currentVote = parseInt(votesPerCity[j]);
		if (currentVote > highestVotePerCity) {
			winnerPerCityIdx = j;
			highestVotePerCity = currentVote;
		}
	}
	if (citiesWonByCandidates[winnerPerCityIdx] == null) {
		citiesWonByCandidates[winnerPerCityIdx] = 1;
	} else {
		citiesWonByCandidates[winnerPerCityIdx] += 1;
	}
}
var highestVote = 0, winner;
for (i = 0; i < citiesWonByCandidates.length; i++) {
	if (citiesWonByCandidates[i] > highestVote) {
		winner = i+1;
		highestVote = citiesWonByCandidates[i];
	}
}
print(winner);


String.prototype.normalize = function() {
    var self = this;
    return self.toLowerCase().replace(/o/g, '0').replace(/[il]/g, 1);
};

var potentialLogin = readline().normalize();
var existanceLoginCount = parseInt(readline());
var extstanceLogins = [];
var canLogIn = true;
var i = 0;
while(i < existanceLoginCount) {
    var line = readline();
    if(canLogIn && potentialLogin === line.normalize()){
        canLogIn = false;
    }
    i++;
}

print(canLogIn ? 'Yes' : 'No')

var login = readline().replace(/0/g, "o").toLowerCase().replace(/1/g, "i").replace(/l/g, "i");
var db = readline();
var logins, answer;
for (i=0; i<db; i++) {
    logins = readline();
    logins = logins.replace(/0/g, "o").toLowerCase().replace(/1/g, "i").replace(/l/g, "i");
    if (login === logins) {answer="No";break;} else answer = "Yes";
}
print(answer);

var user_input = readline().split("");
var number = parseInt(readline());
var logged = [];
for (var i = 0; i < number; i++) {
    logged.push(readline().split(""));
}
var numberSample = 0;
var res = true;
for (var i = 0; i < logged.length; i++) {
    if (logged[i].length != user_input.length) {
        continue;
    }
    for (var j = 0; j < logged[i].length; j++) {
        if (logged[i][j] == "0" || logged[i][j] == "o" || logged[i][j] == "O") {
            logged[i][j] = ".";
        }
        if (user_input[j] == "0" || user_input[j] == "o" || user_input[j] == "O") {
            user_input[j] = ".";
        }
        if (logged[i][j] == "1" || logged[i][j] == "l" || logged[i][j] == "I" || logged[i][j] == "i" || logged[i][j] == "L") {
            logged[i][j] = "*";
        }
        if (user_input[j] == "1" || user_input[j] == "l" || user_input[j] == "I" || user_input[j] == "i" || user_input[j] == "L") {
            user_input[j] = "*";
        }
        if (user_input[j].toLowerCase() == logged[i][j].toLowerCase()) {
            numberSample++;
        }
    }
    if (user_input.length == numberSample) {
        res = false;
    }
    numberSample = 0;
}
if (!res) write("No");
else write("Yes");

var newLogin = readline();
var numberOfLogins = parseInt(readline());
var isPrinted = false;

for (var i = 0; i < numberOfLogins; i++) {
    if(areLoginsSimilar(newLogin, readline())) {
        write('No');
        isPrinted = true;
        break;
    }
}

isPrinted || write('Yes');

function areLoginsSimilar(login, loginToChange) {
    if(login.length !== loginToChange.length) {
        return false;
    }

    for(var i = 0; i < loginToChange.length; i++) {
        if(!areLettersSimilar(login[i], loginToChange[i])) {
            return false;
        }
    }

    return true;
}

function areLettersSimilar(letter, letterToChange) {
    if(letterToChange.toLowerCase() === letter ||
           letterToChange.toUpperCase() === letter) {
           return true;
    }

    if(letter.match(/[0o]/i) && letterToChange.match(/[0o]/i)) {
        return true
    }

    if(letter.match(/[1li]/i) && letterToChange.match(/[1li]/i)) {
        return true
    }

    return false;
}

'use strict'
function getInputs(){
    let i = []
    let x = readline()
    while(typeof x != 'undefined'){
        i.push(x)
        x=readline()
    }
    return i
}
function check1(l){
    if(!l){
        print('No')
        return false
    }
    l = '' + l
    if(l.match(/[a-z0-9_]{1,50}/i)){
        return true
    } else{
        print('No')
        return false
    }
}
function upgradeDatabase(db){
    db = db.map(e=>e.toLowerCase(e))
    db = db.map(e=>e.replace(/(i|l)/ig,'1'))
    db = db.map(e=>e.replace(/(o)/ig,'0'))
    return db
}
function upgradeLogin(lg){
    lg = lg.toLowerCase()
    lg = lg.replace(/(i|l)/ig,'1')
    lg = lg.replace(/o/ig,'0')
    return lg
}
function check2(l,db){
    let check = true
    for(let e of db){
        if(e == l){
           check = false
        }
    }
    if(check){
        return true
    } else{
        print('No')
        return false
    }
}
function checkLogin(login,dbsize,...db){
    db=db[0]
    if(check1(login)){
        db = upgradeDatabase(db)
        login = upgradeLogin(login)
        if(check2(login,db)){
            print('Yes')
        }
    }
}

let inputs = getInputs()
checkLogin(inputs[0],inputs[1],inputs.slice(2))

var login = readline().toLowerCase();
var countLogins = +readline();
var logins = [];
var result = true;

for (var i = 0; i < countLogins; i++) {
  logins.push(readline().toLowerCase());
}

// Solution start
function reformatLogin(login) {
  return login.replace(/o/gi, '0').replace(/l/gi, '1').replace(/i/gi, '1');
}

login = reformatLogin(login);

for (var i = 0; i < countLogins; i = i + 1) {
  var temp = reformatLogin(logins[i]);

  if (login === temp) {
    result = false;
    break;
  }
}

print(result ? 'Yes' : 'No');

var input = function(){
  var userNick = normalize(readline());
  var n = parseInt(readline());
  var s = new Set();
  for(var i=0; i<n; i++){
    s.add(normalize(readline()));
  }
  return {
    set : s,
    userNick: userNick
  }
}

var normalize = function(str){
  str = str.toLowerCase();
  str = str.replace(/0/g, 'o');
  str = str.replace(/1/g, 'i');
  str = str.replace(/l/g, 'i');
  return str;
}

var data = input();
if(data.set.has(data.userNick)){
  print('No');
} else {
  print('Yes');
}

function transformLogin(login) {
  return login.trim().toUpperCase().replace(/O/g, "0").replace(/[LI]/g, "1");
}

const newLogin = transformLogin(readline());
const existingCount = Number(readline());
(() => {
  for (var i = 0; i < existingCount; i++)
    if (newLogin === transformLogin(readline())) {
      print("No");
      return;
    }
  print("Yes");
})();

//Some debug stuff
const isDebugMode=false;
var log=()=>{}
if(isDebugMode){
    var print=function (out) {
        console.log('COUT: '+ out);
    }
    log=function (out) {
        console.log('DEBUG OUTPUT: '+ out);
    }
    function* readline_generator() {
        var a=[
            'La0',
            '3',
            '2a0',
            'La1',
            '1a0'
        ];
        while(a.length>1){
            yield a.shift()
        }
        return a.shift();
    }
    var g=readline_generator();
    var readline=function () {
        return g.next().value;
    }
}

//SOLUTION

var compareS=function(s1, s2){
    if(s1.toLowerCase()==s2.toLowerCase()){
        return true;
    }
    switch(s1){
        case 'O':
        case '0':
        case 'o':
            if(['0', 'O', 'o'].indexOf(s2)>-1){
                return true;
            }
            break;
        case '1':
        case 'l':
        case 'I':
        case 'i':
        case 'L':
            if(['1', 'l', 'I', 'i', 'L'].indexOf(s2)>-1){
                return true;
            }
            break;
    }
    return false;
};

var compare=function(a1, a2){
    var c=0;
    a1.forEach((i,k)=>{
        if(compareS(i, a2[k])){
            c++;
        }
    });
    return c==a1.length;
};

var magic=function(s1, s2){
    s1=s1.split('');
    s2=s2.split('');
    var diff1=[];
    var diff2=[];
    s1.forEach((i,k)=>{
        if(i!=s2[k]){
            diff1.push(i);
            diff2.push(s2[k]);
        }
    })
    return compare(diff1, diff2)
}

var loginToTest=readline();

var numOfLogins=+(readline());

var count=0;
var f=0;
while(count<numOfLogins){
    count++;
    var currentLogin=readline();
    log('Comparing '+currentLogin+ ' vs '+loginToTest);
    if( currentLogin && currentLogin.length==loginToTest.length){
        log('Length is equal')
        if(magic(loginToTest, currentLogin)){
            log('Magic is true');
            print('No');
            f=1;
        }
    }
}
if(f===0){
    print('Yes');
}

var compareS=function(s1, s2){
    if(s1.toLowerCase()==s2.toLowerCase()){
        return true;
    }
    switch(s1){
        case 'O':
        case '0':
        case 'o':
            if(['0', 'O', 'o'].indexOf(s2)>-1){
                return true;
            }
            break;
        case '1':
        case 'l':
        case 'I':
        case 'i':
            if(['1', 'l', 'I', 'i'].indexOf(s2)>-1){
                return true;
            }
            break;
    }
    return false;
};

var compare=function(a1, a2){
    var c=0;
    a1.forEach((i,k)=>{
        if(compareS(i, a2[k])){
            c++;
        }
    });
    return c==a1.length;
};

var magic=function(s1, s2){
    s1=s1.split('');
    s2=s2.split('');
    var diff1=[];
    var diff2=[];
    s1.forEach((i,k)=>{
        if(i!=s2[k]){
        diff1.push(i);
        diff2.push(s2[k]);
    }
})
    return compare(diff1, diff2)
}

var loginToTest=readline();

var numOfLogins=+(readline());

var count=0;
var f=0;
while(count<numOfLogins){
    count++;
    var currentLogin=readline();
    if(currentLogin.length==loginToTest.length){
        if(magic(loginToTest, currentLogin)){
            print('No');
            f=1;
        }
    }
}
if(f===0){
    print('Yes');
}

'use strict';
var compareS=function(s1, s2){
    if(s1.toLowerCase()==s2.toLowerCase()){
        return true;
    }
    switch(s1){
        case 'O':
        case '0':
        case 'o':
            if(['0', 'O', 'o'].indexOf(s2)>-1){
                return true;
            }
            break;
        case '1':
        case 'l':
        case 'I':
            if(['1', 'l', 'I'].indexOf(s2)>-1){
                return true;
            }
            break;
    }
    return false;
};

var compare=function(a1, a2){
    var c=0;
    a1.forEach((i,k)=>{
        if(compareS(i, a2[k])){
            c++;
        }
    });
    return c==a1.length;
};

var magic=function(s1, s2){
    s1=s1.split('');
    s2=s2.split('');
    var diff1=[];
    var diff2=[];
    s1.forEach((i,k)=>{
        if(i!=s2[k]){
        diff1.push(i);
        diff2.push(s2[k]);
    }
})
    return compare(diff1, diff2)
}

var loginToTest=readline();

var numOfLogins=+(readline());

var count=0;
var f=0;
while(count<numOfLogins){
    count++;
    var currentLogin=readline();
    if(currentLogin.length==loginToTest.length){
        if(magic(loginToTest, currentLogin)){
            print('No');
            f=1;
        }
    }
}
if(f==1){
    print('Yes');
}

var compareS=function(s1, s2){
	if(s1.toLowerCase()==s2.toLowerCase()){
		return true;
	}
	switch(s1){
		case 'O':
		case '0':
		case 'o':
			if(['0', 'O', 'o'].indexOf(s2)>-1){
				return true;
			}
			break;
		case '1':
		case 'l':
		case 'I':
			if(['1', 'l', 'I'].indexOf(s2)>-1){
				return true;
			}
			break;
	}
	return false;
};

var compare=function(a1, a2){
	var c=0;
	a1.forEach((i,k)=>{
		if(compareS(i, a2[k])){
			c++;
		}
	})
	return c==a1.length;
}

var magic=function(s1, s2){
	s1=s1.split('');
	s2=s2.split('');
	var diff1=[];
	var diff2=[];
	s1.forEach((i,k)=>{
		if(i!=s2[k]){
			diff1.push(i);
			diff2.push(s2[k]);
		}
	})
	return compare(diff1, diff2)
}

var loginToTest=readline();

var numOfLogins=+(readline());

var count=0;

while(count<numOfLogins){
	count++;
	var currentLogin=readline();
	if(currentLogin.length==loginToTest){
		if(magic(loginToTest, currentLogin)){
			print('No');
			//return false;
		}
	}
}
if(count==numOfLogins){
print('Yes');
}

var compareS=function(s1, s2){
	if(s1.toLowerCase()==s2.toLowerCase()){
		return true;
	}
	switch(s1){
		case 'O':
		case '0':
		case 'o':
			if(['0', 'O', 'o'].indexOf(s2)>-1){
				return true;
			}
			break;
		case '1':
		case 'l':
		case 'I':
			if(['1', 'l', 'I'].indexOf(s2)>-1){
				return true;
			}
			break;
	}
	return false;
};

var compare=function(a1, a2){
	var c=0;
	a1.forEach((i,k)=>{
		if(compareS(i, a2[k])){
			c++;
		}
	})
	return c==a1.length;
}

var magic=function(s1, s2){
	s1=s1.split('');
	s2=s2.split('');
	var diff1=[];
	var diff2=[];
	s1.forEach((i,k)=>{
		if(i!=s2[k]){
			diff1.push(i);
			diff2.push(s2[k]);
		}
	})
	return compare(diff1, diff2)
}

var loginToTest=readline();

var numOfLogins=+(readline());

var count=0;

while(count<numOfLogins){
	count++;
	var currentLogin=readline();
	if(currentLogin.length==loginToTest.length){
		if(magic(loginToTest, currentLogin)){
			print('No');
			//return false;
		}
	}
}
if(count==numOfLogins){
print('Yes');
}

var compareS=function(s1, s2){
    if(s1.toLowerCase()==s2.toLowerCase()){
        return true;
    }
    switch(s1){
        case 'O':
        case '0':
        case 'o':
            if(['0', 'O', 'o'].indexOf(s2)>-1){
                return true;
            }
            break;
        case '1':
        case 'l':
        case 'I':
            if(['1', 'l', 'I'].indexOf(s2)>-1){
                return true;
            }
            break;
    }
    return false;
};

var compare=function(a1, a2){
    var c=0;
    a1.forEach((i,k)=>{
        if(compareS(i, a2[k])){
            c++;
        }
    });
    return c==a1.length;
};

var magic=function(s1, s2){
    s1=s1.split('');
    s2=s2.split('');
    var diff1=[];
    var diff2=[];
    s1.forEach((i,k)=>{
        if(i!=s2[k]){
        diff1.push(i);
        diff2.push(s2[k]);
    }
})
    return compare(diff1, diff2)
}

var loginToTest=readline();

var numOfLogins=+(readline());

var count=0;
var f=0;
while(count<numOfLogins){
    count++;
    var currentLogin=readline();
    if(currentLogin.length==loginToTest.length){
        if(magic(loginToTest, currentLogin)){
            print('No');
            f=1;
        }
    }
}
if(f===0){
    print('Yes');
}

var compareS=function(s1, s2){
	if(s1.toLowerCase()==s2.toLowerCase()){
		return true;
	}
	switch(s1){
		case 'O':
		case '0':
		case 'o':
			if(['0', 'O', 'o'].indexOf(s2)>-1){
				return true;
			}
			break;
		case '1':
		case 'l':
		case 'I':
			if(['1', 'l', 'I'].indexOf(s2)>-1){
				return true;
			}
			break;
	}
	return false;
};

var compare=function(a1, a2){
	var c=0;
	a1.forEach((i,k)=>{
		if(compareS(i, a2[k])){
			c++;
		}
	})
	return c==a1.length;
}

var magic=function(s1, s2){
	s1=s1.split('');
	s2=s2.split('');
	var diff1=[];
	var diff2=[];
	s1.forEach((i,k)=>{
		if(i!=s2[k]){
			diff1.push(i);
			diff2.push(s2[k]);
		}
	})
	return compare(diff1, diff2)
}

var loginToTest=readline();

var numOfLogins=+(readline());

var count=0;
var f=0;
while(count<numOfLogins){
	count++;
	var currentLogin=readline();
	if(currentLogin.length==loginToTest){
		if(magic(loginToTest, currentLogin)){
			print('No');
			f=1;
			//return false;
		}
	}
}
if(f==1){
print('Yes');
}

var compareS=function(s1, s2){
	if(s1.toLowerCase()==s2.toLowerCase()){
		return true;
	}
	switch(s1){
		case 'O':
		case '0':
		case 'o':
			if(['0', 'O', 'o'].indexOf(s2)>-1){
				return true;
			}
			break;
		case '1':
		case 'l':
		case 'I':
			if(['1', 'l', 'I'].indexOf(s2)>-1){
				return true;
			}
			break;
	}
	return false;
};

var compare=function(a1, a2){
	var c=0;
	a1.forEach((i,k)=>{
		if(compareS(i, a2[k])){
			c++;
		}
	})
	return c==a1.length;
}

var magic=function(s1, s2){
	s1=s1.split('');
	s2=s2.split('');
	var diff1=[];
	var diff2=[];
	s1.forEach((i,k)=>{
		if(i!=s2[k]){
			diff1.push(i);
			diff2.push(s2[k]);
		}
	})
	return compare(diff1, diff2)
}

var loginToTest=readline();

var numOfLogins=+(readline());

var count=0;
var f=0;
while(count<numOfLogins){
	count++;
	var currentLogin=readline();
	if(currentLogin.length==loginToTest.length){
		if(magic(loginToTest, currentLogin)){
			print('No');
			f=1;
			//return false;
		}
	}
}
if(f==1){
print('Yes');
}

var compareS=function(s1, s2){
    if(s1.toLowerCase()==s2.toLowerCase()){
        return true;
    }
    switch(s1){
        case 'O':
        case '0':
        case 'o':
            if(['0', 'O', 'o'].indexOf(s2)>-1){
                return true;
            }
            break;
        case '1':
        case 'l':
        case 'I':
        case 'i':
            if(['1', 'l', 'I', 'i'].indexOf(s2)>-1){
                return true;
            }
            break;
    }
    return false;
};

var compare=function(a1, a2){
    var c=0;
    a1.forEach((i,k)=>{
        if(compareS(i, a2[k])){
            c++;
        }
    });
    return c==a1.length;
};

var magic=function(s1, s2){
    s1=s1.split('');
    s2=s2.split('');
    var diff1=[];
    var diff2=[];
    s1.forEach((i,k)=>{
        if(i!=s2[k]){
            diff1.push(i);
            diff2.push(s2[k]);
        }
    })
    return compare(diff1, diff2)
}

var loginToTest=readline();

var numOfLogins=+(readline());

var count=0;
var f=0;
while(count<numOfLogins+1){
    count++;
    var currentLogin=readline();
    if( currentLogin && currentLogin.length==loginToTest.length){
        if(magic(loginToTest, currentLogin)){
            print('No');
            f=1;
        }
    }
}
if(f===0){
    print('Yes');
}

var s1 = readline();
var s2 = parseInt(readline());
var arr = [];

for(var i = 0; i < s2; i++){
    arr.push(readline());
}

function task(){
    if(register(s1) === true && check(s1) === true) return "Yes";
    else return "No";
}

function register(string){
    for(var i = 0; i < arr.length; i++){
        if(s1.length !== arr[i].length) return false;
    }
    for(var i = 0; i < arr.length; i++){
        if(arr[i].toLowerCase() === string.toLowerCase()) return false;
    }
    return true;
}

function check(string){
    var word = string.split('');
    var ind = [];
    for(var i = 0; i < arr.length; i++){
        var buff = arr[i].split('');
        for(var j = 0; j < buff.length; j++){
            if(buff[j] === 'O' || buff[j] === '0' || buff[j] === '1' || buff[j] === 'l' || buff[j] === 'I' || buff[j] === 'i'){
                ind.push({index: j, el: buff[j]});
            }
        }
    }

    for(var i = 0; i < ind.length; i++){
        for(var j = 0; j < word.length;){
            if(ind[i].el === 'O' && word[j] === '0' && ind[i].index === j) return false;
            if(ind[i].el === '0' && word[j] === 'O' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'l' && ind[i].index === j) return false;
            if(ind[i].el === 'l' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'I' && ind[i].index === j) return false;
            if(ind[i].el === 'I' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'i' && ind[i].index === j) return false;
            if(ind[i].el === 'i' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === 'L' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'L' && ind[i].index === j) return false;
            j++;
        }
    }
    return true;
}

write(task());

var user_input = readline().split("");
var number = parseInt(readline());
var logged = [];
for (var i = 0; i < number; i++) {
    logged.push(readline().split(""));
}
var numberSample = 0;
var res = true;
for (var i = 0; i < logged.length; i++) {
    if (logged[i].length != user_input.length) {
        res = false;
        continue;
    }
    for (var j = 0; j < logged[i].length; j++) {
        if (logged[i][j] == "0" || logged[i][j] == "o" || logged[i][j] == "O") {
            logged[i][j] = ".";
        }
        if (user_input[j] == "0" || user_input[j] == "o" || user_input[j] == "O") {
            user_input[j] = ".";
        }
        if (logged[i][j] == "1" || logged[i][j] == "l" || logged[i][j] == "I" || logged[i][j] == "i" || logged[i][j] == "L") {
            logged[i][j] = "*";
        }
        if (user_input[j] == "1" || user_input[j] == "l" || user_input[j] == "I" || user_input[j] == "i" || user_input[j] == "L") {
            user_input[j] = "*";
        }
        if (user_input[j] == logged[i][j]) {
            numberSample++;
        }
    }
    if (user_input.length == numberSample) {
        res = false;
        numberSample = 0;
    }
}
if (!res) write("No");
else write("Yes");

var user_input = readline();
var number = parseInt(readline());
var logged = [];
for (var i = 0; i < number; i++) {
    logged.push(readline().split(""));
}
var numberSample = 0;
var res = true;
for (var i = 0; i < logged.length; i++) {
    if (logged[i].length != user_input.length) {
        res = false;
        continue;
    }
    for (var j = 0; j < logged[i].length; j++) {
        if (logged[i][j] == "0" || logged[i][j] == "o" || logged[i][j] == "O") {
            logged[i][j] = ".";
        }
        if (user_input[j] == "0" || user_input[j] == "o" || user_input[j] == "O") {
            user_input[j] = ".";
        }
        if (logged[i][j] == "1" || logged[i][j] == "l" || logged[i][j] == "I" || logged[i][j] == "i") {
            logged[i][j] = "*";
        }
        if (user_input[j] == "1" || user_input[j] == "l" || user_input[j] == "I" || user_input[j] == "i") {
            user_input[j] = "*";
        }
        if (user_input[j] == logged[i][j]) {
            numberSample++;
        }
    }
    if (user_input.length == numberSample) {
        res = false;
        numberSample = 0;
    }
}
if (!res) write("No");
else write("Yes");

var user_input = readline().split("");
var number = parseInt(readline());
var logged = [];
for (var i = 0; i < number; i++) {
    logged.push(readline().split(""));
}
var numberSample = 0;
var res = true;
for (var i = 0; i < logged.length; i++) {
    if (logged[i].length != user_input.length) {
        res = false;
        continue;
    }
    for (var j = 0; j < logged[i].length; j++) {
        if (logged[i][j] == "0" || logged[i][j] == "o" || logged[i][j] == "O") {
            logged[i][j] = ".";
        }
        if (user_input[j] == "0" || user_input[j] == "o" || user_input[j] == "O") {
            user_input[j] = ".";
        }
        if (logged[i][j] == "1" || logged[i][j] == "l" || logged[i][j] == "I" || logged[i][j] == "i" || logged[i][j] == "L") {
            logged[i][j] = "*";
        }
        if (user_input[j] == "1" || user_input[j] == "l" || user_input[j] == "I" || user_input[j] == "i" || user_input[j] == "L") {
            user_input[j] = "*";
        }
        if (user_input[j] == logged[i][j]) {
            numberSample++;
        }
    }
    if (user_input.length == numberSample) {
        res = false;
    }
    numberSample = 0;
}
if (!res) write("No");
else write("Yes");

var s1 = readline();
var s2 = parseInt(readline());
var arr = [];

for(var i = 0; i < s2; i++){
    arr.push(readline());
}

function task(){
    if(register(s1) === true && check(s1) === true) return "Yes";
    else return "No";
}

function register(string){
    for(var i = 0; i < arr.length; i++){
        if(s1.length !== arr[i].length) return false;
    }
    for(var i = 0; i < arr.length; i++){
        if(arr[i].toLowerCase() === string.toLowerCase()) return false;
    }
    return true;
}

function check(string){
    var word = string.split('');
    var ind = [];
    for(var i = 0; i < arr.length; i++){
        var buff = arr[i].split('');
        for(var j = 0; j < buff.length; j++){
            if(buff[j] === 'O' || buff[j] === '0' || buff[j] === '1' || buff[j] === 'l' || buff[j] === 'I' || buff[j] === 'i' || buff[j]==='L'){
                ind.push({index: j, el: buff[j]});
            }
        }
    }

    for(var i = 0; i < ind.length; i++){
        for(var j = 0; j < word.length;){
            if(ind[i].el === 'O' && word[j] === '0' && ind[i].index === j) return false;
            if(ind[i].el === '0' && word[j] === 'O' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'l' && ind[i].index === j) return false;
            if(ind[i].el === 'l' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'I' && ind[i].index === j) return false;
            if(ind[i].el === 'I' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'i' && ind[i].index === j) return false;
            if(ind[i].el === 'i' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === 'L' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'L' && ind[i].index === j) return false;
            j++;
        }
    }
    return true;
}

write(task());

var s1 = readline();
var s2 = parseInt(readline());
var arr = [];

for(var i = 0; i < s2; i++){
    arr.push(readline());
}

function task(){
    if(register(s1) === true && check(s1) === true) return "Yes";
    else return "No";
}

function register(string){
    for(var i = 0; i < arr.length; i++){
        if(s1.length !== arr[i].length) return false;
    }
    for(var i = 0; i < arr.length; i++){
        if(arr[i].toLowerCase() === string.toLowerCase()) return false;
    }
    return true;
}

function check(string){
    var word = string.split('');
    var ind = [];
    for(var i = 0; i < arr.length; i++){
        var buff = arr[i].split('');
        for(var j = 0; j < buff.length; j++){
            if(
                buff[j] === 'O' ||
                buff[j] === '0' ||
                buff[j] === '1' ||
                buff[j] === 'l' ||
                buff[j] === 'I' ||
                buff[j] === 'i' ||
                buff[j] === 'L' ||
                buff[j] === 'o'
            ){
                ind.push({index: j, el: buff[j]});
            }
        }
    }

    for(var i = 0; i < ind.length; i++){
        for(var j = 0; j < word.length;){
            if(ind[i].el === 'O' && word[j] === '0' && ind[i].index === j) return false;
            if(ind[i].el === '0' && word[j] === 'O' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'l' && ind[i].index === j) return false;
            if(ind[i].el === 'l' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'I' && ind[i].index === j) return false;
            if(ind[i].el === 'I' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'i' && ind[i].index === j) return false;
            if(ind[i].el === 'i' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === 'L' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'L' && ind[i].index === j) return false;
            if(ind[i].el === 'o' && word[j] === '0' && ind[i].index === j) return false;
            if(ind[i].el === '0' && word[j] === 'o' && ind[i].index === j) return false;
            j++;
        }
    }
    return true;
}

write(task());

var user_input = readline().split("");
var number = parseInt(readline());
var logged = [];
for (var i = 0; i < number; i++) {
    logged.push(readline().split(""));
}
var numberSample = 0;
var res = true;
for (var i = 0; i < logged.length; i++) {
    if (logged[i].length != user_input.length) {
        res = false;
        continue;
    }
    for (var j = 0; j < logged[i].length; j++) {
        if (logged[i][j] == "0" || logged[i][j] == "o" || logged[i][j] == "O") {
            logged[i][j] = ".";
        }
        if (user_input[j] == "0" || user_input[j] == "o" || user_input[j] == "O") {
            user_input[j] = ".";
        }
        if (logged[i][j] == "1" || logged[i][j] == "l" || logged[i][j] == "I" || logged[i][j] == "i" || logged[i][j] == "L") {
            logged[i][j] = "*";
        }
        if (user_input[j] == "1" || user_input[j] == "l" || user_input[j] == "I" || user_input[j] == "i" || user_input[j] == "L") {
            user_input[j] = "*";
        }
        if (user_input[j].toLowerCase() == logged[i][j].toLowerCase()) {
            numberSample++;
        }
    }
    if (user_input.length == numberSample) {
        res = false;
    }
    numberSample = 0;
}
if (!res) write("No");
else write("Yes");