const fs = require("fs");
const input = fs.readFileSync(0, 'utf8').trim().split('\n');
let currentline = 0;
function readline(){
      return input[currentline++];
}

function alph() {
  var f = 'abcdefghijklmnopqrstuvwxyz';
  return f;
}
function Alph() {
  var f = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  return f;
}
function max(x,y) {
  return x >=y ? x : y;
}
function min(x,y) {
  return x <=y ? x : y;
}
function abs(x) {
  return x < 0 ? x*(-1) : x;
}

var T = readline();
// var inf = 1000000000000;
for(var qe=1;qe<=T;qe++) {
  // var n = readline();
  var [a,b] = readline().split(' ').map((x) => parseInt(x));
  var [c,d] = readline().split(' ').map((x) => parseInt(x));
  if(c==1&&d==1&&a==1&&b==1) console.log(2)
  else if(a==1||b==1||c==1||d==1) console.log(1)
  else console.log(0)
}


let data = ''
process.stdin.on('data', line => data += line)
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = data.split(EOL);
    let [n, k] = lines[0].split(' ').map(x => +x);

    while (k) {
      if (n % 10) {
        n--;
      } else {
        n /= 10;
      }

      k--;
    }

    console.log(n);
})


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

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var n1 = one[0];
  var n2 = one[1];
  var k1 = one[2];
  var k2 = one[3];
  myout((n1 > n2) ? "First" : "Second");
}


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

const input = [];
readLine.on('line', line => input.push(line));
const stones = () => {
   let length = +input[0];
   let s = input[1];
   let count = 0;
   for (let i = 1; i < length; i++) {
       if (s[i] === s[i -1]) {
           count++;
       }
   }
   console.log(count);
};

readLine.on('close', stones);


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();
});


process.stdin.setEncoding('utf8')
process.stdin.on('data', chunk => {
    const [n, m, a] = chunk.split(' ').map(s => parseInt(s))
    const ans = Math.ceil(n / a) * Math.ceil(m / a)
    // console.log(ans)
    process.stdout.write(String(ans))
})


const input = [];

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

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

RL.on('close', () => {
  const [d1, d2, d3] = input[0].split(' ').map(x => parseInt(x));

  console.log(
    Math.min(
      d1+d3+d2,
      d1+d1+d2+d2,
      d1+d3+d3+d1,
      d2+d3+d3+d2,
    )
  )
});


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

let stdinInput = '';

process.stdin.on('data', input => {
  stdinInput += input;
})

process.stdin.on('end', () => {
  main(stdinInput);
})

//"use strict";
function main(input) {
    var line = input.split("\n");
    var str1 = line[0];
    var str2 = line[1];
    str1 = str1.toLowerCase();
    str2 = str2.toLowerCase();
    var ans = str1.localeCompare(str2);
    console.log(ans);
}
//main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//main(require('fs').readFileSync('input.txt', 'utf8'));


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

const getNumber = (k) => {
  let str = '';
  let i = 1;

  while (str.length < k) {
    str += i;
    i += 1;
  }

  return str[k - 1];
};

const handleI = (i, k) => {
  if (i === 1) {
    return String(k);
  }

  // Получаем количество цифр в данном отрезке. К примеру в от резке [100, 199] - 300 цифр.
  const rangeCount = i * (10 ** (i - 1));
  // Число 522 лежит в отрезке [200, 299]
  const rangeIdx = Math.ceil((k + 1) / rangeCount);
  // Данное порядковое число.
  const rangeNum = (10 ** (i - 1)) * rangeIdx;
  const num = rangeNum + Math.floor(((k % rangeCount) - 1) / i);
  return String(num)[(k - 1) % i];
};

const optimalWayGetNumber = (k) => {
  // Изначально, предположим, что число 711
  let i = 1;
  while (k > 0) {
    k -= 9 * i * (10 ** (i - 1));
    i += 1;
  }

  i -= 1;
  // После данного этапа получаем номер цифры в заданном отрезке в зависимости от порядка.
  // Для предыдущего примера - это число 522.
  k += 9 * i * (10 ** (i - 1));
  return handleI(i, k);
};

readline.on('line', (line) => {
  const k = Number(line);

  console.log(optimalWayGetNumber(k));
});

module.exports = {
  getNumber,
  optimalWayGetNumber,
};


let i = '';
process.stdin.on('data', (c) => {
  i += c;
});
process.stdin.on('end', () => {
  const { EOL } = require('os');
  const lines = i.split(EOL);
  const [n, k] = lines[0].split(' ');
  console.log(getCandiesEaten(parseInt(n, 10), parseInt(k, 10)));
});

function getCandiesEaten(n, k) {
  if (n === 1) return 0;
  n--;
  let candies = 1;
  let sum = 2;
  let consumed = 0;
  while (n > 0) {
    while (candies <= k) {
      candies += sum;
      sum++;
      n--;
    }
    // Reduce candies to less than k
    const candiesToSubtract = candies - k;
    n -= candiesToSubtract;
    consumed += candiesToSubtract;
    candies -= candiesToSubtract;
  }
  return consumed;
}


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

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var t = one[1];
  var list = nextCharArray();
  for(var i = 0; i < t; i++){
    for(var j = 0; j < N - 1; j++){
      if(list[j] == "B" && list[j + 1] == "G"){
        list[j] = "G";
        list[j + 1] = "B";
        j++;
      }
    }
  }
  myout(myconv(list, 0));
}


'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

function print(s) {
  process.stdout.write(`${s}`);
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  // input
  const [k, r] = readline().split(' ').map(x => parseInt(x));
  let x = 1;
  while (k * x % 10 !== 0 && k * x % 10 !== r) {
    x++;
  }
  // output
  print(x);
}


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

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.num = function() {
		return Number(this.next().value);
	};
nl.nums = function() {
		return this.next().value.split(/\s/g).map(Number);
	};
nl.line = function() {
		return this.next().value;
	}

const sol = () => {
	let [n, k] = nl.nums();
	let a = nl.nums();
	let r = Array(n);
	r.fill(0);
	for(let i of a){
		for(let j = i-1; j < n && r[j] === 0; j++){
			r[j] = i;
		}
	}
	console.log(r.join(' '));

};

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


const readline = require("readline");

function substract(number, times) {

    let result = number;
    while (times > 0) {
        const lastDigit = getLastDigit(result);
        if (lastDigit == 0) {
            result = removeLastDigit(result);
        } else {
            result -= 1;
        }

        times--;
    }

    return result;
}

function getLastDigit(number) {
    const numberAsString = number.toString()
    const numberLength = numberAsString.length;
    const lastDigitAsString = numberAsString[numberLength - 1];
    return parseInt(lastDigitAsString);
}

function removeLastDigit(number) {
    const numberAsString = number.toString();
    const length = numberAsString.length;
    return parseInt(numberAsString.slice(0, length - 1));
}

// console.log(substract(512, 4));
// console.log(substract(1000000000, 9));

// function start() {
//     const line = readline();
//     const input = line.split(" ");
//     const number = parseInt(input[0]);
//     const repetitions = parseInt(input[1]);
//     console.log(substract(number, repetitions));
// }

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

rl.question("", function (line) {
    const input = line.split(" ");
    const number = parseInt(input[0]);
    const repetitions = parseInt(input[1]);
    console.log(substract(number, repetitions));

    rl.close();
});

// start();


var len = readline();
for(var i=0;i<+len;i++)
{
 var inputData = readline();
 var count = new Set();
for(var j=1;j*j<=+inputData;j++)
{
   count.add(j*j);
}
for(var k=1;k*k*k<=+inputData;k++)
{
   count.add(k*k*k);
}
print(count.size);
count.delete(count.size);
}
/*
 if((Math.floor(Math.sqrt(j)) == Math.ceil(Math.sqrt(j)))
    && (Math.floor(Math.cbrt(j)) == Math.ceil(Math.cbrt(j))))
    {
        count++;
    }
    else if (Math.floor(Math.sqrt(j)) == Math.ceil(Math.sqrt(j)))
    count++;
    else if (Math.floor(Math.cbrt(j)) == Math.ceil(Math.cbrt(j)))
    count++;
    */


const readline = require('readline');

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

let count = 0;

const compare = (a, b, count) => {
    a > b ? console.log(count) : compare((a * 3), (b * 2), ++count);
}

rl.on('line', (line) => {
  let array = line.toString().trim().split(' ').map(Number);

  compare(array[0], array[1], count);

  rl.close();
});


process.stdin.setEncoding('ASCII');
let string = '';
process.stdin.on('data', (data) => string += data);

const main = (input) => {
    const ns = input[0].split(' ').map(Number);
    const vol = input[1].split(' ').map(Number);

    let sum = 0, mx = 0;

    vol.forEach( (val) => {
        sum += val;
        mx = Math.max(mx, val);
    });

    if ((sum - mx) <= ns[1]) console.log("YES");
    else console.log("NO");
};

