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

let ls = [];

function solve(){
    const len = parseInt(ls[0]);
    for (let i = 1; i <= len; i++){
        console.log(Math.pow(2, parseInt(ls[i])) - 1);
    }
}

rl.on('line', (l) => ls.push(`${l}`));
rl.on('close', () => solve());


MOD = 1000000000+7;

function main() {
	var n = +readline();
	var answer = 1;
	for (var i = 0; i < n*3; i++) {
		answer *= 3;
		answer %= MOD;
	}
	// 2..
	// 1 2 3
	b = 1;
	for (var i  =0; i < n; i++)
	{
		b *= 7
		b %= MOD;
	}
	answer = (MOD + answer - b);
	answer %= MOD;

	// 3 2 1
	//answer -= 3;

	write(answer);
}

main();


input1=readline();
input=readline();
cnt=0
for ( index = 1; index < input.length; index++) {
     element = input[index];
    if(element===input[index-1])cnt++;
}
print(cnt)


function solve(){
    var a = readline();
    var last = 1;
    var res = 0;
    for(var i = 1; i < a.length; i++){
        if(a[i] != a[i-1]){
            if(last % 2 == 0) ++res;
            last = 1;
        } else {
            last++;
        }
    }
    if(last % 2 == 0) ++res;
    print(res);
}
solve();


function checkAlenasMoney(n, a, b, c)
{
    function increase(n1, n2)
    {
        return n1 - n2;
    }
    var arr = [a, b, c];
    var k = 0;
    while ((n + k) % 4 !== 0)
    {
        k++;
    }
    if (k === 0) return 0;
    else
    {
        if (k === 1)
        {
            arr = [a, c + b, 3 * c];
            return arr.sort(increase)[0];
        }
        if (k === 2)
        {
           arr = [b, 2 * a, 2 * c];
           return arr.sort(increase)[0];
        }
        if (k === 3)
    {
        arr = [c, 3 * a, b + a, 2 * c + a];
        return arr.sort(increase)[0];
    }
    }
}

{
    var input = readline();
    input = input.split(' ');
    print(checkAlenasMoney(+input[0], +input[1], +input[2], +input[3]));
}


String.prototype.lpad = function(padString, length) {
    var str = this;
    while (str.length < length)
        str = padString + str;
    return str;
};

var currentTime = readline().split(":");
currentTime[0] = parseInt(currentTime[0]);
currentTime[1] = parseInt(currentTime[1]);
var sleepLength = readline().split(":");
sleepLength[0] = parseInt(sleepLength[0]);
sleepLength[1] = parseInt(sleepLength[1]);

var sleepTimeHours = (currentTime[0] - sleepLength[0]);
var sleepTimeMinutes = (currentTime[1] - sleepLength[1]);

if (sleepLength[1] > currentTime[1]) {
  sleepTimeHours--;
}

if (sleepTimeHours < 0) sleepTimeHours = 24 + sleepTimeHours;
if (sleepTimeMinutes < 0) sleepTimeMinutes = 60 + sleepTimeMinutes;

var sleepTime = sleepTimeHours.toString().lpad("0", 2) + ":" + sleepTimeMinutes.toString().lpad("0", 2);

print(sleepTime);


var p = readline().split(" ").map(Number);
print((p[1] - p[0])/(p[2] + p[3]));


var values = readline().split(' ').map((elements)=>{
	return parseInt(elements)
})
var circleDistance = 2*values[0]
var path = Math.ceil( Math.sqrt(
	Math.pow(values[1] - values[3],2) + Math.pow(values[2] - values[4],2)
	)/circleDistance)
print(path)


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

rl.on('line', (d) => {
    const arr = d.split(' ').map(Number);
    let point = Infinity;

    for (let i = 0; i <= 2; i++) {
        if (point + i > arr[i]) {
            point = arr[i] - i;
        }
    }

    console.log(point * 3 + 3);
});


var n = (parseInt(readline()) + 1)%6,
    x = parseInt(readline())

//console.log(x,n)
switch (x) {
  case 0:
    switch (n) {
      case 0:
      case 1:
        print(0)
      break;
      case 2:
      case 3:
        print(1)
      break;
      case 4:
      case 5:
        print(2)
      break;
    }
  break;

  case 1:
    switch (n) {
      case 0:
      case 3:
        print(2)
      break;
      case 2:
      case 5:
        print(0)
      break;
      case 4:
      case 1:
        print(1)
      break;
    }
  break;

  case 2:
    switch (n) {
      case 0:
      case 5:
        print(1)
      break;
      case 4:
      case 3:
        print(0)
      break;
      case 2:
      case 1:
        print(2)
      break;
    }
  break;
}


var input = readline()
var touched = Array(parseInt(input)).fill(false)
var step = 1

for(var i=0;i<=input;i++){
    step += i
  	if(step>input) step-=input
  	touched[step]=true
}

var isAllVisited=true
for(var i=1;i<=input;i++){
    if(!touched[i]) isAllVisited=false
}

isAllVisited? print("YES"):print("NO")


'use strict'

let lll = readline()

let max = 0

for (let i = 0; i < lll.length; i++)
  for (let j = max + 1; j < lll.length - i; j++)
    if (lll.lastIndexOf(lll.slice(i, i + j)) != i)
      max = j

print(max)


var n = +readline();

var min = 0;
for(var i = 6, j = 7; ; i += 7, j += 7){
    if(i <= n){
        min++;
    }else break;
    if(j <= n){
        min++;
    }else break;
}

var max = 0;
for(var i = 1, j = 2; ; i += 7, j += 7){
    if(i <= n){
        max++;
    }else break;
    if(j <= n){
        max++;
    }else break;
}

write(min, max);


l=readline();
g=readline().split('');

var toS=0, toF=0;

for (i=0; i<(l-1); i++) {
  if (g[i]=="S" && g[i] != g[i+1]) toF++;
  if (g[i]=="F" && g[i] != g[i+1]) toS++
}

if (toF>toS) print("YES")
else print("NO")


var t = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

var inp = readline().split(' ');
var n = inp[0];
var type = inp[2];

if (type == "week") {
    var current = 5;
    var a = 0;
    for (var i = 0; i < 366; ++i) {
        if(current == n)
            ++a;
        ++current;
        if(current > 7)
            current = 1;
    }
    print(a);
} else {
    var a = 0;
    for (var i = 0; i < 12; ++i) {
        a += n <= t[i];

    }
    print(a);
}


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

rl.on('line', (d) => {
  let [n, k] = d.split(' ').map(Number);

  let mid = Math.floor(n / 2);
  let x = mid % (k + 1);
  let a = (mid - x) / (k + 1);
  let b = a * k;
  let c = n - a - b;

  console.log(`${a} ${b} ${c}`);
});


(function() {
  var s = readline();

  if (s.length < 26) {
    print(-1);
    return 0;
  }

  const alph = 'abcdefghijklmnopqrstuvwxyz';

  var sIdx = 0;
  var resultString = '';

  for (var i = 0; i < alph.length; i++) {
    if (sIdx >= s.length) {
      print(-1);
      return 0;
    }

    var aLetter = alph[i];
    var searchNeeded = true;

    while (searchNeeded && sIdx < s.length) {
      var sLetter = s[sIdx];

      if (sLetter <= aLetter) {
        resultString += aLetter;
        searchNeeded = false;
      } else {
        resultString += sLetter;
      }

      sIdx++;
    }
  }

  for (var i = sIdx; i < s.length; i++) {
    resultString += s[i];
  }

  print(resultString);
  return 0;
})();


var N = parseInt(readline());
var arr = readline().split("");
var localCounter = 0;
var res = 0;

arr.map(function(el) {
  if (el === 'x') {
    localCounter++;
    if (localCounter > 2) {
      res++;
    }
  } else {
    localCounter = 0;
  }
});

print(res);


var s = readline();
var t = readline();

var b = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p',
	'q','r','s','t','u','v','w','x','y','z'];

var ans="";
var p = 1;
for(var i=s.length-1; i>=0; i--){
	for(var ind=0; b[ind]!=s[i]; ind++);
	if(ind+p>=b.length){
		ind = 0 + p - 1;
		p = 1;
	}else{
		ind = ind+p;
		p = 0;
	}

	ans+=b[ind];
}
var ansRev="";
	for(var i=s.length-1; i>=0; i--)
		ansRev+=ans[i];
if(p!=0 || ansRev>=t)
	print('No such string');
else{
	print(ansRev);
}


function abs(q)
{
    if (q>0){return q;}
    return -q
}

s=readline().split(' ').map(function(x){return +x;})
a=+s[0]
b=+s[1]
s=readline().split(' ').map(function(x){return +x;})
c=+s[0]
d=+s[1]
u=0
if (a==c||b==d)
{
    u=2
}
print(abs(a-c)*2+abs(b-d)*2+4+u)


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

let inp = 0
process.stdin.on("data",input=>{
    inp = input
})
process.stdin.on("end",input=>{
    inp = inp.replace(/\s*$/, '').split("\n").map(str => str.replace(/\s*$/, ''));

    main();

})

function main(){
    n = inp[0].split(" ")[0]
    k = inp[0].split(" ")[1]

    let allscores = inp[1].split(" ").map(item=>{return parseInt(item)})

    let gecen = allscores.filter((item)=>{return item >= allscores[k-1]}).filter(item=>{return item>0})
    console.log(gecen.length)

}


/**
Polycarp has just invented a new binary protocol for data transmission. He is encoding positive integer decimal number to binary string using following algorithm:

Each digit is represented with number of '1' characters equal to the value of that digit (for 0 it is zero ones).
Digits are written one by one in order corresponding to number and separated by single '0' character.
Though Polycarp learnt how to encode the numbers, he has no idea how to decode them back. Help him calculate the decoded number.

Input
The first line contains one integer number n (1 ≤ n ≤ 89) — length of the string s.

The second line contains string s — sequence of '0' and '1' characters, number in its encoded format. It is guaranteed that the number corresponding to the string is positive and doesn't exceed 109. The string always starts with '1'.

Output
Print the decoded number.

Examples
input
3
111
output
3
input
9
110011101
output
2031

 */

let inputString = '';

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

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

    let lengthOfString = Number(inputString[0]);
    let string = inputString[1];

    solution(lengthOfString, string);

});

function solution(lengthOfString, string) {

    let onesCount = 0;
    let zeorCount = '';
    let digit = [];

    for (let index = 0; index < lengthOfString; index++) {

        if (string[index] == '1') {

            onesCount++;

            if (zeorCount.length > 1)
                digit.push(zeorCount.substring(0, zeorCount.length - 1));

            zeorCount = '';
        }

        if (string[index] == '0') {

            zeorCount += '0';

            if (onesCount)
                digit.push(onesCount.toString());

            onesCount = 0;
        }
    }

    if (onesCount)
        digit.push(onesCount.toString());

    if (zeorCount.length )
        digit.push(zeorCount);

    console.log(digit.join(""));

}


var arr1=readline().split(" ");
var arr2=readline().split(" ");
var n=readline();
var ans1=parseInt(parseInt(arr1[0])+parseInt(arr1[1])+parseInt(arr1[2]));
var ans2=parseInt(parseInt(arr2[0])+parseInt(arr2[1])+parseInt(arr2[2]));
var x =Math.ceil(parseFloat(ans1/5));
var y =Math.ceil(parseFloat(ans2/10));
if(parseInt(n)>=parseInt(x+y)){
    print("YES");
}
else{
    print("NO");
}


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");
   var start = Date.now();
   Main();
   var end = Date.now() - start;
   myerr("time : " + (end) + "ms");
   myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return 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){
    var returnObj = {
      list : input, index : 0, max : input.length,
      hasNext : function(){return (this.index < this.max);},
      next : function(){
        if(!this.hasNext()){

            throw "ArrayIndexOutOfBoundsException これ以上ないよ";
        }
        else{
            var returnInput = this.list[this.index];
            this.index++;
            return returnInput;
        }
    }};
    return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
      //[no]要素の扱い。数値型
      //不明値、異常時:引数そのまま返す 1:数値へ変換
      //2:半角SPで分割 4:半角SPで分割し、数値配列へ
      //6:1文字で分割  7:1文字で分割し、数値配列へ
      //8:半角SPで結合 9:改行で結合 0:文字なしで結合
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;
    }
}
function Main(){
    var output = [];

    var ul = next();
    var arr = nextIntArray() ;
    var brr = nextIntArray() ;
    arr.sort() ;
    brr.sort();
    var crr = arr.filter(x=>brr.includes(x));
    if(crr.length > 0) {
        myout(crr[0]) ;
    }
    else {
        var l = Math.min(arr[0],brr[0]) ;
        var h = Math.max(arr[0],brr[0]) ;
        myout(l+""+h)
    }

}