process.stdin.on('end', () => main( string.trim().split('\n') ));


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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    let [t] = readline().split(' ').map(num => parseInt(num));
    for (let i = 0; i < t; i++) {
        let [n] = readline().split(' ').map(num => parseInt(num));
        let cnt = 1;
        for (let j = 2; j <= Math.sqrt(n); j++) {
            if (j * j <= n && !Number.isInteger(Math.cbrt(j))) cnt++;
            if (j * j * j <= n && (!Number.isInteger(Math.sqrt(j)) || Math.sqrt(j) * Math.sqrt(j) * Math.sqrt(j) > j)) cnt++;
        }
        console.log(cnt);
    }
}


// https://codeforces.com/problemset/problem/977/B
// Big O:
// Time complexity: O(n)
// Space complexity: O(n)

const readline = require("readline");

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

let stringLength;
rl.on('line', (input) => {
    if (stringLength) {
        console.log(findMostCommonGram(input, stringLength));
        rl.close();
    } else {
        stringLength = input;
    }
});

// Problem
function findMostCommonGram(string, stringLength) {
    let mostCommonGram = "";
    let mostCommonGramOccurrences = 0;
    const gramOccurrences = {};

    for (let i = 0; i < stringLength - 1; i++) {
        const twogram = string[i] + string[i + 1];
        const occurrences = gramOccurrences[twogram] ? gramOccurrences[twogram] + 1 : 1;
        const currentOcurrences = occurrences + 1;
        if (currentOcurrences > mostCommonGramOccurrences) {
            mostCommonGram = twogram;
            mostCommonGramOccurrences = currentOcurrences;
        }

        gramOccurrences[twogram] = currentOcurrences;
    }

    return mostCommonGram;
}


var line_number = 0;
const cs = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

var lines = {};
cs.on("line", (input) => {
  if (input == "") {
    cs.close();
  }
  lines[line_number] = input.split(" ");
  line_number += 1;
}).on("close", () => {
  main();
  process.exit();
});

function isOp(str) {
  return str.length === 1 && str.match(/[<=>]/);
}
function isChr(str) {
  return str.length === 1 && str.match(/[a-z]/i);
}
function isInt(str) {
  return str.length === 1 && str.match(/[0-9*]/);
}

function print(str) {
  console.log(str);
}

function exit(status = 0) {
  process.exit(status);
}

function predict(test) {
  let op = "";
  let ops = [];
  let opVariables = [];
  let limits = [];
  for (let t of test) {
    // console.log(t);
    for (let i = 0; i < t.length; i++) {
      if (isOp(t[i])) {
        op = t[i];
        if (isOp(t[i + 1])) {
          op += t[i + 1];
          i += 1;
        }
        ops.push(op);
        op = "";
      } else if (isChr(t[i])) {
        // console.log(t[i])
        op = t[i];
        for (var j = i + 1; j < t.length; j++) {
          if (isChr(t[j]) || isInt(t[j])) {
            op += t[j];
            i = j;
          } else break;
        }
        opVariables.push(op);
        op = "";
      } else {
        if (i == 0 || (i > 0 && isOp(t[i - 1]))) {
          op = t[i];
          let j = i + 1;
          for (; j < t.length; j++) {
            if (isInt(t[j])) {
              op += t[j];
              i = j;
            } else break;
          }
          limits.push(op);
          op = "";
        }
      }
    }
  }

  let min = limits[0];
  let max = limits[1];

  let pvs = ops.map((o, i) => [o, opVariables[i]]);

  for (let pv of pvs) {
    if (pv[1] == undefined) {
      pv[1] = max;
    }
    // print(`${min} ${pv[0]} ${pv[1]} ?`)
    if (eval(`${min}${pv[0]}${pv[1]}`)) {
      // print(` ${min} ${pv[0]} ${pv[1]} true`)
      min = pv[1];
    } else {
      print("input error");
      exit();
    }
  }
}

var n;
function main() {
  x = BigInt(lines[0][0])
  predict(["1<=x<=10**15"]);

  let S=0,e=0,o=0
  if (x%2n == 0) {
    e = (x*x+2n*x)/4n
    o = (x*x)/4n
  }
  else
  {
    e = ((x-1n)*(x-1n)+2n*(x-1n))/4n
    o = ((x+1n)*(x+1n))/4n
  }

  print(Number(e-o))

}


const readline = require('readline');

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

rl.question('', (weight) => {
    if (weight <= 3) {
        console.log('NO');
        return;
    }

    var answer = weight % 2;
    console.log(answer ? 'NO' : 'YES');
    rl.close();
});


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

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

readline.on('close', () => {
    const [n, m] = Array.from(input[0].split(' '), v => parseInt(v));
    const puzzles = Array.from(input[1].split(' '), v => parseInt(v));
    puzzles.sort((a, b) => a - b);

    let min = Number.MAX_SAFE_INTEGER;
    for(i = 0; i <= puzzles.length - n; i++) {
        let distance = puzzles[i + n - 1] - puzzles[i];
        if(distance < min) min = distance;
    }

    console.log(min);
});


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

rl.on('line', function(line) {
	DominoPiling(line);

	rl.close();
});

//M N
let DominoPiling = (line) => {
	let input = line.split(' ');
	let M = input[0] * 1;
	let N = input[1] * 1;

	let num1 = M % 2 === 0 ? M / 2 : (M - 1) / 2;
	if (num1 === M / 2) {
		console.log(num1 * N);
	} else {
		console.log(num1 * N + Math.floor(N / 2));
	}
};


const readline = require('readline');

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

rl.on('line', (input) => {
    rl.close();
    let line = input.split(' ');
    console.log(solve(parseInt(line[0]), parseInt(line[1])));
});

const solve = (pOfShovel, rBurles) => {
    let noOfShovels = 1;
    while ((pOfShovel * noOfShovels % 10) !== 0 && ((pOfShovel * noOfShovels - rBurles) % 10 !== 0)) {
        noOfShovels++;
    }
    return noOfShovels;
}


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

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

readline.on('close', () => {
    let [l, b] = Array.from(input[0].split(' '), x => parseInt(x));
    let i = 0;
    while (l <= b) {
        l *= 3;
        b *= 2;
        i++;
    }

    console.log(i);
});


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

rl.on('line', (d) => {
  const arr = d.split(' ');
  const uniqueArr = new Set(arr);
  const ans = arr.length - uniqueArr.size;

  console.log(ans);
});


'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

function readLine() {
    return inputString[currentLine++];
}
function main(){
let n=readLine();
let twoGram=readLine();
let res=0;
let answer=" ";
for(let i=0;i<n-1;i++){
    let cur=0;
    for(let j=0;j<n-1;j++){
        if(twoGram[j]==twoGram[i] && twoGram[j+1] == twoGram[i+1])
        cur++;
        if(res<cur){
            res=cur;{
                answer=twoGram[i]+twoGram[i+1];
            }

        }

    }

}

     console.log(answer);
}


const readline = require('readline');

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

/*
       012345678910
str = "abcdZZZefgh"

strart = 4
len = 3

       012345
input="///one"
       01234
input="//one"
*/
var eraseAt = function (str, start, len) {
    return str.substring(0, start) + str.substring(start + len);
}

rl.on('line', (input) => {
    /*
    method I.
      for(let i=0; i<input.length-1; i++){
          if(input[i]=='/' && input[i+1]=='/'){
               input=eraseAt(input, i, 1);
               i--;
          }
      }

      if(input.length > 1 && input[input.length-1] == '/')
           input = eraseAt(input ,input.length-1, 1);

      console.log(input);
      rl.close();
      */
    let ans = "", len = input.length, met = false;
    for (let i = 0; i < len - 1; i++) {
        if (input[i] == '/' && input[i + 1] != '/')
            ans += '/';
        else if (input[i] != '/') {
            ans += input[i];
            met = true;
        }
    }
    if (!met || input[len - 1] != '/')
        ans += input[len - 1];

    console.log(ans);

    rl.close();
});


const readline = require('readline');

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

rl.on('line', function(line) {
	const str = line.toLowerCase();
	const remove = 'aoyeui';
	let res = '';
	for (let i = 0; i < str.length; i++) {
		if (remove.indexOf(str[i]) < 0) {
			res += '.' + str[i];
		}
	}
	console.log(res);
	rl.close();
});


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 = 1e9 + 7;

function main () {
	let t = rn();
	while (t--) {
		let [n, k] = rna();

		let ans = 1;
		for (let i = 1; i <= k; i++)
			ans = (ans * n) % MOD;

		console.log(ans);
	}
}


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[0].split(' ')
  const a1 = parseInt(ax[0])
  const a2 = parseInt(ax[1])
  const a3 = parseInt(ax[2])
  const a4 = parseInt(ax[3])

  var f = false

  if(a1 + a2 == a3 + a4) f = true
  else if(a1 + a3 == a2 + a4) f = true
  else if(a1 + a4 == a3 + a2) f = true
  else if(a1 + a2 + a3 == a4) f = true
  else if(a1 + a2 + a4 == a3) f = true
  else if(a1 + a4 + a3 == a2) f = true
  else if(a2 + a4 + a3 == a1) f = true

  if(f) console.log('YES')
  else console.log('NO')
})


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

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

  const cards = d.split(' ');
  let ans = 'NO';

  for (let i = 0; i < cards.length; i++) {
    if (tableCard[0] === cards[i][0] || tableCard[1] === cards[i][1]) {
      ans = 'YES';
      break;
    }
  }

  console.log(ans);

  c++;
});


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

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}