var N = parseInt(readline());
var ar = readline().split(' ').map(function(a) {return parseInt(a);});
ar.sort(function(a, b) { return a-b;});

var sum = 0;
for (var i = 0; i < ar.length; i++) {
  sum += ar[i];
}

var r = 0;
var navg = Math.round( sum / ar.length );

for (var i = 0; i < ar.length && navg < 5; i++) {
  sum -= ar[i];
  sum += 5;
  navg = Math.round( sum / ar.length );
  r++;
}

print(r);


"use strict";
Array.prototype.contains = function(el){
  return this.indexOf(el) > -1;
};

var rotateArray = function rotateArray(arr){
  arr.unshift(arr.pop());
  return arr;
};

print(function(input){
  input = input.split('');
  var len = input.length;
  var arr = [];
  var i = 0;
  var count = 0;
  while (i < len) {
    //print(i, len);
    input = rotateArray(input);
    var add = input.join('');
    if (!arr.contains(add)){
      count++;
      arr.push(add);
      //print("we here with", input);
      //print(arr);
    }
    i++;
  }
  return count;
}.apply(null, readline().split(" ")));


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

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

  b = +d;
  const a1 = Math.floor(Math.abs(a - b) / 2);
  const b1 = Math.ceil(Math.abs(a - b) / 2);
  const leftSum = a1 * (a1 + 1) / 2;
  const rigthSum = b1 * (b1 + 1) / 2;
  const ans = leftSum + rigthSum;

  console.log(ans);

  c++;
});


var line = readline();
var isOne = false;
var counter = 0;
var found = false;
for (var i = 0; i < line.length; i++) {
    if ((line[i] === '1' && isOne) || (line[i] === '0' && !isOne)) {
        counter++;
    } else {
        counter = 1;
        isOne = (line[i] === '1');
    }
    if (counter === 7) {
        print('YES');
        found = true;
        break;
    }
}
if (!found) {
print('NO');
}


// https://codeforces.com/problemset/problem/596/A
// Big O:
// Time complexity:
// Space complexity:

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

let numberOfVertices;
let vertices = [];
rl.on('line', (input) => {
    if (!numberOfVertices) {
        numberOfVertices = parseInt(input);
        return;
    }

    const verticesArray = input.split(" ").map(Number)
    const x = verticesArray[0];
    const y = verticesArray[1];
    vertices.push({ x, y });

    if (vertices.length === numberOfVertices) {
        console.log(findRectangleArea(numberOfVertices, vertices));
        rl.close();
    }

});

// Problem
function findRectangleArea(numberOfVertices, vertices) {

    const xPositions = new Set();
    const yPositions = new Set();

    for (let vertex of vertices) {
        xPositions.add(vertex.x);
        yPositions.add(vertex.y);
    }

    if (xPositions.size < 2 || yPositions.size < 2) {
        return -1;
    }

    const xPositionsArray = Array.from(xPositions)
    const yPositionsArray = Array.from(yPositions)

    return Math.abs((xPositionsArray[0] - xPositionsArray[1]) * (yPositionsArray[0] - yPositionsArray[1]));
}


'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

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

function output(x) {
    if (typeof x !== 'string') {
        x = x.toString();
    }
    //process.stdout.write(x);   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

function main() {
    /*let N = readline();

    for (let test = 0; test < N; test++) {*/
        let [r, c] = readline().split(' ');
        r = BigInt(r);
        c = BigInt(c);
        if (c == BigInt(1)) {
            output(r - BigInt(1));
        } else {
            output((c - BigInt(1)) * r);
        }
    /*}*/
}


function main() {
  var input = readline().split(' ').map(Number);
  var n = input[0];
  var t = input[1];

  var count = 0;

  function isBigEnough(element, index, array) {
    return element >= 1;
  }

  var array = [t];
  count += array.filter(isBigEnough).length;
  for (var i = 2; i <= n; ++i) {
    var next_array = [];
    for (var j = 0; j < i; ++j) {
      var value = 0;
      if (j - 1 >= 0) {
        value += Math.max(0, array[j - 1] - 1);
      }
      if (j < array.length) {
        value += Math.max(0, array[j] - 1);
      }
      value /= 2;
      next_array.push(value);
    }
    array = next_array;
    count += array.filter(isBigEnough).length;
  }

  print(count);
}

main();


var a = readline()

var dict = "aouie"
var b = true

for(var i = 0;i < a.length;i++){
	if(dict.indexOf(a[i]) == -1){
		if(dict.indexOf(a[i + 1]) != -1 || a[i] == "n"){
			continue;
		} else {
			b = false
			break
		}
	}
}

if(b && (dict.indexOf(a[a.length - 1]) != -1 || a[a.length - 1] == "n")){
	print("YES")
} else {
	print("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++];
}

const store = {};

function main() {
	let [n, m] = readLine()
		.split(' ')
		.map(x => x >> 0);

	if (m > n) {
		console.log(-1);
		return;
	}

	let steps = (n & 1) === 0 ? n >> 1 : (n >> 1) + 1;

	if (steps % m === 0) {
		console.log(steps);
		return;
	}

	let found = false;
	while (steps <= n) {
		steps++;
		if (steps % m === 0) {
			found = true;
			break;
		}
	}

	found ? console.log(steps) : console.log(-1);
}


function getOutput(n, a, x, b, y) {
    const maxNumberOfSteps = n;
    for (var currentMinute = 0; currentMinute < maxNumberOfSteps; currentMinute++) {
        var danielCurrentStation = (a + currentMinute) % maxNumberOfSteps;
        if (danielCurrentStation === 0) {
            danielCurrentStation = n;
        }
        var vladCurrentStation = (b - currentMinute) % maxNumberOfSteps;
        if (vladCurrentStation < 0) {
            vladCurrentStation = n + vladCurrentStation;
        }
        if (vladCurrentStation === 0) {
            vladCurrentStation = n;
        }
        if (danielCurrentStation === vladCurrentStation) {
            return 'YES';
        }
        if (danielCurrentStation === x || vladCurrentStation === y) {
            break;
        }
    }
    return 'NO';
}

function main() {
    var line;
    while (line = readline()) {
        line = line.split(' ');
        var n = parseInt(line[0]);
        var a = parseInt(line[1]);
        var x = parseInt(line[2]);
        var b = parseInt(line[3]);
        var y = parseInt(line[4]);
        print(getOutput(n, a, x, b, y));
    }
}

main();


var num = readline();

// var num = '1000000000'

function multiplyNines(num) {
  var hi = 1;
  for (var i = 0; i < num.length-1; i++) {
    hi *= 9;
  }

  return hi + ''
}

function allNines(num) {
  var arr=[]
  for (var i = 0; i < num.length-1; i++) {
    arr.push(9);
  }

  return parseInt(arr.join(''))
}

function main(num) {
  //add less than 2 case
  if (num.length === 1) {
    return parseInt(num);
  } else if (num[0] === '1') {
    return multiplyNines(num)
  } else {
    return Math.max(parseInt(num[0])*main(num.split('').slice(1).join('')), (parseInt(num[0]) - 1)*parseInt(multiplyNines(num)));
  }
}

write(main(num))


var n = parseInt(readline());
var arr = readline().split(' ').map(Number);

var max = arrayMax(arr);
var min = arrayMin(arr);

var startIndex = 0;
var endIndex = 0;

	var startCounting = false;

	for (var i = 0; i < n; i++) {
		if ((arr[i] == max || arr[i] == min) && !startCounting)
		{
			startCounting = true;
			startIndex = i;
			i++;
		}
		if ((arr[i] == max || arr[i] == min) && startCounting)
		{

			startCounting = false;
			endIndex = i;
			break;
		}
	}

var maxarr = [];
maxarr.push(endIndex - startIndex);
maxarr.push(endIndex);
maxarr.push(startIndex);
maxarr.push(arr.length - 1 - startIndex);
maxarr.push(arr.length - 1 - endIndex);

function arrayMin(array) {
  var len = array.length, min = Infinity;
  while (len--) {
    if (array[len] < min) {
      min = array[len];
    }
  }
  return min;
};

function arrayMax(array) {
  var len = array.length, max = -Infinity;
  while (len--) {
    if (array[len] > max) {
      max = array[len];
    }
  }
  return max;
};

print(arrayMax(maxarr));


var a = readline().split(" ").map(Number);
var flag=true;
var moves = 1;
var path =""+a[1];
while(a[1] > a[0]) {
    moves++;
    if (a[1]% 2 === 0) {
        a[1]=a[1]/2;
    } else if(a[1]%10 === 1) {
        a[1]= (a[1]-1)/10;
    } else {
        print("NO");
        flag=false;
        break;
    }
    if (a[1] < a[0]) {
        print("NO");
        flag=false;
        break;
    }
    path = a[1]+" "+path;
}
if (flag) {
    print('YES');
    print(moves);
    print(path);
}


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++];
}
function main() {
  let [n, len] = readLine()
    .split(" ")
    .map((n) => parseInt(n));
  const arr = readLine()
    .split(" ")
    .map((n) => parseInt(n));
  arr.sort((a, b) => a - b);
  let min = Number.MAX_SAFE_INTEGER;

  for (let i = 0; i <= len - n; i++) {
    const [low, high] = [arr[i], arr[i + n - 1]];
    min = Math.min(min, high - low);
  }

  console.log(min);
}


// Sample code to perform I/O:

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
    main(stdin_input);
});

function main(input) {
    let output = nameLookUp(input);
    process.stdout.write(output);       // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

// Write your code here
function nameLookUp(str) {
    let input = str.trim().split('\n');
    let numeric = input[0].split(' ');
    let seconds = +numeric[1];
    let bg = input[1].split('');
    let newbg = [...bg];
    for (let i = 0; i < seconds; i++) {

        for (let i = 1; i < bg.length; i++) {
            if (bg[i - 1] < bg[i]) {
                let temp = bg[i - 1];
                newbg[i - 1] = bg[i];
                newbg[i] = temp;
            }
        }
        bg = newbg;
        newbg = [...bg];
    }
    return bg.join('').toString();
}


var nk = readline().split(' ').map(el => parseInt(el, 10)),
    num = nk[0];

for(var i=1; i<=nk[1]; i++) {
    if(num%10 === 0) num /= 10;
    else num--;
}

print(num);


var arr = readline().split(" ", 2);
if (arr[0] === arr[1]) {
    print(arr[0]);
} else {
    print("1");
}


var s = []
for(var i=0;i<8;i++) s.push(readline());
var get = function(s, x, y) {
    if(s[x][y] == 'W') {
        for(var i=x-1;i>=0;i--) if(s[i][y] == 'B') return -1;
        return x;
    } else if(s[x][y] == 'B') {
        for(var i=x+1;i<8;i++) if(s[i][y] == 'W') return -1;
        return 7 - x;
    } else {
        return -1;
    }
};
var getw = function(s) {
    for(var i=0;i<8;i++) {
        for(var j=0;j<8;j++) {
            if(s[i][j] == 'W' && get(s, i, j) != -1) return i;
        }
    }
    return -1;
}
var getb = function(s) {
    for(var i=7;i>=0;i--) {
        for(var j=0;j<8;j++) {
            if(s[i][j] == 'B' && get(s, i, j) != -1) return 7-i;
        }
    }
    return -1;
}
var answ = getw(s);
var ansb = getb(s);
if(ansb == -1 || answ <= ansb) print("A");
else print("B");
// print(answ, "," , ansb);


var names = new Array("Sheldon", "Leonard", "Penny", "Rajesh", "Howard");
var n = parseInt(readline());

n += 4;

var pow = Math.floor(Math.log(Math.floor(n * 2 / 5))/Math.log(2));
var pos = Math.floor((n - Math.pow(2, pow) * 5 / 2) / Math.pow(2, pow - 1));

print(names[pos]);


try {require('codef');} catch (e){};
function readLineAsArray(separator){
    return readline().split(typeof separator == "undefined" ? ' ' : separator)
}
function readLineAsIntegerArray(separator){
    return readLineAsArray(separator).map(function(v){return +v});
}

var arr = readLineAsIntegerArray('');
var length = arr.length;
var res = [];

while(1){
    var tepm = 0;
    arr.forEach(function(v, k){
        if (v > 0) {
            tepm += Math.pow(10, length - k - 1);
            arr[k]--;
        }
    });
    if (tepm == 0) break; else res.push(tepm);
}
write(res.length + "\n" + res.join(' '));


var n = +readline(),
input = readline().split(" "), min1 = +input[0], max1 = +input[1],
input = readline().split(" "), min2 = +input[0], max2 = +input[1],
input = readline().split(" "), min3 = +input[0], max3 = +input[1];
var i, j, k;

cycle:
for(i = max1; i >= min1; i--){

	if((n - i) < (min2 + min3)){
		continue;
	}

	j = (n-i > max2) ? max2 : n-i;
	for( ; j >= min2; j--){
		if((n - i - j) < min3){
			continue;
		}

		k = n - i - j;

		write(i + " " + j + " " + k);

		break cycle;
	}
}


var num = readline().split(' ');
var l = parseInt(num[0]);
var r = parseInt(num[1]);
if(r > l){
	print(2);
}else if(r == l){
	print(l);
}


print(function(a) {
	var sum = a.reduce(function(a, b) {return a + b;});
	if (sum % 2 === 1) return 'Impossible';
	sum = sum / 2;

	var ans = [0, 0, 0];
	for (var i = 0; i < 3; i++) {
		ans[i] = sum - a[(i + 2) % 3];
		if (ans[i] > a[i]) return 'Impossible';
	}
	return ans.join(' ');

}(readline().split(' ').map(Number)));


//Input
// var firstLine = "Is it a melon?"; //R: NO
// var firstLine = "Is it an apple?"; //R: YES
// var firstLine = "  Is     it a banana ?"; //R: YES
// var firstLine = "Is   it an apple  and a  banana   simultaneouSLY?"; //R: YES

var firstLine = readline();

retorno = eval(firstLine);

//Solution
function eval(firstLine){
    var str = firstLine;

    write(sleuth(str));
    // console.log(sleuth(str));
    return "Hola";
};

function sleuth(str){
    str = str.toLowerCase();
    //console.log(str);
    var vowels = "aeiouy";
    var char = "";
    var len = str.length;
    var answer = "NO";
    for(var i = len ; i >= 0 ; i--){
        if(str[i] >= "a" && str[i] <= "z"){
            char = str[i];
            break;
        };
    };
    if(char == "a" || char == "e" || char == "i" || char == "o" || char == "u" || char == "y"){
        answer = "YES"
    };
    return answer;
};


var tokens = [];
var numTokens = 0;
function next(){
	while(numTokens>=tokens.length){
		tokens = readline().split(/[\s]+/);
		numTokens = 0;
	}
	return tokens[numTokens++];
}
function invertir(n){
	return n.split("").reverse().join("");
}
function impri(n){
	if(n<10) return "0"+n;
	return ""+n;
}

function cumple(h,m){
	if(h<24 && m < 60)
		return invertir(impri(h)) == impri(m);
	return false;
}
function solve(h){
	while(h < 24*60 ){
		c = Math.floor(h/60);
		if(cumple(c,h-c*60))
			return h;
		h++;
	}
	return 0;
}
function main(){
	var a = next();
	var h = parseInt(a.substring(0,2),10)*60	+ parseInt(a.substring(3,5),10);
	h = solve(h+1);
	var c = Math.floor(h/60);
	var x = c;
	var y = h - c*60;
	print(impri(x)+":"+impri(y));
}
main();


var n = parseInt(readline());
var m = parseInt(readline());
var result = m % Math.pow(2, n);
print(result);


print(function(a, b) {
	var i, x, ans = [0, 0, 0];
	for (i = 1; i <= 6; i++) {
		x = Math.abs(i - a) - Math.abs(i - b);
		ans[x < 0 ? 0 : x === 0 ? 1 : 2]++;
	}
	return ans.join(' ');
}.apply(0, readline().split(' ').map(Number)));


var alphabet = ['a', 'b', 'c', 'd', 'e', 'f']

var input = readline().split(' ')

var n = input[0]

var strings = generateStrings(n)

var q = input[1]

var ops = {}

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

    input = readline().split(' ')
    ops[input[0]] = input[1]

}

print(
    strings
        .filter(function (string) {
            for (var i = 0; string.length > 1; i++) {
                var op = string.slice(0, 2)
                if (!ops[op]) { return false }
                string = ops[op] + string.slice(2)
            }
            return string === 'a'
        })
        .length
)

function generateStrings (NN) {

    var strings = []

    var K = NN - 1, k = 0,
        N = alphabet.length, n = 0,
        out = [],
        stack = []

    function next(){
        while (true) {
            while (n < alphabet.length) {
                out[k] = alphabet[n++];
                if (k == K) return out.slice(0);
                else {
                    if (n < alphabet.length) {
                        stack.push(k);
                        stack.push(n);
                    }
                    k++;
                    n = 0;
                }
            }
            if (stack.length == 0) break;

            n = stack.pop();
            k = stack.pop();
        }
        return false;
    }

    var str

    while (str = next()) {
        strings.push(str.join(''))
    }

    return strings

}


var line = readline().split(' ');
var d = parseInt( line[0] );
var sumTime = parseInt( line[1] );

var minTime = [];
var maxTime = [];
var minSum = 0;
var maxSum = 0;

for(var i=0; i<d; i++){
	line = readline().split(' ');
	var min = parseInt( line[0] );
	var max = parseInt( line[1] );
	minTime.push(min);
	maxTime.push(max);
	minSum += min;
	maxSum += max;
}

if( sumTime >= minSum && sumTime<= maxSum){
	print('YES');
	var time=maxSum;
	var ret = [];
	for(var i=0; i<d; i++){
		if( time == sumTime){
			ret[i] = maxTime[i];
		}else{
			ret[i] = minTime[i];
			time -= maxTime[i]-minTime[i];
			if( time < sumTime){
				ret[i] = minTime[i] + sumTime - time;
				time += sumTime - time;
			}
		}
	}
	print( ret.join(' ') );
}else{
	print('NO');
}


s = readline();

print(25 * (s.length + 1) + 1);


var obj = [];
obj[0] = parseInt(readline());
obj[1] = parseInt(readline());
obj[2] = parseInt(readline());
var max = obj[0] > Math.floor(obj[1]/2) ? 1 : 0;
max = Math.floor(obj[max]/(max*2||1)) > Math.floor(obj[2]/4) ? 2 : max;
obj[max] = obj[max] - obj[max]%(max*2||1);
var sum = 0;
var one = obj[max]/(max*2||1);

for (var i = 0; i < 3; i++) {
  sum += one*(i*2||1);
}

print(sum);


'use strict'

const {EOL} = require('os')

let ipt = ''
process.stdin.on('data', s => ipt += s)
process.stdin.on('end', () => {
  const n = +ipt.split(EOL).slice(0, -1)[0]
  let o = 'ROY'
  let r = (n - 3) / 4 | 0
  for (let i = 0; i < r; i++) o += 'GBIV'
  o += 'GBIV'.slice(0, (n - 3) % 4)
  console.log(o)
})


function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i], 10);
	};
	return tokens;
}

function gcd(a, b) {
	while (a != 0 && b != 0) {
		if (a > b) {
			a %= b;
		}
		else {
			b %= a;
		}
	}
	return Math.max(a, b);
}

function solve(screenWidth, screenHeight, movieWidth, movieHeight) {
	var bottom = movieWidth*screenHeight,
		top = bottom - movieHeight*screenWidth,
		factor = gcd(top, bottom);
	return { top: top/factor, bottom: bottom/factor };
}

function main() {
	var data = tokenizeIntegers(readline()),
		screenWidth = data[0], screenHeight = data[1],
		movieWidth = data[2], movieHeight = data[3];

	if (screenWidth*movieHeight < movieWidth*screenHeight) {
		var solution = solve(screenWidth, screenHeight, movieWidth, movieHeight);
	}
	else {
		var solution = solve(screenHeight, screenWidth, movieHeight, movieWidth);
	}

	print(solution.top + "/" + solution.bottom);
}

main();


function main(){
    var n = +readline();
    for(var i = 0; i < n; ++i){
        var c = readline().split('');
        var l = 1;
        if(c.length === 2) l = 3;
        if(c.length === 3) l = 6;
        if(c.length === 4) l = 10;
        print(l + ((+c[0] - 1) * 10));
    }
}

main();


var line = readline().split(' ');
var n = parseInt(line[0]);
var v = parseInt(line[1]);
var arr = readline().split(' ');
var a = [];
var cur = [];
var sum = 0;
for (var i = 0; i < arr.length; i ++)
{
    a[i] = parseInt(arr[i]);
    cur[i] = a[i]%2===0?a[i]/2:parseInt(a[i]/2)+1;
    sum += cur[i];
}
if (sum > v)
{
    print(-1);
}
else
{
    while(v-sum > 0)
    {
        var max = 0;
        var maxi = 0;
        for (var i = 0; i < a.length; i ++)
        {
            if (a[i] > max && cur[i]!=a[i])
            {
                max = a[i];
                maxi = i;
            }
        }
        var put = Math.min(Math.min(v-sum), (a[maxi]-cur[maxi]));
        cur[maxi]+=put;
        sum+=put;
    }

    print( cur.join(" ") );
}


let i = ''

process.stdin.on('data',c => {
    i += c
})

process.stdin.on('end', () => {
    const { EOL } = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/

    let citiesCount = parseInt(lines[0].split(" ")[0])
    let limakCity = parseInt(lines[0].split(" ")[1])

    let criminals = lines[1].split(" ").map( value => {
        return parseInt(value)
    })

    let distanceCount = 0
    let caughtCriminalsCount = 0
    let passedCities = {}

    let limakCityIndex = limakCity - 1

    for(i = 0; i < citiesCount ; i++){

        distanceCount = Math.abs(i - limakCityIndex)

        let leftCityIndex =  limakCityIndex - distanceCount
        let rightCityIndex = distanceCount + limakCityIndex

        if (passedCities[rightCityIndex] === true || passedCities[leftCityIndex] === true) {
            continue
        }

        if (distanceCount === 0) {
            caughtCriminalsCount = caughtCriminalsCount + criminals[i]
            passedCities[i] = true
            distanceCount++
            continue
        }

        let rightCriminalCount = 0
        let leftCriminalCount = 0

        if (leftCityIndex >= 0) {
            passedCities[leftCityIndex] = true
            leftCriminalCount = criminals[leftCityIndex]
        } else {
            leftCriminalCount = -1
        }

        if (rightCityIndex < citiesCount) {
            passedCities[rightCityIndex] = true
            rightCriminalCount = criminals[rightCityIndex]
        } else {
            rightCriminalCount = -1
        }

        if (rightCriminalCount + leftCriminalCount === 2) {
            caughtCriminalsCount = caughtCriminalsCount + 2
        } else if (rightCriminalCount === 1 && leftCriminalCount === -1) {
            caughtCriminalsCount = caughtCriminalsCount + 1
        } else if (leftCriminalCount === 1 && rightCriminalCount === -1){
            caughtCriminalsCount = caughtCriminalsCount + 1
        }

        distanceCount++
    }
    console.log(caughtCriminalsCount)
})


'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 output(x) {
    if (typeof x !== 'string') {
        x = x.toString();
    }
    //process.stdout.write(x);   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

function main() {
    let N = readline();

    for (let test = 0; test < N; test++) {
        let x = Number(readline());
        let arr = readline().split(' ').map(Number);

        let result = 'YES';

        let first = arr[x - 1];
        let second = first ? arr[first - 1] : 0;

        if (first === 0) {
            result = 'NO';
        } else if (second === 0) {
            result = 'NO';
        }

        output(result);
    }
}


var importanceInPetriciumusCifera = function ( base, number ) {
  var rest,
    importance;
  rest = number;
  importance = 0;
  while ( rest % base === 0 && rest > base) {

    rest /= base;
    ++importance;
  }
  if ( rest === base ) {
    return importance;
  }
};

var k = parseInt( readline(), 10 );
var l = parseInt( readline(), 10 );
var importance = importanceInPetriciumusCifera( k, l );
if ( typeof importance !== "undefined" ) {
  print( "YES" );
  print( importance );
} else {
  print( "NO" );
}


var whoWinsFromTwo = function(n, p, winner)
    {
       if ((n === 1) || (p === 1)) return winner;
       else {
           winner = -winner;
           return whoWinsFromTwo(n - 1, p - 1, winner);
       }
    }
var input1 = readline();
input1 = input1.split(' ');
var person = 1;
var result = whoWinsFromTwo(+input1[0], +input1[1], person);
if (result < 0) print('Malvika');
else print('Akshat');


var n = parseInt(readline());
var ar = readline().split(' ').map((v)=>{return parseInt(v);}).sort((a,b)=>(b-a));

var marked = {0: true}
var markeda = {0: true}

var a = ar[0]

ar.forEach((o, i)=>{
    if (!markeda[o] && a%o==0) {
       markeda[o] = true;
       marked[i] = true;
    }
})

var b = ar.filter((x, i)=>(!marked[i]))[0]
print(a, b)


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