function main() {
  const arr = readLine()
    .split(" ")
    .map((n) => parseInt(n));
  let found = false;
  const total = arr.reduce((s, n) => s + n, 0);

  for (let i = 0; i < 4; i++) {
    for (let j = i + 1; j < 5; j++) {
      for (let k = j + 1; k < 6; k++) {
        const sum = arr[i] + arr[j] + arr[k];
        const otherSum = total - sum;
        if (sum === otherSum) {
          found = true;
          break;
        }
      }
    }
  }

  if (found) console.log("YES");
  else console.log("NO");
}


const readline = require('readline');

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

rl.on('line', line => {
    const str = line.toLowerCase().slice(' ');
    // console.log(str);
    const remove = 'aoyeui';
    let res = ' ';
    for (let i = 0; i < str.length; i++) {
        if (remove.indexOf(str[i]) < 0) {
            res += '.' + str[i];
        }
    }
    console.log(res);
    rl.close();
});


const readline = require('readline');

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

rl.on('line', (input) => {
    let line = input.split(' ');
    let limakW = parseInt(line[0]);
    let bobW = parseInt(line[1]);
    rl.close();
    console.log(solve(limakW, bobW));

});

const solve = (limakW, bobW) => {
    let year = 0;
    while (limakW <= bobW) {
        limakW *= 3;
        bobW *= 2;
        year++;
    }
    return year;
};


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

const input = [];
readLine.on('line', line => input.push(line));
const mathHelp = () => {
    let s=  input.toString();
    let string = s.split('+');
    string.sort();
    console.log(string.join('+'));
};
readLine.on('close', mathHelp);


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

rl.on('line', (d) => {
  console.log(Math.floor(+d / 2) + 1);
});


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

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

function main() {
	let n = readLine() >> 0;

	if ((n & 1) === 1) {
		console.log(0);
	} else {
		console.log(1 << (n / 2));
	}
}


'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    const str=  readline();
    let unique =  new Set(str);
    let result = unique.size %2 ===0? "CHAT WITH HER!":"IGNORE HIM!";
    console.log(result);
    return;
}


const readline = require('readline');

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

rl.on('line', line1 => {
    var arr = line1.split(' ');
    var plateSide = parseInt(arr.splice(-1));
    var sides = arr.map(item => parseInt(item));
    // console.log(plateSide, sides);

    var [isCoversFirstSide, forFirstSide] = prepareResult(sides[0], plateSide);
    var [isCoversSecondSide, forSecondSide] = prepareResult(sides[1], plateSide);

    // console.log(isCoversFirstSide, forFirstSide, isCoversSecondSide, forSecondSide);

    var result = forFirstSide * forSecondSide;

    var needCorner = 0;

    if (!isCoversFirstSide) {
        result += forSecondSide;
        needCorner += 1;
    }

    if (!isCoversSecondSide) {
        result += forFirstSide;
        needCorner += 1;
    }

    if (needCorner === 2) result += 1;

    console.log(result);

    rl.close();
});

function prepareResult(sideSize, plateSize) {
    if (sideSize <= plateSize) return [true, 1];

    var platesForSideFloat = sideSize / plateSize;
    var plateForSideInt = parseInt(platesForSideFloat);
    var isCovers = platesForSideFloat === plateForSideInt;

    return [isCovers, plateForSideInt];
}


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 = readLine().split('');
	let ld = 0;
	n.forEach(d => {
		if (+d === 4 || +d === 7) {
			ld++;
		}
	});

	if (ld === 4 || ld === 7) console.log('YES');
	else console.log('NO');
}


function ProblemSolver() {
    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;
    this.CLEAR_ARRAY_PER_CASE = false;

    this.solveCase = function() {
        var res , i , j , fl , cn , temp , a , b , c ;
        res = 0 ;
        a = Math.max( this.n , this.m ) ;
        for( i = 0 ; i <= a ; i++ ) {
        	for( j = 0 ; j <= a ; j++ ) {
        		b = i * i + j ;
        		c = i + j * j ;
        		if( b == this.n && c == this.m ) {
        			res++ ;
        		}
        	}
        }
        print( res );
    };

    this.init = function() {
        this.lim1 = 100010;
        this.lim2 = 110;
        this.cc = 1;
        this.ind = 1;
        this.n = 0;
        this.cn = 0;
        this.declareAndFillArrays();
    };

    this.getInput = function( irObj ) {
        var hasMoreInput , i;
        hasMoreInput = true;
        try {
            this.n = irObj.nextInt();
            this.m = irObj.nextInt();
        }
        catch( ex ) {
            hasMoreInput = false;
        }
        return hasMoreInput;
    };

    this.clearArraysPerCase = function() {
        var i;
        this.arr = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.arr.push( 0 );
            this.adj_list.push( new Array() );
        }
    };

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        if( this.CLEAR_ARRAY_PER_CASE == true ) {
            this.clearArraysPerCase() ;
        }
    };

    this.declareAndFillArrays = function() {
        var i , j;
        this.srr = new Array();
        this.vis = new Array();
        this.arr = new Array();
        this.brr = new Array();
        this.memo = new Array();
        this.done = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.srr.push( "" );
            this.vis.push( 0 );
            this.arr.push( 0 );
            this.brr.push( 0 );
            this.adj_list.push( new Array() );
        }
        for( i = 0 ; i < this.lim2 ; i++ ) {
            this.memo.push( new Array() );
            this.done.push( new Array() );
            for( j = 0 ; j < this.lim2 ; j++ ) {
                this.memo[ i ].push( -1 );
                this.done[ i ].push( 0 );
            }
        }
    };

    this.init();
}

function InputReader() {
    var self = this ;
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;
    this.callBackFunction = null ;
    this.parentContext = null ;

    this.readAllLines = function() {
        var singleLine;
        while( true ) {
            try {
                singleLine = readline();
                if( singleLine == null ) {
                    break;
                }
            }
            catch( ex ) {
                break;
            }
            this.allLines.push( singleLine );
        }
    };

    this.readAllLinesFromRhino = function() {
        var brObj , line ;
        importPackage( java.io ) ;
        importPackage( java.lang ) ;
        brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;
        this.allLines = [] ;
        while( true ) {
            line = brObj.readLine() ;
            if( line == null ) {
                break;
            }
            this.allLines.push( line ) ;
        }
    };

    this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {
        self.chunkData += chunk ;
    };

    this.readEndFromNodeJsJudgeServer = function() {
        self.parseRawData( self.chunkData ) ;
        self.parentContext.runCases() ;
    };

    this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {
        this.parentContext = parentContext ;
        process.stdin.resume() ;
        process.stdin.setEncoding( 'utf8' ) ;
        this.chunkData = '' ;
        process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;
        process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;
    };

    this.parseRawData = function( data ) {
        var len , i , currentString;
        len = data.length;
        currentString = "";
        this.allLines = [] ;
        for( i = 0 ; i < len ; i++ ) {
            if( data[ i ] == '\r' ) {
            }
            else if( data[ i ] == '\n' ) {
                this.allLines.push( currentString );
                currentString = "";
            }
            else {
                currentString += data[ i ];
            }
        }
        if( currentString != "" ) {
            this.allLines.push( currentString );
        }
    };

    this.readAllLinesFromFile = function( inputFileName ) {
        var currentDirectory , fsObj , inputFilePath , rawData;
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        inputFilePath = currentDirectory + "\\" + inputFileName;
        rawData = fsObj.readFileSync( inputFilePath , "utf8" );
        this.parseRawData( rawData );
    };

    this.next = function( flag ) {
        var len , i , startIdx , res , endIdx;
        if( flag == 0 ) {
            if( this.currrentCharacterIndex != 0 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            res = "";
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;
            }
            this.currrentLineNumber++;
            this.currrentCharacterIndex = 0;
            return res;
        }
        while( true ) {
            if( this.currrentLineNumber >= this.allLines.length ) {
                throw new Error( "No more tokens available!" );
            }
            startIdx = -1;
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {
                    startIdx = i;
                    break;
                }
            }
            if( startIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
                continue;
            }
            res = "";
            endIdx = len - 1 ;
            for( i = startIdx ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {
                    endIdx = i;
                    break;
                }
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {
                    res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;
                }
                else {
                    res += '' + this.allLines[ this.currrentLineNumber ].charAt( i );
                }
            }
            this.currrentCharacterIndex = endIdx;
            if( endIdx == len - 1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            return res;
        }
    };

    this.nextInt = function() {
        return parseInt( this.next( 1 ) );
    };

    this.nextDouble = function() {
        return parseFloat( this.next( 1 ) );
    };

    this.nextString = function() {
        return this.next( 1 );
    };

    this.nextLine = function() {
        return this.next( 0 );
    };
}