rl.on('line', (d) => {
  const arr = d.split(' ').map(Number);
  let ans = 0;
  const max = Math.max(...arr);

  for (let i = 0; i < arr.length - 1; i++) {
    for (let j = i + 1; j < arr.length; j++) {
      if (arr[i] + arr[j] <= max) {
        ans = max - (arr[i] + arr[j]) + 1;
      }
    }
  }

  console.log(ans);
});


let input = [];

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

RL.on('line', (line) => {
    let count_a = 0; [...line].forEach( i => {if(i === 'a') count_a++} );
    if(count_a > line.length - count_a)
        console.log(line.length);
    else
        console.log( line.length - ( line.length-count_a - count_a ) -1)
});

RL.on('close', () => {
});


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

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n')
  const ax = arr.shift().split(' ')
  const v = parseInt(ax[0])
  const e = parseInt(ax[1])

  if(e == 0) {
    console.log(0)
    return
  }
  if(v <= 6) {
    console.log(e)
  }

  else {
    let m = new Map()

    for(let i = 1; i <= v; i ++) {
      m.set(i, [])
    }

    for(let i = 0; i < e; i ++) {
      const edge = arr.shift().split(' ')
      const a = parseInt(edge[0])
      const b = parseInt(edge[1])
      m.get(a).push(b)
      m.get(b).push(a)
    }

    var f = false
    var noOfVertices = 20
    for(let j = 1; j <= 7; j ++) {
      var a7 = m.get(j)
      for(let i = 1; i <= 7; i ++) {
        if(i == j) continue
        var other = m.get(i)
        var x = a7.filter(el => other.indexOf(el) != -1)
        if(x.length == 0) {
          f = true
          break
        }
        else if(x.length < noOfVertices) {
          noOfVertices = x.length
        }
      }
    }
    if(f) {
      console.log(e)
    }

    else {
      console.log(e - noOfVertices)
    }
  }
})


ar = [];
n = +readline();
readline().split('').map(Number).forEach(x=>{
    if (x !== 0) ar.push(x);
});
found = (ar.length === 0)?true:false;
sum = 0;
for (i = 0;i<ar.length-1 && !found;i++){
    sum += ar[i];
    cur = 0;
    restart = true;
    for (j = i+1;j<ar.length;j++){
        cur += ar[j];
        if (cur === sum){
            cur = 0;
        } else if (cur > sum) break;
    }
    found = cur === 0;
}
print(found?'YES':'NO');


'use strict';

//const fs = require('fs');

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.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}
function main() {
    var n = parseInt(readLine(), 10);
    var coins = [];
    coins.push(n);
    for (var i = n - 1; i > 0; i--) {
        if ((n % i) == 0) {
            coins.push(i);
            n = i;
        }
    }
    console.log(coins.join(" "));

}


function main() {
    let line = stdin[0].split(' ');
    let n = parseInt(line[0], 10);
    let p = parseInt(line[1], 10);
    let k = parseInt(line[2], 10);

    const lo = Math.max(p - k, 1);
    const hi = Math.min(p + k, n);

    let str = [];

    if (lo !== 1) str.push("<<")

    for (let i = lo; i <= hi; ++i) {
       if (i === p) {
         str.push(`(${i})`);
       } else {
         str.push(i + '')
       }
    }

    if (hi !== n) str.push(">>")

    console.log(str.join(' '));
}

const readline = require('readline');
const rl = readline.createInterface({input: process.stdin});
var stdin = [];
rl.on('line', function (line) {stdin.push(line);});
rl.on('close', main);


var n=+readline();
var s=readline();
var ans=0;
s.replace(/B/g, function(_, i){
	ans+=Math.pow(2, i);
});
print(ans);


const readline = require('readline');

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

rl.on("line", (input)=>{
    if(!n) n = parseInt(input.split(" "))
    else
    {
        columns = input.split(" ");
        columns.sort((a,b)=>{return a-b});
        columns.forEach(element => {
            console.log(element);
        });
        rl.close();
    }

})


const memo = {};

function resolve(k, arr, n) {
  if (memo[arr.join('')] !== undefined) {
    return memo[arr.join('')];
  }
  if (parseInt(arr[0], 10) % 2 === 0 || parseInt(arr[k - 1], 10) % 2 === 0) {
    memo[arr.join('')] = false;
    return false;
  } else {
    if (k % 2 !== 0 && n % 2 !== 0) {
      memo[arr.join('')] = true;
      return true;
    } else {
      for (var i = 0; i < k; i += 2) {
        if (parseInt(arr[i], 10) % 2 !== 0) {
          if (resolve(arr.slice(i + 1).length, arr.slice(i + 1), n + 1)) {
            memo[arr.join('')] = true;
            return true;
          }
        }
      }

      for (var i = k - 1; i >= 0; i -= 2) {
        if (parseInt(arr[i], 10) % 2 !== 0) {
          if (resolve(arr.slice(0, i).length, arr.slice(0, i), n + 1)) {
            memo[arr.join('')] = true;
            return true;
          }
        }
      }
      memo[arr.join('')] = false;
      return false;
    }
  }
}

const k = parseInt(readline(), 10);
const arr = readline().split(' ');

const result = resolve(k, arr, 1);

print(result ? 'Yes' : 'No' + '\n');


var firstDay = getDayNumber(readline());
var secondDay = getDayNumber(readline());

print(firstDay === secondDay || (firstDay + 2) % 7 === secondDay % 7 || (firstDay + 3) % 7 === secondDay % 7 ? "YES" : "NO");

function getDayNumber(dayName) {
    switch (dayName.trim()) {
        case "monday":
            return 1;
        case "tuesday":
            return 2;
        case "wednesday":
            return 3;
        case "thursday":
            return 4;
        case "friday":
            return 5;
        case "saturday":
            return 6;
        case "sunday":
            return 7;
    }
}


'use strict'

let lll = readline().split(' ').map(v => parseInt(v))
let a = lll[0]
let b = lll[1]

let min = String(a).split('').reduce((r, v) => Math.max(r, v), 0)
min = String(b).split('').reduce((r, v) => Math.max(r, v), min)
min++

let max = 0
for (let i = min; i < 14; i++) {
  let da = parseInt(a, i)
  let db = parseInt(b, i)
  let ds = da + db
  let bs = from10(ds, i)
  max = Math.max(max, String(bs).length)
}

print(max)

function from10 (x, b) {
  let res = ''
  let n = 0
  while (Math.pow(b, ++n) <= x) {}
  while (n--) {
    let a = x / Math.pow(b, n) | 0
    if (b > 9) {
      res += 'a'
    } else {
      res += a
    }
    x -= a * Math.pow(b, n)
  }
  return res
}


function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var integers = tokenizeIntegers(readline());
	var fromR = integers[0], fromC = integers[1];
	var toR = integers[2], toC = integers[3];

	var rook = (fromR == toR || fromC == toC ? 1 : 2);

	if ((fromR+fromC)%2 != (toR+toC)%2) {
		var bishop = 0;
	}
	else {
		var bishop = (Math.abs(fromR - toR) == Math.abs(fromC - toC) ? 1 : 2);
	}

	var dr = Math.abs(fromR - toR), dc = Math.abs(fromC - toC);
	var king = dr + dc - Math.min(dr, dc);

	print(rook, bishop, king);
}

main();


var triangles=[0]
while(triangles[triangles.length-1]<=100000)
{
    triangles.push(triangles[triangles.length-1]+triangles.length);
}

var n=+readline()
var nows='qwertyuiopasdfghjklzxcvbnm'
var now=0
res=''
if (7==n)
{
    print("skorobogatova")
}
else if (0==n)
{
    print("danil")
}
else
{
    var i=triangles.length-1;
    while(n)
    {
        while(triangles[i]>n){i--;}
        n-=triangles[i]
        for (var j=0;j<=i;j++)
        {
            res+=nows[now];
        }
        now++;
    }
}
print(res)


/*
  Pick your own problems you fuck faced cunt.
*/
var radix=parseInt(readline());
for(var i = 1;i < radix; ++i){
  for(var j = 1;j < radix; ++j){
    write((i*j).toString(radix)+" ");
  }
  print();
}


var n = Number(readline());
var k = 1, sum = 0;
while (sum < n - k) {
    sum += k++;
}
print(n - sum);


var line = readline().split(' ');
var n = parseInt(line[0]);
var k = parseInt(line[1]);
var arr = readline().split(' ');
var list = [];

if (n === arr.length) {

for (var i = 0; i < arr.length; i++) {

  if (k % arr[i] === 0) {
    list.push(arr[i]);
  }

}

print(k / Math.max.apply(Math, list));

}


var n =readline()

var nLeft,nRight,qLeft,qRight

var aPos=n.indexOf('A')
var sum=0

while(aPos!=-1){
    nLeft=n.substring(0,aPos)
    nRight=n.substring(aPos+1,n.length)

    qLeft=(nLeft.match(/Q/g) || []).length
    qRight=(nRight.match(/Q/g) || []).length
    sum+= qLeft*qRight
    n=nLeft+nRight
    aPos=n.indexOf('A')
}
print(sum)


const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
rl.on('line', (inputString) => {
    let numberOfSquares = parseInt(inputString);
    console.log(findTheNumberOfLinesForLady(numberOfSquares));
    process.exit();
});

function findTheNumberOfLinesForLady(forTheNumberOfSquaress) {
    let a = Math.sqrt(forTheNumberOfSquaress);
    let b = Math.trunc(a);
    if (a == b) return (a + a);
    if (b * (b + 1) >= forTheNumberOfSquaress) return b + b + 1;
    return b + b + 2;
}


function getInput() {
    var line = readline();
    var lines = [line];
    while (line = readline()) {
        lines.push(line);
    }
    return lines;
}

function main() {
    var lines = getInput().map(item => item.split(' '));
    var durationA = Number(lines[0][1]);
    var durationB = Number(lines[1][1]);
    var repeatB = Number(lines[1][0]);

    // first bus run at 5:00.
    var firstBusTime = 5 * 60;
    // start time in minutes.
    var startTime = lines[2][0].split(':').map(Number);
    startTime = startTime[0] * 60 + startTime[1];

    var x1 = startTime;
    var y1 = x1 + durationA;

    var count = 0;
    for (var x2 = firstBusTime; x2 < 24 * 60; x2 += repeatB) {
        var y2 = x2 + durationB;
        var x = Math.max(x1, x2);
        var y = Math.min(y1, y2);

        if (x < y) {
            count++;
        }
    }

    print(count);
}

main()


"use strict";[]
/*** Custom Header For JAVASCRIPT ***/
var min = Math.min
var max = Math.max

//_f should be primitive
var nDArray = function(_a, _f)
{
	if(!Array.isArray(_a)) return null;
	if(_a.length==1)
	{
		var _ret = [];
		while(_ret.push(_f)<_a[0]);
		return _ret
	}
	var _ret = [];
	while(_ret.push(nDArray(_a.slice(1),_f))<_a[0]);
	return _ret;
}

var INF = 1e9+9;
/*** End of Custom Header ***/
var main = function()
{
	var N = +readline()
	var A = ("0 "+readline()).split(" ").map(Number)
	var dp = nDArray([N+1,3],0)
	dp[0][0] = 0;
	dp[0][1] = INF;
	dp[0][2] = INF;
	for(var i=1; i<=N; i++)
	{
		dp[i][0] = 1 + min(dp[i-1][0], min(dp[i-1][1], dp[i-1][2]) );
		dp[i][1] = min(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = min(dp[i-1][0], dp[i-1][1]);
		if(A[i]==2 || A[i]==0) dp[i][2]=INF;
		if(A[i]==1 || A[i]==0) dp[i][1]=INF;
	}
	var ans = min(dp[N][0], min(dp[N][1],dp[N][2]));
	write(ans)
}

main()


const readline = require('readline');

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

let grid = [];
// Read Inputs

rl.on('line', lineInput => {
    grid.push(lineInput);
})
rl.on('close', () => {
    let r = grid[0].split(" ")[0];
    let c = grid[0].split(" ")[1];

    // rows
    let clearRows = 0, rows = [];
    for (let i = 1; i <= r; i++) {
        const row = grid[i];
        rows.push(row)
        if (!row.split('').includes('S'))
            clearRows++;
    }

    // cols
    let clearCols = 0;
    for (let i = 0; i < c; i++) {
        let f = 0;
        for (let j = 0; j < r; j++) {
            const box = rows[j].split('')[i];
            if (box === 'S') { f = 1; break; }
        }
        if (!f)
            clearCols++;
    }
    let overlaps = clearCols * clearRows;
    let ans = ((clearCols * r) + (clearRows * c)) - overlaps

    console.log(ans)

});


n=+readline()
a=readline().split(' ').map(function(x){return +x;})
var res=0;
for (var i=0;i<=n;i++)
{
    var x0=0;
    var x1=0;
    for (var j=0;j<i;j++)
    {
        x0+=1-a[j];
    }
    for (var j=i;j<n;j++)
    {
        x1+=a[j];
    }
    if (x0+x1>res){res=x0+x1;}
}
print(res)


;(function () {
	print(function (n) {

		for (var i = 1; i <= 4; i++) {
			var l = readline().split(' ').map(Number),
				x = Math.min(l[0], l[1]),
				y = Math.min(l[2], l[3]);

			if (x + y <= n) {
				return [i, x, n - x].join(' ');
			}
		}

		return -1;

	}(+readline()));
}.call(this));


'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 printResult(x) {
    process.stdout.write(x);
}

function main() {
    const arrPoints = new Array(8);
    for (let i = 0; i < 8; i++) {
        let rl = readLine().split(' ').map(Number);
        arrPoints[i] = new Point(rl[0], rl[1]);
    }

    eightPointSet(arrPoints);
}

function Point(x, y)
{
    this.x = x;
    this.y = y;
}

const comparePoints = (a, b) => {
    if (a.x < b.x || (a.x === b.x && a.y < b.y)) {
        return -1;
    }
    if (a.x > b.x || (a.x === b.x && a.y > b.y)) {
        return 1;
    }
    return 0;
}

/**
 * eightPointSet
 *
 * 2    4   7
 * 1        6
 * 0    3   5
 *
 * => Equal
 * x0 = x0 = x2
 * x3 = x4
 * x5 = x6 = x7
 * y0 = y3 = y5
 * y1 = y6
 * y2 = y4 = y7
 *
 * => Not equal
 * x0 != x3
 * x3 != x5
 * y0 != y1
 * y1 != y2
 */
const eightPointSet = (a) => {
    a.sort(comparePoints);
    if (a[0].x === a[1].x && a[1].x === a[2].x
        && a[3].x === a[4].x
        && a[5].x === a[6].x && a[6].x === a[7].x
        && a[0].y === a[3].y && a[3].y === a[5].y
        && a[1].y === a[6].y
        && a[2].y === a[4].y && a[4].y === a[7].y

        && a[0].x !== a[3].x
        && a[3].x !== a[5].x
        && a[0].y !== a[1].y
        && a[1].y !== a[2].y) {
        printResult('respectable');
    } else {
        printResult('ugly');
    }
};


var input = readline().split(" "), a = input[0], b = input[1], counter = 0;

for(;a > 0 && b > 0;){
	if(a >= b){
		counter += Math.floor(a/b);
		a = a % b;
	}
	else{
		counter += Math.floor(b/a);
		b = b % a;
	}
}
write(counter);


;(function () {
	print(function () {
		var s = readline().split(''), l = [];
		for (var i = 0; i < 8; i++) {
			l.push(s.splice(0, 10).join(''));
		}

		var n = [], s = 10;
		while (s--) {
			n.push(readline());
		}

		l.forEach(function (e, i) {
			l[i] = n.indexOf(e);
		});

		return l.join('');
	}());
}.call(this));


var cards = readline().split(' ').map(Number);

var duplicates = {};

for (var i = 0; i < cards.length; i++) {
	if (cards[i] in duplicates) {
		if (duplicates[cards[i]] < 3) {
			duplicates[cards[i]] += 1; //but only up to 3!!
		}
	} else {
		duplicates[cards[i]] = 1;
	}
}

var sum = 0;
var max_sum = 0;

for (var key in duplicates) {
	if (duplicates[key] > 1) {
		sum = key * duplicates[key];
		if (sum > max_sum) {
			max_sum = sum;
		}
	}
}

var cards_sum = 0;
var min_sum = 0;

for (var i = 0; i < cards.length; i++) {
	cards_sum += cards[i];
}

min_sum = cards_sum - max_sum;

print(min_sum);


var a = +readline();

while(String(a).split('').map(e => +e).reduce((a,b) => a + b) % 4 != 0) a ++;
write(a)


var keyboard = "qwertyuiopasdfghjkl;zxcvbnm,./", mistake = readline(), string = readline(), answer = [];

if( mistake == "R" ){
	for(i = 0; i < string.length; i++){
		answer.push(keyboard[keyboard.indexOf(string[i])-1]);
	}
	write(answer.join(""));
}
else{
	for(i = 0; i < string.length; i++){
		answer.push(keyboard[keyboard.indexOf(string[i])+1]);
	}
	write(answer.join(""));
}


function calculateProb(str1, str2) {
    var num = parseInt(str1);
    var arr = str2.split("").map(function(x) { return parseInt(x); });
    var ob = {};

    for (var i = 0; i < arr.length; i++) {
        if (!ob[arr[i]]) {
            ob[arr[i]] = 0;
        }

        ob[arr[i]]++;
    }

    var min = 0;

    for (var j = 0; j < 10; j++) {
        if (j === 0) {
            min = ob[j] || 0;
        } else {
            if (ob[j] < min) min = ob[j];
        }

    }

    ob[8] = ob[8] ? ob[8] : 0;

    return Math.min(ob[8], Math.floor(num / 11));
}

var s1 = readline();
var s2 = readline();

print(calculateProb(s1, s2));


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

rl.on('line', (data) => {
  arr.push(+data);
});

rl.on('close', () => {
  const [a, b, c, d, e, f] = arr;

  let suite2 = Math.min(b, c, d);
  let suite1 = Math.min(a, d - suite2);
  if (f > e) {
    suite2 = Math.min(b, c, d);
    suite1 = Math.min(a, d - suite2);
  }
  else {
    suite1 = Math.min(a, d);
    suite2 = Math.min(b, c, d - suite1);
  }

  const price1 = suite1 * e < 0 ? 0 : suite1 * e;
  const price2 = suite2 * f < 0 ? 0 : suite2 * f;
  const ans = price1 + price2;

  console.log(ans);
});


function main() {
    var line1 = readline();
    var data = readline().split(' ').map(Number);
    data.sort((a, b) => a-b);
    for (var k = data.length-1; k >= 2 && data[k-2] > 0 ; --k) {
        if ( data[k-2]+data[k-1] > data[k] )
            return print("YES")
    }
    return print("NO")
}

main()


var flights = +readline();
if (flights === 1) {
	print("contest");
}
else {
	var home = readline();
	var fa = [];
	var pair;
	var inx;
	for (var i = 0; i < flights; i++) {
		pair = readline().split("->");
		inx = hasPair(pair, fa);
		if (inx !== -1) {
			fa.splice(inx, 1);
		}
		else {
			fa.push(pair);
		}
	}
	print(fa.length > 0 ? "contest" : "home");
}
function hasPair(w, a) {
	var c;
	for (var x = 0, l = a.length; x < l; x++) {
		c = a[x];
		if (c && c[0] === w[1] && c[1] === w[0]) {
			return x;
		}
	}
	return -1;
}


  var tmp = readline().split(' ').map(x => parseInt(x));
  var a = tmp[0];
  var b = tmp[1];

  var turn = true;
  var curr = 1;
  while(true) {
    if(turn) {
      if(a < curr) {
        break;
      }
      a -= curr;
      curr += 1;
    } else {
      if(b < curr) {
        break;
      }
      b -= curr;
      curr += 1;
    }
    turn = !turn;
  }
  print(turn ? 'Vladik' : 'Valera')


var sum=readline().split(" ").reduce((a,b)=>{return +a + +b;});
if(sum%5!==0||sum===0)
    print("-1");
else
    print(sum/5);


var cnt=new Array();

for(var i=0;i<=1000;i++){
    cnt[i]=new Array();
    for(var j=1;j<=2;j++) cnt[i][j]=0;

}

var line = readline().split(' ');
var n=line[0];
var m=line[1];

line = readline().split(' ');
for(var i=0;i<n;i++){
    var x=parseInt(line[i]);
    cnt[i%m][x]++;
}

var ans=0;

for(var i=0;i<m;i++)
    ans+=Math.min(cnt[i][1],cnt[i][2]);

print(ans);


var n=parseInt(readline());
var answer=0;
var n2=1;
while(n!=0){
  var i=n%10;
  n=(n-i)/10;
  var num=0;
  if(i == 4){
    num=1;
  }else{
    num=2;
  }
  answer+=num*n2;
  n2*=2;
}
print(answer)


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

var x = parseInt(line[0]);
var y = parseInt(line[1]);

if( y<=1 && x != 0 ){
    print('No');
} else {
    if(y == x + 1){
        print("Yes")
    } else {
        if(x > y && (x - y + 1)% 2 == 0){
            print('Yes');
        } else {
            print('No');
        }
    }
}


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

if (isGood(str)) {
    print("1");
    print(str);
} else {
    var res = breakItDown(str, len);
    print(res.length)
    print(res.join(" "))
}

function breakItDown(str, len) {
    var left = str.substr(0, len / 2);
    var right = str.substr(len / 2);
    var slidingWindowIndex = 0;

    while (!isGood(left)) {
        slidingWindowIndex++;
        left += right.charAt(0);
    }

    right = right.substr(slidingWindowIndex);

    return [left, right];
}

function isGood(str) {
    return count(str, 1) != count(str, 0)
}

function count(str, num) {
    var _count = 0;
    for (var i = 0; i < str.length; i++)
        _count += str.charAt(i) == num ? 1 : 0;
    return _count
}


;(function () {

	var n = readline().split(' ');
	var m = +n[1];
	n = +n[0];

	var a = readline().split(' ').map(Number);

	var w = 0;
	var x = 0;
	for (var i = 0; i < n; i++) {
		w += a[i];

		if (w > m) {
			x++;
			w = a[i];
		} else if (w == m) {
			x++;
			w = 0;
		}
	}

	if (w) x++;

	print(x);

}).call(this);


const solve = (n) => {
    let res = 1;
    for (let i = 1; i <= n; i++) {
        res *= i;
    }
    res /= n;
    res /= (n >> 1);
    return res;
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    rl.on('line', (line) => {
        console.log(solve(Number(line)));
    });
};

main()


let data = '';
process.stdin.on('data', c => data += c);

const solution = () => {
	let line = data.split('\n');
	let n = parseInt(line[0],10);
	let a = line[1].split(' ').map(v => parseInt(v,10));
	let c = 0;
	while(a.length > 0){
		c++;
		let t = [];
		let min = Math.min(...a);
		for(let i of a){
			if (i%min !== 0){
				t.push(i);
			}
		}
		a = t;

	}
	console.log(c);
};

process.stdin.on('end',solution);


s=readline().split(' ')
var n = s[0];
var k = s[1];
var x = s[2];
a=readline().split(' ').map(function(v){return +v;})
res=k*x
for (var i=0;i<n-k;i++){
    res+=a[i]
}
print(res)


var num = parseInt(readline())
var response = Math.floor(num / 5)
if(num % 5 > 0) response++
print(response)


var nums = readline().split(" ").map(function(x) { return parseInt(x); });
var w1 = nums[0];
var h1 = nums[1];
var w2 = nums[2];
var h2 = nums[3];
var ans = 0;
//if (w1 === w2)
	ans = w1*2 + (h1+h2)*2 + 4;
//else
//	ans = w1 + w2 +
write(ans);


function toInt(x) {
	return parseInt(x);
}

var ar = readline().split(' ').map(toInt);
var sum = 0;
var res = 'NO';
var fg = true;

for (var i = 0; i < 6; i++) {
	sum += ar[i];
}

if (sum % 2 != 0) {
	print('NO');
        fg = false;
} else {
	sum /= 2;
}

for (var i = 0; i < 6; i++) {
	for (var j = 0; j < 6; j++) {
		for (var k = 0; k < 6; k++) {
			if ((i != j && i != k && j != k) && (ar[i] + ar[j] + ar[k] == sum)) {
				res = 'YES';
			}
		}
	}
}

if (fg)
  print(res);


var n = parseInt(readline());

var ret = 1;

for(var i=2; i<=n; i++) {
    ret += (i-1)*4;
}

print(ret);


var s = readline();

var l = s.length, m = -1, n = 0, i = 0, ss = "", out = "";

for(i = 0; i< l; i++)
{
  if( s.charCodeAt(i) > m )
  {
    m = s.charCodeAt(i);
    n = 0
  }
  else if( s.charCodeAt(i) == m )
  {
    n++;
  }
}

ss = String.fromCharCode(m);
n++;

for(i = 0; i< n; i++)
{
  out = out + ss;
}

print(out);