function FileOutputHandler() {
    this.resultantStringArray = new Array();

    this.addNewLine = function( newString ) {
        this.resultantStringArray.push( newString );
    };

    this.clearPercase = function() {
        this.resultantStringArray = new Array();
    };

    this.flushOutOutputToFile = function( outputFileName ) {
        var i , sz , res , currentDirectory , fsObj , outputFilePath;
        res = "";
        sz = this.resultantStringArray.length;
        for( i = 0 ; i < sz ; i++ ) {
            if( i != 0 ) {
                res += "\n";
            }
            res += this.resultantStringArray[ i ];
        }
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        outputFilePath = currentDirectory + "\\" + outputFileName;
        fsObj.writeFileSync( outputFilePath , res );
        this.clearPercase();
    };
}

function CodeExecutioner() {
    this.irObj = new InputReader();
    this.psObj = new ProblemSolver();
    this.fohObj = new FileOutputHandler();

    this.runCases = function() {
        if( this.psObj.HAS_TEST_CASES == true ) {
            testCases = this.irObj.nextInt();
            for( i = 0 ; i < testCases ; i++ ) {
                this.psObj.clearPerCase();
                this.psObj.getInput( this.irObj );
                this.psObj.solveCase();
            }
        }
        else {
            while( true ) {
                this.psObj.clearPerCase();
                hasMoreTestCases = this.psObj.getInput( this.irObj );
                if( hasMoreTestCases == false ) {
                    break;
                }
                this.psObj.solveCase();
            }
        }
        if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.detectEnvironmentType = function() {
        var environmentType = null ;
        try {
            if( importPackage != null ) {
                environmentType = 'rhino' ;
            }
        }
        catch( ex1 ) {
            try {
                //for nodejs local server check
                if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {
                    environmentType = 'local-node-js' ;
                }
            }
            catch( ex2 ) {
                try {
                    if( readline == null || typeof( readline ) != 'function' ) {
                        environmentType = 'server-node-js' ;
                    }
                    else {
                        try {
                            if( Map != null ) {
                                environmentType = 'spider-monkey' ;
                            }
                            else {
                                environmentType = 'javascript-v8' ;
                            }
                        }
                        catch( ex3 ) {
                            environmentType = 'javascript-v8' ;
                        }
                    }
                }
                catch( ex3 ) {
                    environmentType = 'server-node-js' ;
                }
            }
        }
        return environmentType ;
    };

    this.configureStreamsAndReadInput = function() {
        var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , environmentType ;
        isNodeJsJudgeServer = false ;
        environmentType = this.detectEnvironmentType() ;
        if( environmentType == 'local-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
                localContext = this.fohObj;
                print = function() {
                    localContext.addNewLine.apply( localContext , arguments );
                }
            }
            this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );
            this.runCases() ;
        }
        else if( environmentType == 'server-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;
        }
        else if( environmentType == 'javascript-v8' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
        else if( environmentType == 'rhino' ) {
            this.irObj.readAllLinesFromRhino();
            this.runCases() ;
        }
        else if( environmentType == 'spider-monkey' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
    };

    this.configureStreamsAndReadInput();
}

new CodeExecutioner();


'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 readAsInt(){
  return parseInt(readline());
}

function readAsIntList(){
  return readline().split(' ').filter(i => i).map(i => parseInt(i));
}

// Make a Snippet for the code above this and then write your logic in main();

function main() {
  let [k,n,w] = readAsIntList();
  let total = 0;
  for(let i = 1; i <= w; i++) {
    total += k * i;
  }
  console.log(Math.max(total - n, 0));
}


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

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  if(one[0] % 2 == 1 && one[1] % 2 == 1){
    myout((one[0] * one[1] - 1) / 2);
  }else{
    myout((one[0] * one[1]) / 2);
  }
}


var line_number = 0;
const cs = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

var lines = {};
cs.on("line", (input) => {
  if (input == "") {
    cs.close();
  }
  lines[line_number] = input.split(" ");
  line_number += 1;
}).on("close", () => {
  main();
  process.exit();
});

function isOp(str) {
  return str.length === 1 && str.match(/[<=>]/);
}
function isChr(str) {
  return str.length === 1 && str.match(/[a-z]/i);
}
function isInt(str) {
  return str.length === 1 && str.match(/[0-9*]/);
}

function print(str) {
  console.log(str);
}

function exit(status = 0) {
  process.exit(status);
}

function predict(test) {
  let op = "";
  let ops = [];
  let opVariables = [];
  let limits = [];
  for (let t of test) {
    // console.log(t);
    for (let i = 0; i < t.length; i++) {
      if (isOp(t[i])) {
        op = t[i];
        if (isOp(t[i + 1])) {
          op += t[i + 1];
          i += 1;
        }
        ops.push(op);
        op = "";
      } else if (isChr(t[i])) {
        // console.log(t[i])
        op = t[i];
        for (var j = i + 1; j < t.length; j++) {
          if (isChr(t[j]) || isInt(t[j])) {
            op += t[j];
            i = j;
          } else break;
        }
        opVariables.push(op);
        op = "";
      } else {
        if (i == 0 || (i > 0 && isOp(t[i - 1]))) {
          op = t[i];
          let j = i + 1;
          for (; j < t.length; j++) {
            if (isInt(t[j])) {
              op += t[j];
              i = j;
            } else break;
          }
          limits.push(op);
          op = "";
        }
      }
    }
  }

  let min = limits[0];
  let max = limits[1];

  let pvs = ops.map((o, i) => [o, opVariables[i]]);

  for (let pv of pvs) {
    if (pv[1] == undefined) {
      pv[1] = max;
    }
    // print(`${min} ${pv[0]} ${pv[1]} ?`)
    if (eval(`${min}${pv[0]}${pv[1]}`)) {
      // print(` ${min} ${pv[0]} ${pv[1]} true`)
      min = pv[1];
    } else {
      print("input error");
      exit();
    }
  }
}

var a,b;
function main() {
  [a,b] = lines[0].map(x => parseInt(x))
  predict(["1<=a<=b<=10"])
  let years = 0
  for (;;a=a*3,b=b*2,years++) {
    if (a <= b ){
        continue;
    }
    else break;
  }
  print(years)
}


const input = [];

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

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

readLine.on("line", (line) => {
  input.push(line);
});

readLine.on("close", () => {
  const [n, m, a] = splbsi(input[0]);
  console.log(parseInt(Math.ceil(m / a) * Math.ceil(n / a)));
});


const readline = require("readline");
const solve = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
let data = [];
const main = () => {
    solve.question('', (value) => {
      data = value.split(' ').map(Number);
      var res = data[0] * data[1];
      res /= 2;
      console.log(Math.floor(res));
      solve.close();
    })
}
main()


process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', (inputStd) => {
    inputString += inputStd;
});
process.stdin.on('end', function () {
    inputString = inputString
        .trim()
        .split('\n')
        .map((str) => {
            return str.trim();
        });
    main();
});
function readLine() {
    return inputString[currentLine++];
}

function main() {
    let numberString = readLine();
    let numberArray = numberString.split('');
    let luckyDigits = [];
    for (let i = 0; i < numberArray.length; i++) {
        if (numberArray[i] === '7' || numberArray[i] === '4') {
            luckyDigits.push(numberArray[i]);
        }
    }
    if (luckyDigits.length === 7 || luckyDigits.length === 4) {
        console.log('YES');
    } else {
        console.log('NO');
    }
}


function main(stdin) {
    var _a = stdin.split(" ").map(function (v) { return parseInt(v); }), n = _a[0], m = _a[1], a = _a[2];
    console.log(Math.ceil(n / a) * Math.ceil(m / a));
}
main(require("fs")
    .readFileSync(0, "utf-8")
    .trim());


var readline = require('readline');
var z = readline.createInterfrace
var r = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal: false
});
var b = [];
r.on('line', function (line) {
    b.push(line);
    if(b.length == 2){
        r.close();

        bain();
    }
});
function bain(){
    let a = "";
    for(let k = 0; k<b[0].length; k++){
        if(b[0].substr(k,1) != b[1].substr(k,1)){
            a += "" + 1;
        } else{
            a += "" + 0;
        }
    }
    console.log(a + "");
}


function findGreeting(str) {
  const word = 'hello';
  let i = 0;
  for(const l of str) {
    if(word.length > i && l === word[i]) {
      i++;
    }
  }
  return i === word.length ? 'YES' : 'NO';
}

const { EOL } = require('os');

let i = '';

process.stdin.on('data', c => i += c)
        process.stdin.on('end', () => {
            const lines = i.split(EOL)
            const res = findGreeting(lines[0])
            console.log(res);
        })


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

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

readLine.on('close', () => {
  const k = parseInt(input[0]);
  const l = parseInt(input[1]);
  const m = parseInt(input[2]);
  const n = parseInt(input[3]);
  const d = parseInt(input[4]);

  let answ = 0;
  for (let i = 1; i <= d; i += 1) {
    if (i % k === 0 || i % l === 0 || i % m === 0 || i % n === 0) answ += 1;
  }

  console.log(answ);
});


let lines = [];
require('readline').createInterface({input: process.stdin,output: process.stdout})
				.on('line', line => {lines.push(line);})
				.on('close', () => {main(lines)});