function main() {
    let line = stdin[0].split(' ');
    let k = parseInt(line[1], 10);
    let items = stdin[1].split(' ').map(i => parseInt(i, 10));
    let allItems = {}, max = 0;

    for (let i = 0; i < items.length; ++i) {
       if (!(items[i] in allItems)) allItems[items[i]] = 0;
       ++allItems[items[i]];
    }

    for (let p in allItems) {
       max = Math.max(allItems[p], max);
    }

    const uniqCount = Object.keys(allItems).length;

    while (max % k != 0) { max++; }

    console.log(uniqCount * max - items.length);
}

const readline = require('readline');
const rl = readline.createInterface({input: process.stdin});
var stdin = [];
rl.on('line', function (line) {stdin.push(line);});
rl.on('close', main);


var n = parseInt(readline());
var dirs = [];
for (var i = 0; i < n; i++) {
  dirs[i] = readline().split(' ');
  dirs[i][0] = parseInt(dirs[i][0]);
}

var yPos = 0;
result = 'YES';
var i = 0;
for (; i < n; i++) {
  var dist = dirs[i][0];
  var dir = dirs[i][1];
  if (yPos === 0 && dir !== 'South') {
    result = 'NO';
    break;
  }
  if (yPos === 20000 && dir !== 'North') {
    result = 'NO';
    break;
  }
  if (dir === 'South') {
    yPos += dist;
  } else if (dir === 'North') {
    yPos -= dist;
  }
  if (yPos < 0 || yPos > 20000) {
    result = 'NO';
    break;
  }
}

print(yPos === 0 ? result : 'NO');


main();

function main(){
   var x = parseInt(readline());

    var guess=Math.round(Math.sqrt(x));
    //print(guess);

    for(var i=guess;i>=1;i--){
    if(x%i===0){
        //print("no remainder");
        //print(lcm(i,x/i));
        if(x==lcm(i,x/i)){print(i+" "+x/i);return;}
    }//whole number divisor
}

}//main, added for return

function lcm(a,b){
    return a*b/gcd(a,b);
}

function gcd(a,b){
    while(a>0){
        var temp=a;
        a=b%a;
        b=temp;
    }
    return b;
}


const find = (tasks, reserved) => {
    let bad = tasks * 2;
    let good = 0;
    let perTask = 5;

    const sum = (tasksCount) =>
        (2 * perTask + perTask * (tasksCount - 1))
            / 2
            * tasksCount
            + reserved;

    while (bad - good > 1) {
        let middle = (good + bad) >> 1;

        if (sum(middle) <= 240) {
            good = middle;
        } else {
            bad = middle;
        }
    }

    console.log(Math.min(good, tasks));
};

let _input = "";

process.stdin.on("data", function (input) {
    _input += input;
});

process.stdin.on("end", function () {
   find(..._input.split('\n')[0].split(' ').map(Number));
});


var numbers = readline().split(" ").map(function(x) { return parseInt(x); });
var n = numbers[0], m = numbers[1], a = numbers[2], b = numbers[3];

if (n % m === 0) {
    print(0);
} else {
    var destroy = (n - Math.floor(n / m) * m) * b;
    var build = (Math.ceil(n / m) * m - n) * a;
    print(Math.min(destroy, build));
}


var s = readline().split(' ');
var n = Number(s[0]);
var m = Number(s[1]);
var a = Number(s[2]);
var b = Number(s[3]);

var out = 0;
var k = 0;

if(b/m >= a/1)
{
  out = a*n;
}
else
{
  k = (n - n % m);
  out = (k/m)*b;
  if( (n-k)*a > b)
  {
    out = out + b;
  }
  else
  {
    out = out + (n-k)*a;
  }
}

print(out);


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

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

const MOD = 1000000007n;

function fast_pow(a, p)
{
	let res = 1n;
	while (p) {
		if (p % 2n == 0) {
			a = a * a % MOD;
			p /= 2n;
		} else {
			res = res * a % MOD;
			p--;
		}
	}
	return res;
}

function main () {
	const k = rn();

	const ans = fast_pow(4n, 2n**BigInt(k)-2n) * 6n % MOD;

	console.log(ans.toString());
}


let _inputLines;
let _lineNumber = 0;
let inputReader = _inputReader ();

function _main() {

	_inputLines = _inputData.trim().split('\n').map((string) => {
		return string.trim();
	});;
	let n = inputReader.readNumber();
	let a =1,b=1,c=0;
	let flag = true;
	while(n--){
		let num = inputReader.readNumber();
		if(num===1){
			if(a===1){
				if(b===1){
					b=0;
					c=1;
				}
				else{
					c=0;
					b=1;
				}
			}
			else{
				flag=false;
			}
		}
		else if(num===2){
			if(b===1){
				if(a===1){
					a=0;
					c=1;
				}
				else{
					c=0;
					a=1;
				}
			}
			else{
				flag=false;
			}
		}
		if(num===3){
			if(c===1){
				if(b===1){
					b=0;
					a=1;
				}
				else{
					a=0;
					b=1;
				}
			}
			else{
				flag=false;
			}
		}
	}

	if(flag)
		console.log("YES");
	else
		console.log("NO");
	//console.log(obj);

}

var _inputData = '';
function cacheInput(data) {
	_inputData += data;
}

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', cacheInput).on('end', _main);

function _inputReader () {
	function readNumber(){
		return Number(_inputLines[_lineNumber++]);
	}

	return {
		readNumber,
	}
}


var min = Math.min;
var max = Math.max;

var each = function (a, f) {
	Array.apply(null, Array(a)).map(function (a, i) {return i;}).map(f);
}

var n = +readline();
var g = [];
var ans = 0;

each(n, function (i) {
	g.push(readline().split(' '));
});

each(n, function (i) {
	each(n, function (j) {
		each(n, function (k){
			g[j][k] = min(+g[j][k], +g[j][i] + g[i][k]);
		});
	});
});

each(n, function (i) {
	each(n, function (j) {
		ans = max(ans, +g[i][j]);
	});
});

print(ans);


var s=readline();
var t=readline();
var i=0;
t.split('').forEach(function(v){
	if(s[i]===v) i++;
});
print(i+1);


var N = readline();
var data = readline().split(' ');
var kondidate = new Array();
var bribed=0;
var maxNumber = 0;
var isResult=0;
for (i=0;i<N;i++){
	kondidate[i] = parseInt(data[i]);

}
var maxValue = kondidate[0];

//write('\n');
while (isResult<N-1){
	isResult=N-1;
	var maxNumber = 0;
	var maxValue = kondidate[0] ;

	//находим за кого больше всего проголосовало
	for (i=1;i<N;i++){
		if (maxValue<=kondidate[i]){
			maxNumber=i;
			maxValue=kondidate[i];
			isResult--;
		}
	}

	//снимаем один голос с оппонента, набравшего максимум голосов
	if (maxNumber!=0){
		kondidate[0]++;
		bribed++;
		kondidate[maxNumber]--;
	}
}

write(bribed);


function numCapitals(word) {
  var total = 0;
  for (var i = 0; i < word.length; i++) {
    if (/[A-Z]/.test(word[i])) {
      total++;
    }
  }
  return total;
}

function main() {
  var n = readline();
  var words = readline().split(' ');

  var max = words.reduce((max, curr) => {
    var count = numCapitals(curr);
    if (count > max) {
      return count;
    }
    return max;
  }, -1);

  print(max);
}

main();


var input = readline().split(' ').map(function(x){return Number(x)});
var a = input[0];
var b = input[1];
var res = 1;
for(var i = 1 ; i <= Math.min(a,b) ; i++){
    res *= i;
}
print(res);


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

const input = [];

function splitAndParseInt(line) {
  return line.split(" ").map((x) => parseInt(x));
}

readLine.on("line", (line) => input.push(line));
readLine.on("close", () => {
  let string1 = input[0].toLowerCase();
  let string2 = input[1].toLowerCase();
  console.log(string1.localeCompare(string2))
});


var row = readline().split(" ").map(function(x) { return parseInt(x); });
var k1 = row[0];
var k2 = row[1];
var k3 = row[2];

var max = k1;
if(max < k2)
	max = k2;
if(max < k3)
	max = k3;

var mid;
var min;
if(max == k1) {
	if (k2 > k3) {
		mid = k2;
		min = k3;
	} else {
		min = k2;
		mid = k3;
	}
} else if(max == k2) {
	if (k1 > k3) {
		mid = k1;
		min = k3;
	} else {
		mid = k3;
		min = k1;
	}
} else {
	if (k1 > k2) {
		mid = k1;
		min = k2;
	} else {
		mid = k2;
		min = k1;
	}
}

var minLoop = lcm(k1, lcm(k2, k3));

var result = "YES";
for(var i = 0; i < minLoop; i++) {
	if(i % max == 0 || (i-1) % mid == 0 || (i-2) % min == 0) {
		//Nothing
	} else {
		result = "NO";
		break;
	}
}

if(result == "NO") {
result = "YES";
for(var i = 0; i < minLoop; i++) {
	if(i % max == 0 || (i-1) % min == 0 || (i-2) % mid == 0) {
		//Nothing
	} else {
		result = "NO";
		break;
	}
}
}

write(result);

function gcd(a, b) {
    return !b ? a : gcd(b, a % b);
}

function lcm(a, b) {
    return (a * b) / gcd(a, b);
}


var ints = function() {
	return readline().split(' ').map(function(x) {
		return parseInt(x)
	})
}

var numbers = ints()
	k = numbers[0],
	a = numbers[1],
	b = numbers[2],
	invalid = (a < k && b < k) || (a < k && b % k > 0) || (b < k && a % k > 0)

print(invalid ? -1 : Math.floor(a / k) + Math.floor(b / k))


function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var integers = tokenizeIntegers(readline());
	var maxBoxes = integers[0], brandNum = integers[1];

	var brands = [];

	for (var i = 0; i < brandNum; i += 1) {
		var integers = tokenizeIntegers(readline());
		brands.push({ boxes: integers[0], matches: integers[1] });
	}

	brands.sort(function(a, b) {
		return a.matches - b.matches;
	});

	var matches = 0;

	for (var i = brands.length-1; i >= 0 && maxBoxes > 0; i -= 1) {
		var boxes = Math.min(brands[i].boxes, maxBoxes);
		matches += boxes*brands[i].matches;
		maxBoxes -= boxes;
	}

	print(matches);
}

main();


function main() {
    var lines = [];
    for(var i=0;i<4;i++){
        lines.push(readline());
    }
    var winning = [".xx", 'x.x', 'xx.'];

    for(var j=0;j<4;j++){
        var line = "";
        for(var i=0;i<4;i++){
            line += lines[i][j];
        }
        lines.push(line);
    }
    lines.push(lines[0][0] + lines[1][1] + lines[2][2] + lines[3][3])
    lines.push(lines[0][1] + lines[1][2] + lines[2][3])
    lines.push(lines[1][0] + lines[2][1] + lines[3][2])

    lines.push(lines[0][3] + lines[1][2] + lines[2][1] + lines[3][0])
    lines.push(lines[1][3] + lines[2][2] + lines[3][1])
    lines.push(lines[0][2] + lines[1][1] + lines[2][0])

    for(var i=0;i<lines.length;i++){
        for(var j=0;j<3;j++){
            if(lines[i].indexOf(winning[j])!=-1){
                print("YES");
                return;
            }
        }
    }
    print("NO");

}

main()


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

rl.on('line', (d) => {
  const [n, k] = d.split(' ').map(BigInt);
  const ans = n / k;

  if (ans % 2n === 0n) {
    console.log('NO');
  }
  else {
    console.log('YES');
  }

});


'use strict'

const {EOL} = require('os')

let ipt = ''
process.stdin.on('data', s => ipt += s)
process.stdin.on('end', () => {
  const [ils] = ipt.split(EOL).slice(0, -1)
  const [a, b, c, d, e, f] = ils.split(' ')

  let r = 1
  let g1, g2

  const cast = (r, a, b) => {
    if (a == 0 && b == 0) {
      return 0
    }
    else if (a == 0) {
      return Infinity
    }
    return r / a * b
  }

  r = cast(r, a, b)
  r = cast(r, c, d)
  g1 = r
  r = cast(r, e, f)
  r = cast(r, a, b)
  r = cast(r, c, d)
  g2 = r

  console.log(g2 == Infinity || g2 > g1 ? 'Ron' : 'Hermione')
})


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

for (let i = 0; i <= 100; i++) {
  if (can[i]) {
    can[i + 3] = 1;
    can[i + 7] = 1;
  }
}

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

  if (can[+d]) {
    console.log('YES');
  }
  else {
    console.log('NO');
  }

  // let n = +d;
  // let ans = 'NO';

  // while (n > 0) {
  //   if (n % 7 === 0) {
  //     ans = 'YES';
  //     break;
  //   }

  //   if (n % 3 === 0) {
  //     ans = 'YES';
  //     break;
  //   }

  //   n -= 7;
  // }

  // n = +d;
  // while (n > 0) {
  //   if (n % 7 === 0) {
  //     ans = 'YES';
  //     break;
  //   }

  //   if (n % 3 === 0) {
  //     ans = 'YES';
  //     break;
  //   }

  //   n -= 3;
  // }

  // console.log(ans);

  c++;
});