const main = (input) => {
	var tableCard = input[0].split("");
	var tableValue = tableCard[0];
	var tableSuit = tableCard[1];
	var handCards = input[1].split(" ");

	for (var i = 0; i < 5; i++) {
		if (handCards[i][0] == tableValue || handCards[i][1] == tableSuit) {
			console.log("YES");
			return;
		}
	}
	console.log("NO");
}


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

function input(){
    return new Promise ( (resolve , error) => {
       readline.question('', (data) => {
           //readline.close();
           resolve(data);
       })
    });
}

async function main(){
    n  = await input();
    if(n == 2 || n % 2 == 1){
        console.log('NO');
    } else {
        console.log('YES');
    }
}

main();


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

let stdinInput = '';

process.stdin.on('data', input => {
  stdinInput += input;
})

process.stdin.on('end', () => {
  main(stdinInput);
})

function main(data) {
    data = data.split('\n');
    const testCases = data[0] * 1;
    let i = 1;
    while (i <= testCases) {
      let a = data[i].trim();
      // const n = data[i] * 1;
      // const k = a[1];
      // let s = data[i + 1].trim().split(' ').map(Number);
      // s.sort((a, b) => b - a);
      let press = 0;
      out:
      for (let j = 1; j < 10; j += 1) {
        let k = j + '';
        while (k.length <= 4) {
          press += k.length;
          if (k === a) {
            break out;
          } else k += j;
        }
      }
      console.log(press);
      i += 1;
    }
}


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

rl.on('line', function(line) {
	chatRoom(line);
	rl.close();
});

//M N
let chatRoom = (input) => {
	//hello
	let word = [ 'h', 'e', 'l', 'l', 'o' ];
	let count = 0;
	for (let i = 0; i < input.length; i++) {
		if (input.charAt(i) === word[count]) {
			count++;
			if (count === 5) break;
		}
	}
	count === 5 ? console.log('YES') : console.log('NO');
};


const readline = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
})
readline.question("",ans=>{
    ans=ans.split(" ")

    var each_Banana_money=ans[0]
    var initial_Money=ans[1]
    var banana_Want=ans[2]

    var res=calculate(-initial_Money,banana_Want,each_Banana_money)
    console.log(res>-1?res:0)
    readline.close()
})

function calculate(total_Money,banana_Want,each_Banana_money){
    return banana_Want==0?total_Money:calculate(total_Money+(each_Banana_money*banana_Want),banana_Want-1,each_Banana_money)
}


'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();
});

const readLine=()=> inputString[currentLine++];
/* ================================================
           Main Solution Starts Here
===================================================*/

const main=()=>{
	let first=+readLine()
	let second=+readLine()
	let third = first+second
	let newFirst='', newSecond='' , newThird2=''
	for(let char of first.toString())
		if(char!=='0')
			newFirst+=char
	for(let char of second.toString())
			if(char!=='0')
				newSecond+=char
	for(let char of third.toString())
		if(char!=='0')
			newThird2+=char
	let newThird=+newFirst + (+newSecond)

	if(+newThird2===newThird)
		console.log('YES')
	else console.log('NO')

}


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

function test(t) {
  if (t < 1 || t > 100) {
    console.log("input error");
    process.exit();
  }
}

readline.on("line", (input) => {
readline.close()
////////////////////////////////////////////////////////////////
test(input);

for (let i = 1; i < input; i++) {
  if (i % 2 == 0) {
    let m = input - i;
    if (m % 2 == 0) {
      console.log("YES");
      process.exit();
    }
  }
}
console.log("NO")

})


const readline = require("readline");

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

rl.question("", (firstLine) => {
  const [n, k] = firstLine.split(" ").map((numStr) => parseInt(numStr));

  rl.question("", (scopeListString) => {
    let result = 0;
    const scopeList = scopeListString
      .split(" ")
      .map((numStr) => parseInt(numStr));
    let scopesOfWinners = scopeList.slice(0, k);

    if (scopesOfWinners[0] > 0) {
      const scopesOfAdditionalParticipans = scopeList.slice(k);

      scopesOfAdditionalParticipans.forEach((scope) => {
        if (scope !== scopesOfWinners[scopesOfWinners.length - 1]) {
          return;
        }
        scopesOfWinners.push(scope);
      });

      result = scopesOfWinners.length;
    }

    scopesOfWinners = scopesOfWinners.filter((n) => n > 0);
    result = scopesOfWinners.length;

    console.log(result);
    rl.close();
  });
});


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 multiply(a, b) {
	a = a.toString(10).split('').reverse();
	b = b.toString(10).split('').reverse();

	if (a.length < b.length) {
		[a, b] = [b, a];
	}

	let res = Array(a.length + b.length).fill(0);
	for (let i = 0, lb = b.length; i < lb; ++i) {
		let carry = 0;
		let scarry = 0;
		for (let j = 0, la = a.length; j < la; ++j) {
			let m = b[i] * a[j];
			m += carry;

			if (m > 9) {
				let [c, d] = m.toString(10).split('');
				res[i + j] += (scarry >> 0) + (d >> 0);
				carry = c >> 0;
			} else {
				res[i + j] += (scarry >> 0) + m;
				carry = 0;
			}

			if (res[i + j] > 9) {
				let [c, d] = res[i + j].toString(10).split('');
				res[i + j] = d >> 0;
				scarry = c;
			} else {
				scarry = 0;
			}
		}
		if (carry > 0) res[a.length + i] = carry;
		if (scarry > 0) res[a.length + i] = scarry;
	}

	res.reverse();
	let mulVal = '';
	let flag = false;
	res.forEach(d => {
		if (!flag && d !== 0) flag = true;
		if (flag) mulVal += d;
	});
	return mulVal;
}

function main() {
	let n = readLine() >> 0;
	let pages = readLine()
		.split(' ')
		.map(x => x >> 0);
	let i = 0,
		s = 0,
		d = 0;
	while (true) {
		s += pages[i++];
		if (s >= n) {
			d = i;
			break;
		}
		if (i % 7 === 0) i = 0;
	}
	console.log(d);
}


const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
let input = [];
rl.on('line', line => {
    input.push(line);
})
rl.on('close', line => {
    var t = Number(input[0]);
    var mod = 10 ** 9 + 7;
    for (var j = 1; j < input.length; j++) {
        var [n, k] = input[j].split(" ").map((i) => {
            return Number(i);
        });
        var product = 1;
        for (var i = 1; i <= k; i++) {
            product = (product * n % mod);
        }
        console.log(product);
    }
})


let fs=require("fs")

let txt=fs.readFileSync(0,"utf-8").split("\r\n").filter(data=>{return data.length>0})

txt.forEach(element => {
    football(element)
});

function football(str){
    if(str.match("0000000")!=null ||str.match("1111111")!=null){
        console.log("YES");
    }else{
        console.log("NO");
    }
}


const input = [];

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

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

function fact(n) {
  if (n-1 === 0) return 1;
  return n * fact(n-1);
}

RL.on('close', () => {
  const [a, b] = input[0].split(' ').map(x => parseInt(x));

  console.log(fact(Math.min(a, b)));
});


// https://codeforces.com/problemset/problem/1091/A
// Big O:
// Time complexity: O(n)
// Space complexity: O(n)

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

rl.on('line', (input) => {
    const numbers = input.split(" ").map(Number);
    const yellow = numbers[0];
    const blue = numbers[1];
    const red = numbers[2];
    console.log(findMaxOrnaments(yellow, blue, red));
    rl.close();
});

function findMaxOrnaments(yellow, blue, red) {
    const minimum = Math.min(yellow, blue, red)

    if (minimum == yellow) {
        return findMaxWithYellowMinimum(yellow, blue, red);
    }

    if (minimum == blue) {
        return findMaxWithBlueMinimum(yellow, blue, red);
    }

    return findMaxWithRedMinimum(yellow, blue, red);
}

function findMaxWithYellowMinimum(yellow, blue, red) {
    let solutionFound = false;

    let yellowChosen = yellow;
    let blueChosen = 0;
    let redChosen = 0;

    while (!solutionFound) {
        blueChosen = 1 + yellowChosen;
        redChosen = 2 + yellowChosen;
        if (blueChosen > blue || redChosen > red) {
            yellowChosen = yellowChosen - 1;
        } else {
            solutionFound = true;
        }

    }
    return yellowChosen + blueChosen + redChosen;
}

function findMaxWithBlueMinimum(yellow, blue, red) {
    let solutionFound = false;

    let yellowChosen = 0;
    let blueChosen = blue;
    let redChosen = 0;

    while (!solutionFound) {
        yellowChosen = blueChosen - 1;
        redChosen = blueChosen + 1;
        if (yellowChosen > yellow || redChosen > red) {
            blueChosen = blueChosen - 1;
        } else {
            solutionFound = true;
        }

    }

    return yellowChosen + blueChosen + redChosen;
}

function findMaxWithRedMinimum(yellow, blue, red) {
    let solutionFound = false;

    let yellowChosen = 0;
    let blueChosen = 0;
    let redChosen = red;

    while (!solutionFound) {
        yellowChosen = redChosen - 2;
        blueChosen = redChosen - 1;
        if (yellowChosen > yellow || blueChosen > blue) {
            redChosen = redChosen - 1;
        } else {
            solutionFound = true;
        }

    }
    return yellowChosen + blueChosen + redChosen;
}


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

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

readline.on('close', () => {
    const [n, k] = Array.from(input[0].split(' '), v => parseInt(v));
    let center = Math.round(n / 2);
    if (k <= center) console.log(k * 2 - 1);
    else console.log(2 * (k - center));
});


process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', (inputStd) => {
    inputString += inputStd;
});
process.stdin.on('end', function () {
    inputString = inputString
        .trim()
        .split('\n')
        .map((str) => {
            return str.trim();
        });
    main();
});
function readLine() {
    return inputString[currentLine++];
}
function main() {
    let nums = readLine().split(' ').map(Number);
    let [n, m] = nums; // [2, 5]
    for (let i = n + 1; i <= m; i++) {
        // console.log(i);
        if (isPrime(i) && i !== m) {
            console.log('NO');
            return;
        }
        if (isPrime(i)) {
            if (i === m) {
                // console.log(isPrime(i));
                console.log('YES');
                return;
            }
        }
    }
    console.log('NO');
}

function isPrime(number) {
    if (number <= 1) {
        return false;
    }
    for (let i = 2; i < number; i++) {
        if (number % i === 0) {
            return false;
        }
    }
    return true;
}


var inputs = null;
//let inputs = ['8'];
function main(inputs) {
    var weight = parseInt(inputs[0]);
    if (weight == 2)
        return console.log('NO');
    for (var i = 2; i < 50; i += 2) {
        if (weight % 2 == 0)
            return console.log('YES');
    }
    console.log('NO');
}
// Do not change this
if (!inputs) {
    var input_1 = '';
    process.stdin.on('data', function (char) { return input_1 += char; });
    process.stdin.on('end', function () {
        var EOL = require('os').EOL;
        var inputs = input_1.split(EOL).slice(0, -1);
        main(inputs);
    });
}
else
    main(inputs);


const readline = require('readline');

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

rl.on('line', (line) => {
  const denominations = [100, 20, 10, 5, 1];
  let sum = 0;
  num = Number(line);
  denominations.forEach(bill => {
    while(num >= bill) {
      sum += 1;
      num -= bill;
    }
  });
  console.log(sum);
  rl.close();
});


const readline = require('readline');
//const lineReader = require('fs');
//const scanner = lineReader.createReadStream('main.in');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
const N = 102;
let n, m, lp = 0;

rl.on('line', (input) => {
    if (lp === 0){
        lp = 1;
        let t = input.split(' ').map((x) => { return parseInt(x); });
        n = t[0];
        m = t[1];
    } else if (lp === 1) {
        let a = input.split(' ').map((x) => { return parseInt(x); });
        let fd = new Array(N);
        let an = new Array(N);
        fd.fill(0);
        for (let i = 0; i < m; i++){
            for (let j = a[i]; j <= n; j++){
                if (fd[j] === 0){
                    an[j] = a[i];
                    fd[j] = 1;
                }
            }
        }
        for (let i = 1; i <= n; i++)console.log(an[i]);
        rl.close();
    }
});


function ProblemSolver() {
    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;
    this.CLEAR_ARRAY_PER_CASE = false;

	this.calc = function() {
		var i , fl , idx , j , crr , cnt , k ;
		while( true ) {
			fl = 0 ;
			for( i = 0 ; i < this.cn ; i++ ) {
				cnt = 1 ;
				for( j = i + 1 ; j < this.cn ; j++ ) {
					if( this.brr[ i ] != this.brr[ j ] ) {
						break ;
					}
					cnt++ ;
					k = j ;
				}
				if( cnt >= 3 ) {
					idx = 0 ;
					crr = new Array() ;
					for( j = 0 ; j < i ; j++ ) {
						crr.push( this.brr[ j ] ) ;
						idx++ ;
					}
					for( j = k + 1 ; j < this.cn ; j++ ) {
						crr.push( this.brr[ j ] ) ;
						idx++ ;
					}
					this.brr = crr ;
					this.cn = idx ;
					fl = 1 ;
					break ;
				}
			}
			if( fl == 0 ) {
				break ;
			}
		}
		return this.n - this.cn ;
	} ;

    this.solveCase = function() {
        var res , i , j , fl , cn , temp ;
        res = 0 ;
        //at the start
        this.cn = 0 ;
        this.brr[ this.cn++ ] = this.x ;
        for( i = 0 ; i < this.n ; i++ ) {
        	this.brr[ this.cn++ ] = this.arr[ i ] ;
        }
        res = Math.max( res , this.calc() ) ;
        //at the end
        this.cn = 0 ;
        for( i = 0 ; i < this.n ; i++ ) {
        	this.brr[ this.cn++ ] = this.arr[ i ] ;
        }
        this.brr[ this.cn++ ] = this.x ;
        res = Math.max( res , this.calc() ) ;
        //anywhere in the middle
        for( j = 0 ; j < this.n - 1 ; j++ ) {
        	this.cn = 0 ;
	        for( i = 0 ; i <= j ; i++ ) {
	        	this.brr[ this.cn++ ] = this.arr[ i ] ;
	        }
	        this.brr[ this.cn++ ] = this.x ;
	        for( i = j + 1 ; i < this.n ; i++ ) {
	        	this.brr[ this.cn++ ] = this.arr[ i ] ;
	        }
        	res = Math.max( res , this.calc() ) ;
        	//print( j , res , this.cn ) ;
	    }
        print( res );
    };

    this.init = function() {
        this.lim1 = 100010;
        this.lim2 = 110;
        this.cc = 1;
        this.ind = 1;
        this.n = 0;
        this.cn = 0;
        this.declareAndFillArrays();
    };

    this.getInput = function( irObj ) {
        var hasMoreInput , i;
        hasMoreInput = true;
        try {
            this.n = irObj.nextInt();
            this.k = irObj.nextInt();
            this.x = irObj.nextInt();
            for( i = 0 ; i < this.n ; i++ ) {
                this.arr[ i ] = irObj.nextInt();
            }
        }
        catch( ex ) {
            hasMoreInput = false;
        }
        return hasMoreInput;
    };

    this.clearArraysPerCase = function() {
        var i;
        this.arr = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.arr.push( 0 );
            this.adj_list.push( new Array() );
        }
    };

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        if( this.CLEAR_ARRAY_PER_CASE == true ) {
            this.clearArraysPerCase() ;
        }
    };

    this.declareAndFillArrays = function() {
        var i , j;
        this.srr = new Array();
        this.vis = new Array();
        this.arr = new Array();
        this.brr = new Array();
        this.memo = new Array();
        this.done = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.srr.push( "" );
            this.vis.push( 0 );
            this.arr.push( 0 );
            this.brr.push( 0 );
            this.adj_list.push( new Array() );
        }
        for( i = 0 ; i < this.lim2 ; i++ ) {
            this.memo.push( new Array() );
            this.done.push( new Array() );
            for( j = 0 ; j < this.lim2 ; j++ ) {
                this.memo[ i ].push( -1 );
                this.done[ i ].push( 0 );
            }
        }
    };

    this.init();
}

function InputReader() {
    var self = this ;
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;
    this.callBackFunction = null ;
    this.parentContext = null ;

    this.readAllLines = function() {
        var singleLine;
        while( true ) {
            try {
                singleLine = readline();
                if( singleLine == null ) {
                    break;
                }
            }
            catch( ex ) {
                break;
            }
            this.allLines.push( singleLine );
        }
    };

    this.readAllLinesFromRhino = function() {
        var brObj , line ;
        importPackage( java.io ) ;
        importPackage( java.lang ) ;
        brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;
        this.allLines = [] ;
        while( true ) {
            line = brObj.readLine() ;
            if( line == null ) {
                break;
            }
            this.allLines.push( line ) ;
        }
    };

    this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {
        self.chunkData += chunk ;
    };

    this.readEndFromNodeJsJudgeServer = function() {
        self.parseRawData( self.chunkData ) ;
        self.parentContext.runCases() ;
    };

    this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {
        this.parentContext = parentContext ;
        process.stdin.resume() ;
        process.stdin.setEncoding( 'utf8' ) ;
        this.chunkData = '' ;
        process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;
        process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;
    };

    this.parseRawData = function( data ) {
        var len , i , currentString;
        len = data.length;
        currentString = "";
        this.allLines = [] ;
        for( i = 0 ; i < len ; i++ ) {
            if( data[ i ] == '\r' ) {
            }
            else if( data[ i ] == '\n' ) {
                this.allLines.push( currentString );
                currentString = "";
            }
            else {
                currentString += data[ i ];
            }
        }
        if( currentString != "" ) {
            this.allLines.push( currentString );
        }
    };

    this.readAllLinesFromFile = function( inputFileName ) {
        var currentDirectory , fsObj , inputFilePath , rawData;
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        inputFilePath = currentDirectory + "\\" + inputFileName;
        rawData = fsObj.readFileSync( inputFilePath , "utf8" );
        this.parseRawData( rawData );
    };

    this.next = function( flag ) {
        var len , i , startIdx , res , endIdx;
        if( flag == 0 ) {
            if( this.currrentCharacterIndex != 0 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            res = "";
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;
            }
            this.currrentLineNumber++;
            this.currrentCharacterIndex = 0;
            return res;
        }
        while( true ) {
            if( this.currrentLineNumber >= this.allLines.length ) {
                throw new Error( "No more tokens available!" );
            }
            startIdx = -1;
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {
                    startIdx = i;
                    break;
                }
            }
            if( startIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
                continue;
            }
            res = "";
            endIdx = len - 1 ;
            for( i = startIdx ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {
                    endIdx = i;
                    break;
                }
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {
                    res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;
                }
                else {
                    res += '' + this.allLines[ this.currrentLineNumber ].charAt( i );
                }
            }
            this.currrentCharacterIndex = endIdx;
            if( endIdx == len - 1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            return res;
        }
    };

    this.nextInt = function() {
        return parseInt( this.next( 1 ) );
    };

    this.nextDouble = function() {
        return parseFloat( this.next( 1 ) );
    };

    this.nextString = function() {
        return this.next( 1 );
    };

    this.nextLine = function() {
        return this.next( 0 );
    };
}