(function () {
	'use strict';

	var assessment = 0;

	for (var i = 0; i < 8; i++)
		readline().split('').forEach(function (a) {
			assessment += getWeight(a);
		});

	print(
		assessment > 0 ? 'Black'
		: (assessment < 0 ? 'White' : 'Draw')
	);

}).call(this);

function getWeight (a) {
	if (a.toLowerCase() === a)
		switch (a) {
			case 'q': return 9;
			case 'r': return 5;
			case 'b': return 3;
			case 'n': return 3;
			case 'p': return 1;
		}
	else
		switch (a) {
			case 'Q': return -9;
			case 'R': return -5;
			case 'B': return -3;
			case 'N': return -3;
			case 'P': return -1;
		}

	return 0
}


  var s = readline();

  var len = s.length;
  var res = 0;
  for(var i = 0; i < len; i += 1) {
    for(var j = i; j < len + 1; j += 1) {
      var t = s.slice(i, j);
      if(t !== t.split('').reverse().join('')) {
        // console.log(t);
        res = Math.max(t.length, res);
      }
    }
  }
  print(res);


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

const input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
	let _input = parseInt(input[0], 10)
	let result = 0
	const _return_ = (num, min) => {
		const it1 = num / min
		const it2 = Math.floor(it1) // получаем целое число
		const it3 = min * it2 // какое кол-во едениц можно отнять
		const it4 = num - it3 // остаток
		result += it2
		return it4
	}
	const count_min = (now) => {
		if (now >= 100) {
			count_min(_return_(now, 100))
		} else {
			if (now >= 20) {
				count_min(_return_(now, 20))
			} else {
				if (now >= 10) {
					count_min(_return_(now, 10))
				} else {
					if (now >= 5) {
						count_min(_return_(now, 5))
					} else {
						if (now > 0) {
							count_min(_return_(now, 1))
						}
					}
				}
			}
		}
	}
	count_min(_input)
	console.log(result)
})


var nk = readline().split(' ').map(Number),
    n = nk[0],
    maxDays = nk[1];
var inputInstr = readline().split(' ').map(Number);

var instrMap = [];

for (var i = 0; i < n; i++) {
    instrMap.push({
        val: inputInstr[i],
        idx: i
    });
}

instrMap.sort(function (i1, i2) {
    return i1.val > i2.val;
});

var sum = 0;
    maxInstr = 0,
    indexes = [];

for (var j = 0; j < n; j++) {
    if ( sum + instrMap[j].val > maxDays ) {
        break;
    } else {
        sum += instrMap[j].val;
        indexes.push(instrMap[j].idx + 1);
        maxInstr++;
    }
}

print( maxInstr );
indexes.length ? print(indexes.join(' ')) : null;


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:c} = {...input[0].split(' ')};
    n = parseInt(n); c = parseInt(c);
    let points = []; input[1].split(' ').forEach( i => points.push(parseInt(i)) );
    let times = []; input[2].split(' ').forEach( i => times.push(parseInt(i)) );
    let secondTimes = []; times.forEach(i => secondTimes.push(parseInt(i)));

    let firstPlayer = 0; let secondPlayer = 0;
    let j = n-1;

    for(let i = 0; i < n; i++) {
        firstPlayer += max(0, points[i] - c*times[i]);
        secondPlayer +=  max(0, points[j] - c*secondTimes[j]);

        if(i + 1 != n) {
            times[i+1] += times[i];
        }
        if(j - 1 >= 0) {
            secondTimes[j-1] += secondTimes[j];
        }
        j--;
        //console.log(`fp = ${firstPlayer}; sp = ${secondPlayer}`);
    }

    if(firstPlayer > secondPlayer) {
        console.log('Limak');
    } else if(secondPlayer > firstPlayer) {
        console.log('Radewoosh');
    } else
        console.log('Tie')
});

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


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);
  arr.sort((a, b) => a - b);
  let ans = 0;
  let prev = -1;

  for (let i = 0; i < arr.length; i++) {
    if (prev !== arr[i] && arr[i] !== 0) {
      ans++;
      prev = arr[i];
    }
  }

  console.log(ans);

  c++;
});


function main() {
    var firstLine = readline().split(/\s/gi).map(Number),
        secondLine = readline().split(/\s/gi).map(Number),
        thirdLine = readline().split(/\s/gi).map(Number),
        a1 = firstLine[0], b1 = firstLine[1],
        a2 = secondLine[0], b2 = secondLine[1],
        a3 = thirdLine[0], b3 = thirdLine[1],
        result = "NO",
        combine = [];

    if(b1 > a1) {
        var temp = a1;
        a1 = b1;
        b1 = temp;
    }

    combine.push({
        "a" : a2 + a3,
        "b" : Math.max(b2, b3)
    });
    combine.push({
        "a" : a2 + b3,
        "b" : Math.max(b2, a3)
    });
    combine.push({
        "a" : b2 + a3,
        "b" : Math.max(a2, b3)
    });
    combine.push({
        "a" : b2 + b3,
        "b" : Math.max(a2, a3)
    });

    combine.filter(function(com, index)   {
        var aX = com.a,
            bX = com.b,
            temp;

        if(bX > aX) {
            temp = aX;
            aX = bX;
            bX = temp;
        }

        if(aX <= a1 && bX <= b1)    {
            result = "YES";
            return true;
        }
    });

    print(result);
};

main();


let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    let input = lines[0].split(" ").map(value => {
        return parseInt(value)
    })

    let aCount = input[0]
    let bCount = input[1]
    let abCount = input[2]

    if (bCount > aCount) {
        let maximumACount = aCount
        let maximumBCount = aCount + 1
        let maximumABCountSeperated = abCount * 2
        let maximumLength = maximumACount + maximumBCount + maximumABCountSeperated
        console.log(maximumLength)
    } else if (bCount < aCount) {
        let maximumACount = bCount + 1
        let maximumBCount = bCount
        let maximumABCountSeperated = abCount * 2
        let maximumLength = maximumACount + maximumBCount + maximumABCountSeperated
        console.log(maximumLength)
    } else if (aCount === bCount) {
        let maximumACount = aCount
        let maximumBCount = bCount
        let maximumABCountSeperated = abCount * 2
        let maximumLength = maximumACount + maximumBCount + maximumABCountSeperated
        console.log(maximumLength)
    }
})


n = readline();
var arr = new Array();
arr = readline();
function dificult(n, arr) {
   k = 0;
   for (i = 0; i < arr.length; i++) {
      if (arr[i] == 1) {
         print ('HARD');
         k++;
         break;
      }
   }
   if (k == 0) print ('EASY');
}
dificult(n, arr)


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

var testPosition = function(x, y) {
    if (x + 1 == 4 || y + 1 == 4) {
        return false;
    }
    if (arr[x][y] == arr[x][y + 1] && arr[x][y] == arr[x + 1][y] && arr[x][y] == arr[x + 1][y + 1]) {
        return true;
    }
    return false;
};

var testSquare = function() {
    for (var i = 0; i < 4; i++) {
        for (var j = 0; j < 4; j++) {
            if (testPosition(i, j)) {
                return true;
            }
        }
    }
};

var change = function(x, y) {
    if (x + 1 == 4 || y + 1 == 4) {
        return false;
    }
    var colors = {
        firstColor: {
            color: '',
            found: 0
        },
        secondColor: {
            color: '',
            found: 0
        }
    };
    colors.firstColor.color = arr[x][y];
    for (var ix = x; ix <= x + 1; ix++) {
        for (var jy = y; jy <= y + 1; jy++) {
            if (colors.firstColor.color === arr[ix][jy]) {
                colors.firstColor.found += 1;
            } else {
                if (colors.secondColor.color === '')
                    colors.secondColor.color = arr[ix][jy];
                colors.secondColor.found += 1;
            }
        }
    }
    if (colors.secondColor.found === 1 || colors.firstColor.found === 1) {
        return true;
    }
    return false;
};

var testChange = function() {
    for (var i = 0; i < 4; i++) {
        for (var j = 0; j < 4; j++) {
            if (change(i, j)) {
                return true;
            }
        }
    }
};

if (testSquare()) {
    print('YES');
} else {

    if (testChange()) {
        print('YES');
    } else {
        print('NO');
    }
}


var firstLine = readline().split(' ');
var n = parseInt(firstLine[0]);
var k = parseInt(firstLine[1]);
var str = readline();
for(var i = Math.min(str.indexOf('G'), str.indexOf('T')) + k; i < str.length;i += k){
    if (str[i] === '#'){
     print("NO");   break;
    }
    if (str[i] === 'G' || str[i] === 'T'){
        print('YES');break;
    }
}
if (i > str.length - 1)print("NO");


const rdline = require('readline');

const rl = rdline.createInterface({
    input: process.stdin
});

let lines = [];
rl.on('line', (line) => {
    lines.push(line);
}).on('close', () => {
    // input in lines
    solve();
});

let line = 0;
const readline = () => lines[line++];

solve = () => {
    const t = parseInt(readline());
    for (let i = 0; i < t; i++) {
    var b = parseInt(readline());
    var k = 9;
    var output = [];
    while (b > k){
        output.unshift(k);
        b = b - k;
        k = k - 1;
    } if (b > 0) {
        output.unshift(b)
    }
    console.log(output.join(''))
    }
}


function trim(s) {
    return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
    return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
    var tokens = tokenize(s);
    for (var i = 0; i < tokens.length; i += 1) {
        tokens[i] = parseInt(tokens[i]);
    };
    return tokens;
}

function main() {
    var integers = tokenizeIntegers(readline());
    var A = integers[0], B = integers[1];
    print(A + B);
}

main();


X=readline().split(' ').map(Number)
x=Math.min(X[0],X[1])
print(x, Math.floor((X[0]-x)/2)+Math.floor((X[1]-x)/2))


var input = readline().split(" ");
var n = input[0];
var k = input[1];
var res = 0;
for (var i = 1; i <= k; ++i) {
    var mid = n - i * 2;
    if (mid >= 0) {
        res += mid * 2 + 1;
    }
}
write(res)


const readline = require('readline');

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

var IsPrime = function (num) {
    if (num == 2)
        return true;
    if (num < 2 || num % 2 == 0)
        return false;
    var limit = parseInt(Math.sqrt(num));
    for (i = 3; i <= limit; i += 2) {
        if (num % i == 0)
            return false;
    }
    return true;
}

var prev = 2,
    n, k, counter = 0,
    helper;

rl.on('line', (input) => {
    var temp = input.split(' ').map(item => parseInt(item));
    n = temp[0];
    k = temp[1];

    for (let i = 3; i <= n; i++) {
        if (IsPrime(i)) {
            helper = prev + i + 1;
            if (IsPrime(helper) && helper <= n)
                counter++;
            prev = i;
        }
    }
    console.log((counter >= k) ? "YES" : "NO");
    rl.close();
});


var s = readline();
var d = 0;

for(var idx=0;idx<s.length/2;idx++)
{
  if(s[idx]!==s[s.length-idx-1])
    d++;
}

if(d===1 || (d===0 && s.length%2===1))
  print("YES");
else
  print("NO");


var num = readline().split(" ").map(x => parseInt(x));
var n = num[0];
var k = num[1];

function find(n, k) {
    var _n = n;
    var _k = k;
    var count = Math.pow(2, n) - 1
    var midPos = Math.ceil(count*0.5)

    if (k == midPos) {
        print(n);
    } else {
        _n = n - 1;
        if (k > midPos) {
            _k = k - midPos;
        }
        find(_n, _k);
    }
}

find(n, k)


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

var ans = +a[0]==9 ? a[0] : String(Math.min(+a[0],9-a[0]));
a = a.slice(1,a.length);

for(var i=0; i<a.length; i++){
    //if(+a[i]==9 && i==0) { ans+=a[i]; continue; }
    if(9-a[i]<+a[i]) a[i] = 9-a[i];
    ans+=a[i];
}

print(ans);


var K, P;

var s=readline().split(' ')

K = parseInt(s[0])
P = parseInt(s[1])

var i = 1;
var sum = 0;

while (i <= K) {
    var now = i.toString(10);
    var temp = now;
    temp += m_reverse(now);
    sum = (sum + parseInt(temp)) % P;
    i++;
}

print(sum);