function FileOutputHandler() {
    this.resultantStringArray = new Array();

    this.addNewLine = function( newString ) {
        this.resultantStringArray.push( newString );
    };

    this.clearPercase = function() {
        this.resultantStringArray = new Array();
    };

    this.flushOutOutputToFile = function( outputFileName ) {
        var i , sz , res , currentDirectory , fsObj , outputFilePath;
        res = "";
        sz = this.resultantStringArray.length;
        for( i = 0 ; i < sz ; i++ ) {
            if( i != 0 ) {
                res += "\n";
            }
            res += this.resultantStringArray[ i ];
        }
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        outputFilePath = currentDirectory + "\\" + outputFileName;
        fsObj.writeFileSync( outputFilePath , res );
        this.clearPercase();
    };
}

function CodeExecutioner() {
    this.irObj = new InputReader();
    this.psObj = new ProblemSolver();
    this.fohObj = new FileOutputHandler();

    this.runCases = function() {
        if( this.psObj.HAS_TEST_CASES == true ) {
            testCases = this.irObj.nextInt();
            for( i = 0 ; i < testCases ; i++ ) {
                this.psObj.clearPerCase();
                this.psObj.getInput( this.irObj );
                this.psObj.solveCase();
            }
        }
        else {
            while( true ) {
                this.psObj.clearPerCase();
                hasMoreTestCases = this.psObj.getInput( this.irObj );
                if( hasMoreTestCases == false ) {
                    break;
                }
                this.psObj.solveCase();
            }
        }
        if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.detectEnvironmentType = function() {
        var environmentType = null ;
        try {
            if( importPackage != null ) {
                environmentType = 'rhino' ;
            }
        }
        catch( ex1 ) {
            try {
                //for nodejs local server check
                if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {
                    environmentType = 'local-node-js' ;
                }
            }
            catch( ex2 ) {
                try {
                    if( readline == null || typeof( readline ) != 'function' ) {
                        environmentType = 'server-node-js' ;
                    }
                    else {
                        try {
                            if( Map != null ) {
                                environmentType = 'spider-monkey' ;
                            }
                            else {
                                environmentType = 'javascript-v8' ;
                            }
                        }
                        catch( ex3 ) {
                            environmentType = 'javascript-v8' ;
                        }
                    }
                }
                catch( ex3 ) {
                    environmentType = 'server-node-js' ;
                }
            }
        }
        return environmentType ;
    };

    this.configureStreamsAndReadInput = function() {
        var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , environmentType ;
        isNodeJsJudgeServer = false ;
        environmentType = this.detectEnvironmentType() ;
        if( environmentType == 'local-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
                localContext = this.fohObj;
                print = function() {
                    localContext.addNewLine.apply( localContext , arguments );
                }
            }
            this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );
            this.runCases() ;
        }
        else if( environmentType == 'server-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;
        }
        else if( environmentType == 'javascript-v8' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
        else if( environmentType == 'rhino' ) {
            this.irObj.readAllLinesFromRhino();
            this.runCases() ;
        }
        else if( environmentType == 'spider-monkey' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
    };

    this.configureStreamsAndReadInput();
}

new CodeExecutioner();


const readline = require('readline');

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

rl.question('', (input) => {
  let weight = (input);

  if (weight % 2 == 0 && weight > 2) {
    console.log("YES");
  } else {
    console.log("NO");
  }

  rl.close();
});


const input = [];

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

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

function solver(n, m) {
  let first = 0, second = 0, copyN = n;
  let point = (m % 2 === 0) ? m : m + 1;

  while (copyN !== point/2) {
    if (copyN > point/2) {
      first += copyN - (point/2);
      copyN = point/2;
    }
    if (copyN < point/2) { copyN *= 2;  first += 1; }
  }
  first += (m % 2 === 0) ? 1 : 2;

  copyN = n;
  while (copyN !== m) {
    if (copyN < m) copyN *= 2;
    else {
      second += copyN - m;
      break;
    }
    second += 1;
  }

  return Math.min(first, second);
}

RL.on('close', () => {
  let [n, m] = input[0].split(' ').map(x => parseInt(x));
  if (n > m) {
    console.log(n - m); return;
  }
  let data = {};
  data[n] = n;

  let find = 0;
  while (true) {
    const map = {};
    for (const i of Object.keys(data)) {
      let x = parseInt(i);
      if (x - 1 >=  1 ) {
        map[x - 1] = x-1;
        if (x - 1 === m) {
          console.log(find+1); return;
        }
      }
      if (x*2 <= m*1.5) {
        map[x * 2] =x*2;
        if (x*2 === m) {
          console.log(find+1); return;
        }
      }
    }
    data = map;

    find += 1;
  }
});


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

function _main() {

	_inputLines = _inputData.trim().split('\n').map((string) => {
		return string.trim();
	});;

	const [n, t] = inputReader.readNumberArray();

	const line = inputReader.readLine().split('');
	let count = 0;
	let i = 0;

	while (1) {
		if (i >= line.length && count < t) {
			i = 0;
			count++;
		}
		if (count === t) {
			break;
		}
		if (line[i] == "B" && line[i + 1] == "G") {
			let temp = line[i];
			line[i] = line[i + 1];
			line[i + 1] = temp;
			i += 2;
		} else {
			i++;
		}

	}
	console.log(line.join(""));

}

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 readLine(){
		return _inputLines[_lineNumber++];
	}

	function readNumberArray(){
		return _inputLines[_lineNumber++].split(' ').map(val => Number(val));
	}

	return {
		readLine,
		readNumberArray,
	}
}


// 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 berdLang = inputs[0].trim();
    let birdLang = inputs[1].trim();

    let strFlag = 'NO';
    if (berdLang === birdLang.split('').reverse().join('')) {
        strFlag = 'YES';
    }

    return strFlag.toString();
}


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", () => {
  const array = splitAndParseInt(input[0])
  const items = splitAndParseInt(input[1])
  const length = array[0];
  const max = array[1];
  let answer = 0;
  for(let i = 0; i <= length; i++){
    if(items[i] >= items[max - 1] && items[i] > 0){
      answer++;
    }
  }
  console.log(answer)
});


const readline = require('readline');

let inputs = [];
const chars = [
    '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'
];

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

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

// Excute algorithm
rl.on('close', () => {
    let firstWord = inputs[0];
    let secondWord = inputs[1];

    recognize(firstWord, secondWord)

})

/*
 ****************************
 * Devide & Conquer functions
 ****************************
 */

// Return the charcter position
function charPosition(char) {
    let low = 0
    let high = chars.length - 1
    let mid = Math.floor((low + high) / 2)

    while (low <= high) {
        mid = Math.floor((low + high) / 2)
        if (chars.indexOf(char) > mid)
            low = mid + 1
        else if (chars.indexOf(char) < mid)
            high = mid - 1
        else
            return mid
    }

    return -1
}

// Recognize which one's order is greater than the other
function recognize(fWord, sWord) {

    for (let i = 0; i < fWord.length; i++) {
        const char1 = fWord[i].toLowerCase();
        const char2 = sWord[i].toLowerCase();

        if (charPosition(char1) > charPosition(char2))
            return console.log(1);
        else if (charPosition(char1) < charPosition(char2))
            return console.log(-1);
    }

    return console.log(0)
}


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

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var n = one[0];
  var m = one[1];
  for(var i = n + 1; i < m; i++){
    if(isPrime(i)){
      myout("NO");
      return;
    }
  }
  myout((isPrime(m) ? "YES" : "NO"));
}
function isPrime(val){
  if(val == null || val <= 1 || (val != 2 && val % 2 == 0)){
    return false;
  }else if(val == 2){
    return true;
  }
  var root = Math.floor(Math.sqrt(val));
  for(var i = 3; i <= root; i += 2){
    if(val % i == 0){
      return false;
    }
  }
  return true;
}


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

process.stdin.setEncoding('utf8');
rl.once('line', line => {
    const n = line.toString().split(' ').map(Number);

    if (n % 2 === 0 && n > 2) console.log('YES');
    else console.log('NO');
    process.exit();
});


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

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

  const obj = {};

  for (let i = 0; i < str.length - 1; i++) {
    let pair = str[i] + str[i + 1];

    if (obj[pair]) {
      obj[pair]++;
    }
    else {
      obj[pair] = 1;
    }
  }

  let ans;
  let max = 0;

  Object.keys(obj).forEach(x => {
    if (obj[x] > max) {
      max = obj[x];
      ans = x;
    }
  });

  console.log(ans);

  c++;
});


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

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

readLine.on('close', () => {
	const _input = parseInt(input[0], 10)
	let _res = 0
	let count = 1 // руководителей
	while (count <= Math.floor(_input / 2)) {
		const it1 = _input - count // сотрудников
		const it2 = it1 / count
		const it3 = Math.floor(it1 / count)
		if (it2 === it3) {
			_res++
		}
		count++
	}
	console.log(_res)
})


const stdin = process.openStdin();

process.stdin.on('data', function (chunk) {
  lines = chunk.toString().split('\n');
  lines.map((line, i) => processLine(line, i));
});

function processLine(text, i) {
  if (i === 0) {
    const scores = text.toString().trim().split(' ').map(a => parseInt(a, 10));
    const output = Math.trunc(scores[0] * scores[1] / 2);
    console.log(output);
  }
}


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

let standardInputString = '';
let currentLine = 0;

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

process.stdin.on('data', rawData=> {
    standardInputString += rawData;
})

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

function main() {
    let number = Array.from(readLine());
    const n = 1*number.join("");
    if(n % 4 === 0 || n%7 === 0 || n%47 === 0 || n%74 === 0 || n%44 === 0 || n%444 === 0 || n%447 === 0 || n%474 === 0 || n%477 === 0 || n%777 === 0 || n%774 === 0 || n%744 === 0) {
        console.log('YES');
        return;
    }

    let match = number.filter(n => {
        if(n === '4' || n === '7') {
            return true;
        } else {
            return false;
        }
    })

    if(number.length === match.length) {
        console.log('YES');
    } else {
        console.log("NO");
    }
}


var readline = require('readline');
var rl = readline.createInterface(process.stdin, process.stdout);
rl.question('', (arg)=>{
	let sum = 0;
	if(arg>10){
		let b = 0;
		let a = arg;
		while(a>10){
			b = b*10+9;
			a=a/10;
		}
		a = arg - b;
	while(a!=0|| b!=0){
			sum = sum + a%10 + b%10;
			a= Math.floor(a/10);
			b=Math.floor(b/10);
		}

		}else{
			sum = arg;
		}
	console.log(sum);
	rl.close();
});


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 str = readLine().toLowerCase();
  const vowels = { a: "", o: "", y: "", e: "", y: "", i: "", u: "u" };
  str = str
    .split("")
    .filter((s) => {
      return vowels[s] == undefined;
    })
    .join(".");
  console.log("." + str);
}


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

rl.on('line', (d) => {
  let [x, y] = d.split(' ').map(Number);
  let n1 = Math.min(x, y);
  let n2 = Math.floor((Math.max(x, y) - n1) / 2);

  console.log(`${n1} ${n2}`);
});


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, t] = readLine()
		.split(' ')
		.map(x => x >> 0);

	let queue = readLine().split('');

	while (t--) {
		let i = 0;
		while (i < queue.length) {
			if (queue[i] === 'B' && queue[i + 1] === 'G') {
				queue[i] = 'G';
				queue[i + 1] = 'B';
				i += 2;
			} else {
				i++;
			}
		}
	}
	console.log(queue.join(''));
}


let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    for(i = 1; i <= t; i++){
        var n = lines[i];
        var a = new Map();
        for(j = 1; j * j <= n; j++){
            a.set(j * j, 1);
        }
        for(j = 1; j * j * j <= n; j++){
            a.set(j * j * j, 1);
        }
        console.log(a.size);
    }
});


'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    const input = readline();
    const str = readline();
    let count  =0;
    for (let i =0;i<str.length;i++){
        if(str[i] === str[i+1])
            count++
    }

    console.log(count);

    return;
}


function main() {
    // write code here:
    var arr = stdin[1].split(' '),
        reg1 = new RegExp(stdin[0][0], 'gi'),
        reg2 = new RegExp(stdin[0][1], 'gi'),
        s;
    s=arr.some(a => reg1.test(a) || reg2.test(a)) ? 'YES' : 'NO';
    console.log(s);
}

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);


const readline = require('readline');
//const lineReader = require('fs');
//const scanner = lineReader.createReadStream('main.in');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.on('line', (input) => {
    let n = parseInt(input);
    for (let i = 1; i * i <= n; i++){
        let eq = ((n - 1) - i - (i * i)) / (2 * i);
        if (eq === parseInt(eq) && eq > 0){
            console.log(i + " " + eq);
            process.exit(0);
        }
    }
    console.log("NO");
    rl.close();
});


let fs = require("fs");

let txt = fs.readFileSync(0, "utf-8").split("\r\n").filter(data => {
    return data.length > 0
})
for (let index = 0; index < txt.length; index++) {
    doit(txt[index].split("").filter(data => {
        return data.length > 0
    }).map(data => {
        return data * 1
    }))
}

function doit(tab) {
    let t = tab.filter(data => {
        return data != 7 && data != 4;
    }).length;
        t = tab.length - t
        if (t == 4 || t == 7) {
            console.log("YES");
        } else {
            console.log("NO");
        }
}


var root = function(dsu, v) {
    if (dsu[v] === v) {
        return v;
    } else {
        dsu[v] = root(dsu, dsu[v]);
        return dsu[v];
    }
}

var main = function () {
    var n = parseInt(readline());
    var p = [], prev = [], next = [];
    readline().split(/\s+/).forEach(function (t, i) {
        p.push(parseFloat(t));
    });

    for (var i = -1; i <= n; ++i) {
        prev[i] = next[i] = i;
    }

    var s = [];
    p.forEach(function(e, i) {
        s.push({pos: i, val: e});
    });

    s.sort(function(a, b) {
        return (a.val !== b.val) ? (a.val - b.val) : (a.pos - b.pos);
    });

    var ans = 0;
    var dec = 0;
    var left = n - 2;
    s.forEach(function (e, i) {
        if (left <= 0) {
            return;
        }

        var i = e.pos;
        next[i] = i + 1;
        prev[i] = i - 1;
        var lf = root(prev, i);
        var rg = root(next, i);

        var cur = e.val - dec;
        dec = e.val;
        ans += left * cur;
        left--;

        if (0 <= lf && lf <= rg && rg < n) {
            ans += Math.min(p[lf] - dec, p[rg] - dec);
        }

        return left > 0;
    });

    print(ans);
};

main();


process.stdin.on('data', input => {
  const arr = input.toString().split(' ');
  const m = arr[0];
  const n = arr[1];
  const a = arr[2];

  console.log(Math.ceil(m/a) * Math.ceil(n/a));
});


const readline = require('readline');

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

rl.question('', (answer) => {
  const [n, m, a] = answer.split(' ').map(v => parseInt(v));
  console.log(Math.ceil(n / a) * Math.ceil(m / a));

  rl.close();
});


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

rl.on('line', (data) => {
  let [a, b, c, d] = data.split(' ').map(Number);
  let p1Points = Math.max(3*a/10, a - (a / 250) * c);
  let p2Points = Math.max(3*b/10, b - (b / 250) * d);

  if (p1Points === p2Points) {
    console.log('Tie');
  }
  else if (p1Points > p2Points) {
    console.log('Misha');
  }
  else {
    console.log('Vasya');
  }

  count++;
});


let fs = require('fs');

let txt = fs.readFileSync(0, "utf-8").split("\r\n").filter(data => {
    return data.length > 0;
});

for (let i = 0; i < txt.length; i++) {
    doit(txt[i]);
}

function doit(str) {
    while (true) {
       let r= str.match("WUB");
       if(r===null){
           break;
       }else{
           let t=str.split("");
           t.splice(r.index,2);
           t[r.index]=" ";
           str=t.join("");

        }
    }
    console.log(str.split(" ").filter(data=>{return data.length>0}).join(" "));
}


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

let inputString = ''
let inputArray = null
let currentLine = 0

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

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

  main()
})

function readline() {
  return inputArray[currentLine++]
}

function main() {
  const s = readline()
  for (let i = 2; i < s.length; i++) {
    if (
      (s.charCodeAt(i - 2) -
        'A'.charCodeAt() +
        s.charCodeAt(i - 1) -
        'A'.charCodeAt()) %
        26 !==
      s.charCodeAt(i) - 'A'.charCodeAt()
    ) {
      console.log('NO')
      return
    }
  }
  console.log('YES')
}