function m_reverse(str) {
    var r_str = "";
    for (var i = str.length - 1; i >= 0; i--) {
        r_str += str[i];
    }

    return r_str;
}


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

rl.on('line', (data) => {
  if (c === 0) {
    c++;
    [n, d] = data.split(' ').map(Number);
    return;
  }

  const arr = data.split('').map(Number);
  let ans = 0;
  let best = 0;
  let inc = 1;

  for (let i = 1; i < arr.length; i++) {
    if (arr[i] === 1) {
      best = Math.max(best, i);
    }

    if (inc === d || i + 1 === arr.length) {
      if (best === 0) {
        ans = -1;
        break;
      }
      else {
        ans++;
        i = best;
        best = 0;
        inc = 0;
      }
    }

    inc++;
  }

  console.log(ans);

  c++;
});


(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 alph = {
        A: 1,
        B: 2,
        C: 3,
        D: 4,
        E: 5,
        F: 6,
        G: 7,
        H: 8,
        I: 9,
        J: 10,
        K: 11,
        L: 12,
        M: 13,
        N: 14,
        O: 15,
        P: 16,
        Q: 17,
        R: 18,
        S: 19,
        T: 20,
        U: 21,
        V: 22,
        W: 23,
        X: 24,
        Y: 25,
        Z: 26
    };

    function getR(a, b) {
        if(b < a) {
            var t = b;
            b = a;
            a = t;
        }
        var v1 = b - a;
        var v2 = (26 - b) + a;
        return v1 < v2 ? v1 : v2;
    }

    var n = read.number();
    var s = readline();

    var counts = [];
    for(var i = 0; i < n - 3; i++) {
        counts[i] = 0;
        counts[i] += getR(alph[s[i]], alph['A']);
        counts[i] += getR(alph[s[i + 1]], alph['C']);
        counts[i] += getR(alph[s[i + 2]], alph['T']);
        counts[i] += getR(alph[s[i + 3]], alph['G']);
    }
    var min = counts[0];
    for(var i = 1; i < n - 3; i++) {
        if(counts[i] < min)
            min = counts[i];
    }

    print(min);
}());


(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 n = read.number();
    var a = [...new Set(read.arrNumber(' '))];

    var max = a[0], min = a[0];
    a.forEach(i => {
        if(i > max) max = i;
        if(i < min) min = i;
    });

    mid = min + (max - min)/2

    var midUse = false;
    var minuse = false;
    var maxuse = false

    for(var f = 0; f < a.length; f++) {
        var i = a[f]
        if(i === mid) {
            midUse = true;
        }
        else if(i === max) {
            minuse = true;
        }
        else if(i === min) {
            maxuse = true;
        }
        else {
            print(-1);
            return;
        }
    }

    if(midUse) {
        print(max - mid)
    }
    else {
        if((max - min) %2 === 1)
            print(max - min);
        else {
            print((max - min) / 2)
        }
    }
}());


var a1 = Number(readline());
var a2 = Number(readline());
var k1 = Number(readline());
var k2 = Number(readline());
if (k1 > k2) {
  var t = a1;
  a1 = a2;
  a2 = t;
  t = k1;
  k1 = k2;
  k2 = t;
}
const n = Number(readline());
const a = Math.min(Math.floor(n / k1), a1);
const b = Math.min(Math.floor(Math.max(n - a * k1, 0) / k2), a2);
print(`${Math.min(Math.max(n - (a1 * (k1 - 1) + a2 * (k2 - 1)), 0), a1 + a2)} ${a + b}`);


// Sample code to perform I/O:

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
    main(stdin_input);
});

function main(input) {
    let output = nameLookUp(input);
    process.stdout.write(output);       // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

// Write your code here
function nameLookUp(str) {
    let inputs = str.trim().split('\n');
    let oneNum = inputs[0].trim();
    let twoNum = inputs[1].trim();
    let num = [];
    for (let i = 0; i < oneNum.length; i++) {
        let bit = String(oneNum[i] ^ twoNum[i]);
        num.push(bit);
    }

    return num.join('').toString();
}


const { on } = require('process');
const readline = require('readline');

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

var check = function (s) {
    let sLen = s.length;
    if (sLen == 0 || sLen > 16)
        return false;
    for (let i = 0; i < sLen; i++) {
        if (!(s[i] >= 'a' && s[i] <= 'z' ||
            s[i] >= 'A' && s[i] <= 'Z' ||
            s[i] >= '0' && s[i] <= '9' ||
            s[i] == '_'))
            return false;
    }
    return true;
}

var checkHost = function (hostName) {
    let hostLen = hostName.length;
    if (hostLen == 0 || hostLen > 32)
        return false;
    let cont = hostName.split(".");
    for (let i = 0; i < cont.length; i++) {
        if (!check(cont[i]))
            return false;
    }
    return true;
}

rl.on('line', (input) => {
    let isUser = false, isHost = false, isResource = false;
    let atIndex = input.indexOf("@");
    if (atIndex != -1) {
        let userName = input.substring(0, atIndex);
        isUser = check(userName);
        let slashIndex = input.indexOf("/");
        let hostName = (slashIndex != -1) ? input.substring(atIndex + 1, slashIndex) : input.substring(atIndex + 1);
        isHost = checkHost(hostName);
        isResource = (slashIndex == -1) ? true : check(input.substring(slashIndex + 1));
    }
    console.log((isUser && isHost && isResource) ? "YES" : "NO");
    rl.close();
});


//var t1=prompt('Введите время начала контеста');
//var t2=prompt('Введите время окончания контеста');
var t1=readline();
var t2=readline();

var h1=Number(t1.slice(0,2));
var m1=Number(t1.slice(3,5));
var h2=Number(t2.slice(0,2));
var m2=Number(t2.slice(3,5));
//console.log('Start  '+h1+':'+m1);
//console.log('End  '+h2+':'+m2);

var interval=((h2-h1)*60+m2-m1)/2;

m3=m1+interval;
dh=Math.floor(m3/60);
h3=h1+dh;
h3=h3-24*Math.floor(h3/24);
m3=m3-dh*60;

if(h3<10) {
h3='0'+h3;
}
if (m3<10){
m3='0'+m3;
}

print(h3+':'+m3);
//console.log('Середина контеста '+h3+':'+m3);


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 a = arr[0];
  let b = 0;
  let mid = Math.floor(a / 2);
  const ans = [1];

  for (let i = 1; i < arr.length; i++) {
    if (arr[i] > mid) {
      b += arr[i];
    }
    else {
      a += arr[i];
      ans.push(i + 1);
    }
  }

  if (a <= b) {
    console.log(0);
  }
  else {
    console.log(ans.length);
    console.log(ans.join(' '));
  }

  c++;
});


async function solve() {
  let s = await line()
  const vk = s.split('VK').length - 1
  s = s.split('VK').join('X')
  const vv = s.split('VV').length > 1
  const kk = s.split('KK').length > 1

  print(vk + (vv || kk ? 1 : 0))
}

// read the input
const readline = require('readline')
const _lines = []
let _lineIndex = 0
let _ended = false
const _rl = readline.createInterface(process.stdin)
_rl.on('line', line => _lines.push(line))
_rl.on('end', () => (ended = true))
const wait = ms => new Promise(resolve => setTimeout(resolve, ms))
const line = async () => {
  while (!_ended && _lines.length <= _lineIndex) await wait(10)
  const result = _lines[_lineIndex].trim()
  _lines[_lineIndex] = null
  _lineIndex++
  return result
}
const words = async () => (await line()).split(' ')
const chars = async () => (await line()).split('')
const int = async () => parseInt(await line())
const ints = async () => (await words()).map(x => parseInt(x))
const big = async () => BigInt(await line())
const bigs = async () => (await words()).map(x => BigInt(x))

const print = console.log

solve()


var n = readline();
var str = readline().split(" ").sort((x,y)=>{return x-y}).reverse();
var x = 0;
var res=0;
for (var i=0; i<str.length+1; i++){
	if(res>=n){
	print(i);
	x=1;
	break;
	}
	res+=+str[i];
}
if (x==0) print(-1);


const readline = require('readline');

let secondLine = false;

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

let inputs = [];

rl.on('line', lineInput => {
    inputs.push(lineInput);
})

// Read Inputs
rl.on('close', () => {
    const line1 = inputs[0].split(' ');
    const songs = inputs[1].split(' ');
    const D = parseInt(line1[1].split(' ')[0]);
    let spareTime = 0;
    let neededDurationForSongs = 0;
    for (let i = 0; i < songs.length; i++) {
        neededDurationForSongs += parseInt(songs[i]);
    }

    spareTime = (songs.length - 1) * 10;

    if (neededDurationForSongs + spareTime > D)
        return console.log(-1)

    let durationsForJokes = D - neededDurationForSongs;

    return console.log(Math.floor(durationsForJokes / 5))
});


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

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))

  const n = readInt(arr)
  const a = arr[0]

  let l = 0, r = 0
  for(let i = 0; i < n; i++) {
    if(a[i] == 'L') l ++
    else r++
  }

  wr(l + r + 1)
})

function wr(...x) {
  console.log(...x)
}

function sort(a, inc = true) {
  if(inc) a.sort((a, b) => a - b)
  else a.sort((a, b) => b - a)
}

function readInt(a, i) {
  if(i === undefined) return parseInt(a.shift())
  else return parseInt(a[i])
}
function readInts(a, i) {
  if(i === undefined) return arr.shift().split(' ').map(a => parseInt(a))
  else return arr[i].split(' ').map(a => parseInt(a))
}


var finput = readline();
var minput = readline();
var sinput = readline();

var players = ['F', 'M', 'S'];
var inputs = [finput, minput, sinput];
var rocks = 0, ss = 0, papers = 0
for (var i = 0; i < inputs.length; i++) {
    if (inputs[i] == 'rock') rocks++;
    if (inputs[i] == 'scissors') ss++;
    if (inputs[i] == 'paper') papers++;
}

var winnerFlag = false;
if (rocks == 2 && papers == 1) {write(players[inputs.indexOf('paper')])}
else if (ss == 2 && rocks == 1) {write(players[inputs.indexOf('rock')])}
else if (papers == 2 && ss == 1) {write(players[inputs.indexOf('scissors')])}
else write('?');


var n=+readline();
var a=readline().split(' ').map(function(v){return+v;});

var chest=0;
for(var i=0;i<n;i+=3){
	chest+=a[i];
}
var biceps=0;
for(var i=1;i<n;i+=3){
	biceps+=a[i];
}
var back=0;
for(var i=2;i<n;i+=3){
	back+=a[i];
}
switch(Math.max(chest, biceps, back)){
	case chest:
		print('chest');
		break;
	case biceps:
		print('biceps');
		break;
	case back:
		print('back');
		break;
}


var trump = readline();
var cards = readline().split(" ");

var yes = "YES", no = "NO", ranks = ["6", "7", "8", "9", "T", "J", "Q", "K", "A"];
var answer = no;

if (cards[0][1] == trump && cards[1][1] != trump) {
  answer = yes;
}

if (cards[1][1] == cards[0][1] && ranks.indexOf(cards[0][0]) > ranks.indexOf(cards[1][0])) {
  answer = yes;
}

print(answer);


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

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

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

function max(arr) {
  var max = -Infinity
  for (var i = 0; i < arr.length; i++) {
    if (arr[i] > max)
      max = arr[i]
  }
  return max
}

function minArr(arr) {
  var min = Infinity
  for (var i = 0; i < arr.length; i++) {
    if (arr[i] < min)
      min = arr[i]
  }
  return min
}

// var params = [2, 2, 50]

// var buy = [5, 7]

// var sells = [4, 2]

var minBuy = minArr(buy);
var maxSell = max(sells);

if (minBuy >= maxSell)
  write(params[2])

else if (minBuy > params[2])
  write(params[2])

else {
  var moneyAfterBuying = params[2] % minBuy;
  var stocks = Math.floor(params[2] / minBuy);
  var moneyAfterSelling = moneyAfterBuying + (stocks*maxSell);

  write(moneyAfterSelling);
}


var arr = readline().split(" ").map(function(v) {return +v;});
var n = arr[0]-arr[1];

var c = 0;
for(var i = 1; i <= Math.sqrt(n); i++) {
    if(n%i !== 0) continue;

    count(i);
    if(i*i!==n)
        count(n/i);
}

function count(n) {
    if(n > arr[1])
        c++;
}

if(n===0)
    print("infinity");
else
    print(c);


var ip = readline().split(' ').map(Number);
var n = ip[0], k= ip[1];
if (k <= n){
    print(Math.floor((k-1)/2));
} else if ((k+1)/2 <= n){
       print(Math.floor((n-(k-n)+1)/2));
}else
print(0)