There is a robot on a coordinate plane. Initially, the robot is located at the point $$$(0, 0)$$$. Its path is described as a string $$$s$$$ of length $$$n$$$ consisting of characters 'L', 'R', 'U', 'D'.Each of these characters corresponds to some move:   'L' (left): means that the robot moves from the point $$$(x, y)$$$ to the point $$$(x - 1, y)$$$;  'R' (right): means that the robot moves from the point $$$(x, y)$$$ to the point $$$(x + 1, y)$$$;  'U' (up): means that the robot moves from the point $$$(x, y)$$$ to the point $$$(x, y + 1)$$$;  'D' (down): means that the robot moves from the point $$$(x, y)$$$ to the point $$$(x, y - 1)$$$. The company that created this robot asked you to optimize the path of the robot somehow. To do this, you can remove any non-empty substring of the path. But this company doesn't want their customers to notice the change in the robot behavior. It means that if before the optimization the robot ended its path at the point $$$(x_e, y_e)$$$, then after optimization (i.e. removing some single substring from $$$s$$$) the robot also ends its path at the point $$$(x_e, y_e)$$$.This optimization is a low-budget project so you need to remove the shortest possible non-empty substring to optimize the robot's path such that the endpoint of his path doesn't change. It is possible that you can't optimize the path. Also, it is possible that after the optimization the target path is an empty string (i.e. deleted substring is the whole string $$$s$$$).Recall that the substring of $$$s$$$ is such string that can be obtained from $$$s$$$ by removing some amount of characters (possibly, zero) from the prefix and some amount of characters (possibly, zero) from the suffix. For example, the substrings of "LURLLR" are "LU", "LR", "LURLLR", "URL", but not "RR" and "UL".You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. Each test case is given on two lines. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of the robot's path. The second line of the test case contains one string $$$s$$$ consisting of $$$n$$$ characters 'L', 'R', 'U', 'D' — the robot's path. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$ ($$$\sum n \le 2 \cdot 10^5$$$).

For each test case, print the answer on it. If you cannot remove such non-empty substring that the endpoint of the robot's path doesn't change, print -1. Otherwise, print two integers $$$l$$$ and $$$r$$$ such that $$$1 \le l \le r \le n$$$ — endpoints of the substring you remove. The value $$$r-l+1$$$ should be minimum possible. If there are several answers, print any of them.

// const SegmentTree = require('javascript-algo-ds/src/data-structure/trees/segmentTree/segmentTree')
process.stdin.resume()
process.stdin.setEncoding('utf-8')

let input = ''
let ptr = 0
process.stdin.on('data', (i) => {
  input += i
})

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

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

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

function readInt() {
  return parseInt(input[ptr++])
}

function readString() {
  return input[ptr++]
}

function readStrings() {
  return input[ptr++].split(' ')
}

function readInts() {
  return input[ptr++].split(' ').map(a => parseInt(a))
}

function main() {
  let t = readInt()
  while(t--) {
    const n = readInt()
    const s = readString()
    let x = 0, y = 0
    let map = {}
    map[tS(0, 0)] = -1
    let max = [Infinity, -1, -1]
    for(let i = 0; i < n; i++) {
      switch (s[i]) {
        case 'L' : x--; break
        case 'R' : x++; break
        case 'D' : y--; break
        case 'U' : y++; break
      }
      let str = tS(x, y)
      if(map[str] !== undefined) {
        // wr(map, str, i)
        if(i - map[str] < max[0]) {
          max[0] = i - map[str]
          max[1] = map[str]
          max[2] = i
        }
        map[str] = i
      }
      else {
        map[str] = i
      }
    }
    if(max[0] === Infinity) wr(-1)
    else {
      wr(tS(max[1] + 2, max[2] + 1))
    }
  }

  function tS(x, y) {
    return `${x} ${y}`
  }
}

const processData = (lines) => {
  const num = +lines[0]

  for (let i = 0; i<num; i++) {
    const data = lines[i*2 + 2].split('')
    const points = {
      ['0_0']: [0]
    }
    let curPos = {
      x: 0,
      y: 0,
    }
    let index = 1
    for (const d of data) {
      switch(d) {
        case 'L':
          curPos.x = curPos.x - 1
          break;
        case 'R':
          curPos.x = curPos.x + 1
          break;
        case 'U':
          curPos.y = curPos.y + 1
          break;
        case 'D':
          curPos.y = curPos.y - 1
          break;
      }
      const hash = `${curPos.x}_${curPos.y}`

      if (!points[hash])
        points[hash] = [index]
      else
        points[hash].push(index)

      index++
    }

    let min = -1
    let choosingPoint = null
    for (const point in points) {
      if (points[point].length > 1) {
        for (let j=0; j<points[point].length+1; j++) {
          const len = points[point][j+1] - points[point][j]
          if (min === -1) {
            min = len
            choosingPoint= [points[point][j], points[point][j+1]]
          }
          if (len < min) {
            min = len
            choosingPoint= [points[point][j], points[point][j+1]]
          }
        }
      }
    }
    if (min === -1) {
      console.log('-1')
    } else {
      console.log(`${choosingPoint[0]+1} ${choosingPoint[1]}`)
    }
  }
}

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

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

let n = (m = remainingLines = remainingTestCount = lineNumber = lineCount = 0);

// Some utitls
const utils = {};
utils.doOnTestInputFinished = (line) => {
  line = line.split('');

  const DB = {};
  let position = [0, 0];
  let preparedPosition = utils.preparePosition(position);
  DB[preparedPosition] = [0];

  let answer = -1;
  let arrayLength;
  // Make it as much big as we can
  let minLength = Infinity;

  for (let letterIndex in line) {
    let letter = line[letterIndex];
    let preparedIndex = Number(letterIndex) + 1;

    position = utils.determineNextPosition(position, letter);
    preparedPosition = utils.preparePosition(position);

    if (preparedPosition in DB) {
      arrayLength = DB[preparedPosition].length;
      lastIndex = DB[preparedPosition][arrayLength - 1];

      if (preparedIndex - lastIndex < minLength) {
        minLength = preparedIndex - lastIndex;
        answer = `${lastIndex + 1} ${preparedIndex}`;
      }

      DB[preparedPosition].push(preparedIndex);
    } else {
      DB[preparedPosition] = [preparedIndex];
    }
  }

  console.log(answer);
  // console.log('DB', DB);
};
utils.preparePosition = (position) => {
  return `${position[0]} ${position[1]}`;
};
utils.determineNextPosition = (position, letter) => {
  switch (letter) {
    case 'U':
      return [position[0], position[1] + 1];
    case 'D':
      return [position[0], position[1] - 1];
    case 'R':
      return [position[0] + 1, position[1]];
    case 'L':
      return [position[0] - 1, position[1]];
  }
  return position;
};

rl.on('line', async (line) => {
  try {
    lineNumber++;
    if (lineNumber === 1) {
      // First Line
      remainingTestCount = Number(line);
      return;
    }
    if (!remainingLines) {
      // First line of each test case
      [n, m] = line.split(' ').map((d) => Number(d));
      remainingLines = 1;
      remainingTestCount--;
      return;
    }

    remainingLines--;
    if (remainingLines === 0) {
      // Do something on after inputs of each test case
      utils.doOnTestInputFinished(line);
    }
  } catch (e) {
    console.log(e.message);
    console.log(e.stack);
  }
});

'use strict'

let t = parseInt(readline())
while (t --> 0) {
  const n = parseInt(readline())
  const path = readline()
  let x = 0
  let y = 0
  let last = 0
  let found = false
  const visited = {
    [x + ',' + y]: 0
  }

  let ans = 1e9
  for (let i = 0; i < n; ++i) {
    if (path[i] === 'L') {
      x --
    } else if (path[i] === 'R') {
      x ++
    } else if (path[i] === 'U') {
      y ++
    } else {
      y --
    }
    const next = x + ',' + y

    if (Object.hasOwnProperty.call(visited, next)) {
      found = true
      const len = i - visited[next]
      if (len < ans) {
        ans = len
        last = i
      }
    }
    visited[next] = i+1
  }

  if (!found) print(-1)
  else {
    print(last - ans + 1, last + 1)
  }
}

'use strict'

const problem = (n, s) => {
    const v = { '0.0': [ -1 ] };
    let x = 0;
    let y = 0;
    for(let i = 0; i < n; i++) {
        if (s[i] === 'L') x--;
        else if (s[i] === 'R') x++;
        else if (s[i] === 'U') y++;
        else if (s[i] === 'D') y--;
        const j = `${x}.${y}`;
        if (v[j]) v[j].push(i);
        else v[j] = [i];
    }
    const values = Object.keys(v).map(i => v[i]).filter(i => i.length > 1);
    let min = Infinity;
    let value;
    for (let i = 0; i < values.length; i++) {
        for (let j = 1, d; j < values[i].length; j++) {
            d = values[i][j] - values[i][j-1];
            if (d < min) { min = d; value = [ values[i][j-1], values[i][j] ] }
        }
    }
    return value ? `${value[0]+2} ${value[1]+1}` : -1;
}

let t = +readline();
while(t--) print(problem(+readline(), readline()));

// const SegmentTree = require('javascript-algo-ds/src/data-structure/trees/segmentTree/segmentTree')
process.stdin.resume()
process.stdin.setEncoding('utf-8')

let input = ''
let ptr = 0
process.stdin.on('data', (i) => {
  input += i
})

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

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

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

function readInt() {
  return parseInt(input[ptr++])
}

function readString() {
  return input[ptr++]
}

function readStrings() {
  return input[ptr++].split(' ')
}

function readInts() {
  return input[ptr++].split(' ').map(a => parseInt(a))
}

function main() {
  let t = readInt()
  while(t--) {
    const n = readInt()
    const s = readString()
    let x = 0, y = 0
    let map = {}
    map[tS(0, 0)] = -1
    let max = [Infinity, -1, -1]
    for(let i = 0; i < n; i++) {
      switch (s[i]) {
        case 'L' : x--; break
        case 'R' : x++; break
        case 'D' : y--; break
        case 'U' : y++; break
      }
      let str = tS(x, y)
      if(map[str] !== undefined) {
        if(i - map[str] < max[0]) {
          max[0] = i - map[str]
          max[1] = map[str]
          max[2] = i
        }
      }
      else {
        map[str] = i
      }
    }
    if(max[0] === Infinity) wr(-1)
    else {
      wr(tS(max[1] + 2, max[2] + 1))
    }
  }

  function tS(x, y) {
    return `${x} ${y}`
  }
}


Anatoly lives in the university dorm as many other students do. As you know, cockroaches are also living there together with students. Cockroaches might be of two colors: black and red. There are n cockroaches living in Anatoly's room.Anatoly just made all his cockroaches to form a single line. As he is a perfectionist, he would like the colors of cockroaches in the line to alternate. He has a can of black paint and a can of red paint. In one turn he can either swap any two cockroaches, or take any single cockroach and change it's color.Help Anatoly find out the minimum number of turns he needs to make the colors of cockroaches in the line alternate.

The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of cockroaches. The second line contains a string of length n, consisting of characters 'b' and 'r' that denote black cockroach and red cockroach respectively.

Print one integer — the minimum number of moves Anatoly has to perform in order to make the colors of cockroaches in the line to alternate.

NoteIn the first sample, Anatoly has to swap third and fourth cockroaches. He needs 1 turn to do this.In the second sample, the optimum answer is to paint the second and the fourth cockroaches red. This requires 2 turns.In the third sample, the colors of cockroaches in the line are alternating already, thus the answer is 0.

var n = readline();
var a = readline();
var ro=0, re=0, bo=0, be=0;
for(var i= 0; i < a.length; i++) {
    if (i % 2 ===0) {
        if(a[i] === "r") {
            re++;
        }else{
            be++;
        }

    }else {
        if(a[i] === "r") {
            ro++;
        }else{
            bo++;
        }
    }
}
var m1 =Math.max(ro,be);
var m2 = Math.max(re,bo);
print(Math.min(m1,m2));

var d =readline();
var a =readline();
var ro=0,re=0,be=0,bo=0;
for(var e=0;e<a.length;e++){
    if(e%2===0){
        if(a[e]==="r"){
            re++;
        } else {
            be++;
        }
    } else {
        if(a[e]==="r"){
            ro++;
        } else {
            bo++;
        }

    }
}
print(Math.min(Math.max(ro,be),Math.max(re,bo)));

var n = readline();
var a = readline();
var ro =0,re=0,bo=0,be=0;
for (var i=0;i<a.length;i++) {
    if (i % 2 === 0) {
        if (a[i] === "r") {
            re++;
        }
        else {
            be++;
        }
    } else {
        if (a[i] === "r") {
            ro++;
        }
        else {
            bo++;
        }
    }
}
var m1 = Math.max(ro,be);
var m2 = Math.max(re,bo);
print(Math.min(m1,m2));

var a = readline();
print (a);
print (a.length);
var ro =0,re=0,bo=0,be=0;
for (var i=0;i<a.length;i++) {
    if (i % 2 === 0) {
        if (a[i] === "r") {
            re++;
        }
        else {
            be++;
        }
    } else {
        if (a[i] === "r") {
            ro++;
        }
        else {
            bo++;
        }
    }
}
var m1 = Math.max(ro,be);
var m2 = Math.max(re,bo);
print(Math.min(m1,m2));


You have a square chessboard of size $$$n \times n$$$. Rows are numbered from top to bottom with numbers from $$$1$$$ to $$$n$$$, and columns — from left to right with numbers from $$$1$$$ to $$$n$$$. So, each cell is denoted with pair of integers $$$(x, y)$$$ ($$$1 \le x, y \le n$$$), where $$$x$$$ is a row number and $$$y$$$ is a column number.You have to perform $$$q$$$ queries of three types:  Put a new rook in cell $$$(x, y)$$$.  Remove a rook from cell $$$(x, y)$$$. It's guaranteed that the rook was put in this cell before.  Check if each cell of subrectangle $$$(x_1, y_1) - (x_2, y_2)$$$ of the board is attacked by at least one rook. Subrectangle is a set of cells $$$(x, y)$$$ such that for each cell two conditions are satisfied: $$$x_1 \le x \le x_2$$$ and $$$y_1 \le y \le y_2$$$.Recall that cell $$$(a, b)$$$ is attacked by a rook placed in cell $$$(c, d)$$$ if either $$$a = c$$$ or $$$b = d$$$. In particular, the cell containing a rook is attacked by this rook.

The first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 10^5$$$, $$$1 \le q \le 2 \cdot 10^5$$$) — the size of the chessboard and the number of queries, respectively. Each of the following $$$q$$$ lines contains description of a query. Description begins with integer $$$t$$$ ($$$t \in \{1, 2, 3\}$$$) which denotes type of a query:   If $$$t = 1$$$, two integers $$$x$$$ and $$$y$$$ follows ($$$1 \le x, y \le n$$$) — coordinated of the cell where the new rook should be put in. It's guaranteed that there is no rook in the cell $$$(x, y)$$$ at the moment of the given query.  If $$$t = 2$$$, two integers $$$x$$$ and $$$y$$$ follows ($$$1 \le x, y \le n$$$) — coordinates of the cell to remove a rook from. It's guaranteed that there is a rook in the cell $$$(x, y)$$$ at the moment of the given query.  If $$$t = 3$$$, four integers $$$x_1, y_1, x_2$$$ and $$$y_2$$$ follows ($$$1 \le x_1 \le x_2 \le n$$$, $$$1 \le y_1 \le y_2 \le n$$$) — subrectangle to check if each cell of it is attacked by at least one rook.  It's guaranteed that among $$$q$$$ queries there is at least one query of the third type.

Print the answer for each query of the third type in a separate line. Print "Yes" (without quotes) if each cell of the subrectangle is attacked by at least one rook. Otherwise print "No" (without quotes).

NoteConsider example. After the first two queries the board will look like the following picture (the letter $$$R$$$ denotes cells in which rooks are located, the subrectangle of the query of the third type is highlighted in green):  Chessboard after performing the third and the fourth queries:  Chessboard after performing the fifth and the sixth queries:  Chessboard after performing the seventh and the eighth queries:  Chessboard after performing the last two queries:

const readline = require('readline')

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

function inc(F, idx, val) {
    for (; idx < F.length; idx |= idx + 1) {
        F[idx] += val
    }
}
function sum(F, idx) {
    let s = 0
    for (; idx >= 0; idx = (idx & (idx + 1)) - 1) {
        s += F[idx]
    }
    return s
}

function solve(n, qs) {
    const ans = []
    const row = Array(n).fill(0)
    const col = Array(n).fill(0)
    const rf = Array(n + 5).fill(0) // a little larger in case
    const cf = Array(n + 5).fill(0) // a little larger in case
    qs.forEach(([t, x, y, x2, y2]) => {
        x--; y--; x2--; y2--
        if (t === 1) {
            // add
            if (!row[x]++) inc(rf, x, 1)
            if (!col[y]++) inc(cf, y, 1)
        } else if (t === 2) {
            // remove
            if (!--row[x]) inc(rf, x, -1)
            if (!--col[y]) inc(cf, y, -1)
        } else {
            // query
            const nr = x2 - x + 1
            const nc = y2 - y + 1
            const kr = sum(rf, x2) - (x ? sum(rf, x - 1) : 0)
            const kc = sum(cf, y2) - (y ? sum(cf, y - 1) : 0)
        // console.log(nr, nc, '-', kr, kc)
            const ok = nr === kr || nc === kc
            ans.push(ok ? 'Yes' : 'No')
        }
    })
    return ans.join('\n')
}

'use strict';

var readline = require('readline');

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

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function solve(n, m, ops) {
  const row = new Map(),
        column = new Map();
  const segTreeR = new SegTree(n + 10),
        segTreeC = new SegTree(n + 10);
  let res = [];
  for (let [t, a, b, c, d] of ops) {
    if (t === 1) {
      if (row.get(a)) {
        row.set(a, row.get(a) + 1);
      } else {
        row.set(a, 1);
        segTreeR.update(a, a, 1);
      }
      if (column.get(b)) {
        column.set(b, column.get(b) + 1);
      } else {
        column.set(b, 1);
        segTreeC.update(b, b, 1);
      }
    } else if (t === 2) {
      row.set(a, row.get(a) - 1);
      column.set(b, column.get(b) - 1);
      if (!row.get(a)) {
        segTreeR.update(a, a, -1);
      }
      if (!column.get(b)) {
        segTreeC.update(b, b, -1);
      }
    } else {
      const x = segTreeR.query(a, c),
            y = segTreeC.query(b, d);
      if (x === c - a + 1 || y === d - b + 1) {
        res.push('YES');
      } else {
        res.push('NO');
      }
    }
  }
  console.log(res.join('\n'));
}
class SegTree {
  constructor(n) {
    this.n = n;
    this.root = this._newNode(0, n);
    this.update = this._update.bind(this, this.root);
    this.query = this._query.bind(this, this.root);
  }
  _newNode(l, r, val = 0, left = null, right = null) {
    return {
      val,
      l,
      r,
      left,
      right,
      add: 0
    };
  }
  _update(node, x, y, z) {
    if (!node) return;
    const {
      l,
      r
    } = node;
    if (l === r) {
      node.val = z;
      return;
    }
    const mid = Math.floor((l + r) / 2);
    if (!node.left) {
      node.left = this._newNode(l, mid);
      node.right = this._newNode(mid + 1, r);
    }
    if (y <= mid) this._update(node.left, x, y, z);else if (x > mid) this._update(node.right, x, y, z);else this._update(node.left, x, mid, z), this._update(node.right, mid + 1, y, z);
    node.val = node.left.val + node.right.val;
  }
  _query(node, x, y) {
    if (y < x) return 0;
    if (!node) return 0;
    const {
      l,
      r
    } = node;
    if (l === x && r === y) return node.val;
    let res = 0,
        mid = Math.floor((l + r) / 2);
    if (y <= mid) res = this._query(node.left, x, y);else if (x > mid) res = this._query(node.right, x, y);else res = this._query(node.left, x, mid) + this._query(node.right, mid + 1, y);
    return res;
  }
}

async function main(read) {
  const [n, m] = (await read()).split(' ').map(Number);
  const b = [];
  let tmp = m;
  while (tmp--) {
    b.push((await read()).split(' ').map(Number));
  }
  solve(n, m, b);
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
void async function () {
  const inputs = [];
  let i = 0;
  for await (const line of rl) {
    inputs.push(line.trim());
  }
  function read() {
    return inputs[i++];
  }
  await main(read);
}();

'use strict';
// HEADER:
const print = function(arg){
  let str = arg;
  if (arguments.length>1)
    str = Array.prototype.slice.call(arguments).join(' ');
  process.stdout.write(str+'\n');
};
let IS_MULTITEST, testN, tests;
const pcalc = (testN, toPrint)=>{
  let res = calc(testN);
  if (Array.isArray(res)){
    toPrint.push(res.join(' '));
  } else if (Number.isFinite(res) || typeof res=='string'){
    toPrint.push(res+'');
  }
  if (process.env.DEBUG && toPrint.length){
    let ans = toPrint.pop();
    print(ans);
    let expected = tests[testN-1];
    if (expected){
      if (expected==ans)
        console.log('\x1b[32m%s\x1b[0m', 'correct');
      else {
        console.log('\x1b[31m%s\x1b[0m', 'wrong, expected:', expected);
      }
    }
  }
};

const main = ()=>{
  let toPrint = [];
  L('\nSolving:');
  if (IS_MULTITEST){
    let T = +readline()
    for (testN=1; testN<=T; testN++)
      pcalc(T, toPrint);
  } else {
    pcalc(1, toPrint);
  }
  if (toPrint.length){
    print(toPrint.join('\n'));
  }
};

const lines = [];
const rl = require('readline').createInterface({
   input: process.stdin, output: process.stdout});
rl.on('line', line=>{
  lines.push(line);
});
rl.on('close', main);
let rli = 0;
const readline = ()=>lines[rli++];
const L = process.env.DEBUG ? console.log : ()=>{};
const LT = obj=>L(`\nTest #${testN}`, obj);

const ra = ()=>readline().split(' ').map(a=>+a)
const pa = arr=>print(arr.join(' '));

tests = [
];

// SOLUTION:
IS_MULTITEST = false;

class SegmentTree {
    constructor(arr){
        this.n = arr.length;
        this.l = null;
        this.r = null;
        this.sum = 0;
        this.toPush = null;
        this.build(arr);
    }
    getMiddle(){
        return Math.floor(this.n/2);
    }
    build(arr){
        if (arr.length==0)
            return;
        if (arr.length==1){
            this.sum = arr[0];
            return;
        }
        let m = this.getMiddle();
        let sum = 0;
        let leftArr = arr.slice(0, m);
        if (leftArr.length){
            this.l = new SegmentTree(leftArr);
            sum += this.l.sum;
        }
        let rightArr = arr.slice(m);
        if (rightArr.length){
            this.r = new SegmentTree(rightArr);
            sum += this.r.sum;
        }
        this.sum = sum;
    }
    push(){
      if (this.toPush==null)
        return;
      this.sum = this.n*this.toPush;
      if (this.r){
        this.r.toPush = this.toPush;
      }
      if (this.l){
        this.l.toPush = this.toPush;
      }
      this.toPush = null;
    }
    setAll(val){
      this.toPush = val;
    }
    set(i, val){
      this.push();
        if (this.n==1)
        {
            this.sum = val;
            return;
        }
        let m = this.getMiddle();
        if (i<m)
            this.l.set(i, val);
        else
            this.r.set(i-m, val);
        if (this.l)
          this.l.push();
        if (this.r)
          this.r.push();
        this.sum = (this.l ? this.l.sum : 0) +
            (this.r ? this.r.sum : 0);
    }
    sumRange(l, r){
        this.push();
        if (l==0 && r==this.n-1)
            return this.sum;
        let m = this.getMiddle();
        let sum = 0;
        if (l<m)
            sum += this.l.sumRange(l, Math.min(m-1, r));
        if (m<=r)
            sum += this.r.sumRange(Math.max(l-m, 0), r-m);
        return sum;
    }
}
const calc = (testN)=>{
  // READING:
  let [n, q] = ra();
  LT({n, q});
  // PROCESSING:
  let ans = [];
  let cnti = new Array(n).fill(0);
  let sti = new SegmentTree(cnti);
  let cntj = new Array(n).fill(0);
  let stj = new SegmentTree(cntj);

  while (q--){
    let [t, a1, a2, a3, a4] = ra();
    if (t==1){ // put a rook
      let x = a1-1, y = a2-1;
      cnti[x]++;
      if (cnti[x]==1)
        sti.set(x, 1);
      cntj[y]++;
      if (cntj[y]==1)
        stj.set(y, 1);
    } if (t==2){ // remove a rook
      let x = a1-1, y = a2-1;
      cnti[x]--;
      if (cnti[x]==0)
        sti.set(x, 0);
      cntj[y]--;
      if (cntj[y]==0)
        stj.set(y, 0);
    } if (t==3){ // query
      let x1 = a1-1, y1 = a2-1;
      let x2 = a3-1, y2 = a4-1;
      let si = sti.sumRange(Math.min(x1, x2), Math.max(x1, x2));
      if (si==Math.abs(x1-x2)+1){
        ans.push('Yes')
        continue;
      }
      let sj = stj.sumRange(Math.min(y1, y2), Math.max(y1, y2));
      if (sj==Math.abs(y1-y2)+1){
        ans.push('Yes')
        continue;
      }
        ans.push('No')
    }
  }
  return ans.join('\n');
};

//import { readline, print } from '@ip-algorithmics/codeforces-io';
var _a = readline().split(' ').map(function (v) { return +v; }), n = _a[0], q = _a[1];
var rr = Array(n + 1).fill(0);
var cc = Array(n + 1).fill(0);
var r = [];
var c = [];
var size = 200000;
while (size) {
    r.push(Array(size + 1).fill(0));
    c.push(Array(size + 1).fill(0));
    size = (size >> 1);
}
function add(a, i, v) {
    //print('add',i,v)
    for (var k = 0; k < a.length; k++) {
        if (~i & 1) {
            a[k][i >> 1] += v;
        }
        //print('addd', k, i, v);
        i >>= 1;
    }
}
function sum(a, i) {
    //print(`sum < ${i}:`);
    var res = 0;
    for (var k = 0; k < a.length; k++) {
        if (i & 1) {
            res += a[k][i >> 1];
            //print('summ', k, i, a[k][i-1]);
        }
        i >>= 1;
    }
    //print('sum', res);
    return res;
}
for (var i = 0; i < q; i++) {
    var b = readline().split(' ').map(function (v) { return +v; });
    //print('i',i);
    if (b[0] === 1) {
        var x = b[1];
        var y = b[2];
        rr[x]++;
        if (rr[x] === 1) {
            add(r, x, 1);
        }
        cc[y]++;
        if (cc[y] === 1) {
            add(c, y, 1);
        }
    }
    else if (b[0] === 2) {
        var x = b[1];
        var y = b[2];
        rr[x]--;
        if (rr[x] === 0) {
            add(r, x, -1);
        }
        cc[y]--;
        if (cc[y] === 0) {
            add(c, y, -1);
        }
    }
    else {
        if (sum(r, b[3] + 1) - sum(r, b[1]) === b[3] - b[1] + 1
            || sum(c, b[4] + 1) - sum(c, b[2]) === b[4] - b[2] + 1) {
            print('Yes');
        }
        else {
            print('No');
        }
    }
}

//import { readline, print } from '@ip-algorithmics/codeforces-io';
var _a = readline().split(' ').map(function (v) { return +v; }), n = _a[0], q = _a[1];
var rr = Array(n + 1).fill(0);
var cc = Array(n + 1).fill(0);
var r = [];
var c = [];
var size = 200000;
while (size) {
    r.push(Array(size + 1).fill(0));
    c.push(Array(size + 1).fill(0));
    size = (size >> 1);
}
function add(a, i, v) {
    //print('add',i,v)
    for (var k = 0; k < a.length; k++) {
        //if (i & 1) {
        a[k][i] += v;
        //}
        //print('addd', k, i, v);
        i >>= 1;
    }
}
function sum(a, i) {
    //print(`sum < ${i}:`);
    var res = 0;
    for (var k = 0; k < a.length; k++) {
        if (i & 1) {
            res += a[k][i - 1];
            //print('summ', k, i, a[k][i-1]);
        }
        i >>= 1;
    }
    //print('sum', res);
    return res;
}
for (var i = 0; i < q; i++) {
    var b = readline().split(' ').map(function (v) { return +v; });
    //print('i',i);
    if (b[0] === 1) {
        var x = b[1];
        var y = b[2];
        rr[x]++;
        if (rr[x] === 1) {
            add(r, x, 1);
        }
        cc[y]++;
        if (cc[y] === 1) {
            add(c, y, 1);
        }
    }
    else if (b[0] === 2) {
        var x = b[1];
        var y = b[2];
        rr[x]--;
        if (rr[x] === 0) {
            add(r, x, -1);
        }
        cc[y]--;
        if (cc[y] === 0) {
            add(c, y, -1);
        }
    }
    else {
        if (sum(r, b[3] + 1) - sum(r, b[1]) === b[3] - b[1] + 1
            || sum(c, b[4] + 1) - sum(c, b[2]) === b[4] - b[2] + 1) {
            print('Yes');
        }
        else {
            print('No');
        }
    }
}

const readline = require('readline')

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

function inc(F, idx, val) {
    for (; idx < F.length; idx |= idx + 1) {
        F[idx] += val
    }
}
function sum(F, idx) {
    let s = 0
    for (; idx >= 0; idx = (idx & (idx + 1)) - 1) {
        s += F[idx]
    }
    return s
}

function solve(n, qs) {
    const ans = []
    const row = Array(n).fill(0)
    const col = Array(n).fill(0)
    const rf = Array(n + 5).fill(0) // a little larger in case
    const cf = Array(n + 5).fill(0) // a little larger in case
    qs.forEach(([t, x, y, x2, y2]) => {
        x--; y--; x2--; y2--
        if (t === 1) {
            // add
            if (!row[x]++) inc(rf, x, 1)
            if (!col[y]++) inc(cf, y, 1)
        } else if (t === 2) {
            // remove
            if (!--row[x]) inc(rf, x, -1)
            if (!--col[x]) inc(cf, y, -1)
        } else {
            // query
            const nr = x2 - x + 1
            const nc = y2 - y + 1
            const kr = sum(rf, x2) - (x ? sum(rf, x - 1) : 0)
            const kc = sum(cf, y2) - (y ? sum(cf, y - 1) : 0)
        // console.log(nr, nc, '-', kr, kc)
            const ok = nr === kr || nc === kc
            ans.push(ok ? 'Yes' : 'No')
        }
    })
    return ans.join('\n')
}

//import { readline, print } from '@ip-algorithmics/codeforces-io';
var _a = readline().split(' ').map(function (v) { return +v; }), n = _a[0], q = _a[1];
var rr = Array(n + 1).fill(0);
var cc = Array(n + 1).fill(0);
var r = [];
var c = [];
var size = 200000;
while (size) {
    r.push(Array(size + 1).fill(0));
    c.push(Array(size + 1).fill(0));
    size = (size >> 1);
}
function add(a, i, v) {
    //print('add',i,v)
    for (var k = 0; k < a.length - 13; k++) {
        //if (i & 1) {
        a[k][i] += v;
        //}
        //print('addd', k, i, v);
        i >>= 1;
    }
}
function sum(a, i) {
    //print(`sum < ${i}:`);
    var res = 0;
    for (var k = 0; k < a.length - 13; k++) {
        if (i & 1) {
            res += a[k][i - 1];
            //print('summ', k, i, a[k][i-1]);
        }
        i >>= 1;
    }
    //print('sum', res);
    return res;
}
for (var i = 0; i < q; i++) {
    var b = readline().split(' ').map(function (v) { return +v; });
    //print('i',i);
    if (b[0] === 1) {
        var x = b[1];
        var y = b[2];
        rr[x]++;
        if (rr[x] === 1) {
            add(r, x, 1);
        }
        cc[y]++;
        if (cc[y] === 1) {
            add(c, y, 1);
        }
    }
    else if (b[0] === 2) {
        var x = b[1];
        var y = b[2];
        rr[x]--;
        if (rr[x] === 0) {
            add(r, x, -1);
        }
        cc[y]--;
        if (cc[y] === 0) {
            add(c, y, -1);
        }
    }
    else {
        if (sum(r, b[3] + 1) - sum(r, b[1]) === b[3] - b[1] + 1
            || sum(c, b[4] + 1) - sum(c, b[2]) === b[4] - b[2] + 1) {
            print('Yes');
        }
        else {
            print('No');
        }
    }
}

//import { readline, print } from '@ip-algorithmics/codeforces-io';
var _a = readline().split(' ').map(function (v) { return +v; }), n = _a[0], q = _a[1];
var rr = Array(n + 1).fill(0);
var cc = Array(n + 1).fill(0);
var r = [];
var c = [];
var size = 200000;
while (size) {
    r.push(Array(size + 1).fill(0));
    c.push(Array(size + 1).fill(0));
    size = (size >> 1);
}
function add(a, i, v) {
    //print('add',i,v)
    for (var k = 0; k < a.length; k++) {
        //if (i & 1) {
        a[k][i] += v;
        //}
        //print('addd', k, i>>1, v);
        i >>= 1;
    }
}
function sum(a, i) {
    //print(`sum <= ${i}:`);
    var res = 0;
    for (var k = 0; k < a.length; k++) {
        if (i & 1) {
            res += a[k][i];
            //print('summ', k, i>>1, a[k][i>>1]);
        }
        i >>= 1;
    }
    //print('sum', res);
    return res;
}
for (var i = 0; i < q; i++) {
    var b = readline().split(' ').map(function (v) { return +v; });
    //print('i',i);
    if (b[0] === 1) {
        var x = b[1];
        var y = b[2];
        rr[x]++;
        if (rr[x] === 1) {
            add(r, x, 1);
        }
        cc[y]++;
        if (cc[y] === 1) {
            add(c, y, 1);
        }
    }
    else if (b[0] === 2) {
        var x = b[1];
        var y = b[2];
        rr[x]--;
        if (rr[x] === 0) {
            add(r, x, -1);
        }
        cc[y]--;
        if (cc[y] === 0) {
            add(c, y, -1);
        }
    }
    else {
        if (sum(r, b[3] + 1) - sum(r, b[1]) === b[3] - b[1] + 1
            || sum(c, b[4] + 1) - sum(c, b[2]) === b[4] - b[2] + 1) {
            print('Yes');
        }
        else {
            print('No');
        }
    }
}

//import { readline, print } from '@ip-algorithmics/codeforces-io';
var _a = readline().split(' ').map(function (v) { return +v; }), n = _a[0], q = _a[1];
var rr = Array(n + 1).fill(0);
var cc = Array(n + 1).fill(0);
var r = [];
var c = [];
var size = 200000;
while (size) {
    r.push(Array(size + 1).fill(0));
    c.push(Array(size + 1).fill(0));
    size = (size >> 1);
}
function add(a, i, v) {
    //print('add',i,v)
    for (var k = 0; k < a.length; k++) {
        //if (i & 1) {
        a[k][i] += v;
        //}
        //print('addd', k, i>>1, v);
        i >>= 1;
    }
}
function sum(a, i) {
    //print(`sum <= ${i}:`);
    var res = 0;
    for (var k = 0; k < a.length; k++) {
        if (i & 1) {
            res += a[k][i];
            //print('summ', k, i>>1, a[k][i>>1]);
        }
        i >>= 1;
    }
    //print('sum', res);
    return res;
}
for (var i = 0; i < q; i++) {
    var b = readline().split(' ').map(function (v) { return +v; });
    //print('i',i);
    if (b[0] === 1) {
        var x = b[1];
        var y = b[2];
        rr[x]++;
        if (rr[x] === 1) {
            add(r, x, 1);
        }
        cc[y]++;
        if (cc[y] === 1) {
            add(c, y, 1);
        }
    }
    else if (b[0] === 2) {
        var x = b[1];
        var y = b[2];
        rr[x]--;
        if (rr[x] === 0) {
            add(r, x, -1);
        }
        cc[y]--;
        if (cc[y] === 0) {
            add(c, y, -1);
        }
    }
    else {
        if (sum(r, b[3]) - sum(r, b[1] - 1) === b[3] - b[1] + 1
            || sum(c, b[4]) - sum(c, b[2] - 1) === b[4] - b[2] + 1) {
            print('Yes');
        }
        else {
            print('No');
        }
    }
}

//import { readline, print } from '@ip-algorithmics/codeforces-io';
var _a = readline().split(' ').map(function (v) { return +v; }), n = _a[0], q = _a[1];
var rr = Array(n + 1).fill(0);
var cc = Array(n + 1).fill(0);
var r = [];
var c = [];
var size = 200000;
while (size) {
    r.push(Array(size + 1).fill(0));
    c.push(Array(size + 1).fill(0));
    size = (size >> 1);
}
function add(a, i, v) {
    //print('add',i,v)
    for (var k = 0; k < a.length; k++) {
        //if (i & 1) {
        a[k][i >> 1] += v;
        //}
        //print('addd', k, i>>1, v);
        i >>= 1;
    }
}
function sum(a, i) {
    //print(`sum <= ${i}:`);
    var res = 0;
    for (var k = 0; k < a.length; k++) {
        if (i & 1) {
            res += a[k][i >> 1];
            //print('summ', k, i>>1, a[k][i>>1]);
        }
        i >>= 1;
    }
    //print('sum', res);
    return res;
}
for (var i = 0; i < q; i++) {
    var b = readline().split(' ').map(function (v) { return +v; });
    //print('i',i);
    if (b[0] === 1) {
        var x = b[1];
        var y = b[2];
        rr[x]++;
        if (rr[x] === 1) {
            add(r, x, 1);
        }
        cc[y]++;
        if (cc[y] === 1) {
            add(c, y, 1);
        }
    }
    else if (b[0] === 2) {
        var x = b[1];
        var y = b[2];
        rr[x]--;
        if (rr[x] === 0) {
            add(r, x, -1);
        }
        cc[y]--;
        if (cc[y] === 0) {
            add(c, y, -1);
        }
    }
    else {
        if (sum(r, b[3]) - sum(r, b[1] - 1) === b[3] - b[1] + 1
            || sum(c, b[4]) - sum(c, b[2] - 1) === b[4] - b[2] + 1) {
            print('Yes');
        }
        else {
            print('No');
        }
    }
}

//import { readline, print } from '@ip-algorithmics/codeforces-io';
var _a = readline().split(' ').map(function (v) { return +v; }), n = _a[0], q = _a[1];
var rr = Array(n + 1).fill(0);
var cc = Array(n + 1).fill(0);
var r = [];
var c = [];
var size = 200000;
while (size) {
    r.push(Array(size + 1).fill(0));
    c.push(Array(size + 1).fill(0));
    size = (size >> 1);
}
function add(a, i, v) {
    //print('add',i,v)
    for (var k = 0; k < a.length - 13; k++) {
        //if (i & 1) {
        a[k][i >> 1] += v;
        //}
        //print('addd', k, i>>1, v);
        i >>= 1;
    }
}
function sum(a, i) {
    //print(`sum <= ${i}:`);
    var res = 0;
    for (var k = 0; k < a.length - 13; k++) {
        if (i & 1) {
            res += a[k][i >> 1];
            //print('summ', k, i>>1, a[k][i>>1]);
        }
        i >>= 1;
    }
    //print('sum', res);
    return res;
}
for (var i = 0; i < q; i++) {
    var b = readline().split(' ').map(function (v) { return +v; });
    //print('i',i);
    if (b[0] === 1) {
        var x = b[1];
        var y = b[2];
        rr[x]++;
        if (rr[x] === 1) {
            add(r, x, 1);
        }
        cc[y]++;
        if (cc[y] === 1) {
            add(c, y, 1);
        }
    }
    else if (b[0] === 2) {
        var x = b[1];
        var y = b[2];
        rr[x]--;
        if (rr[x] === 0) {
            add(r, x, -1);
        }
        cc[y]--;
        if (cc[y] === 0) {
            add(c, y, -1);
        }
    }
    else {
        if (sum(r, b[3]) - sum(r, b[1] - 1) === b[3] - b[1] + 1
            || sum(c, b[4]) - sum(c, b[2] - 1) === b[4] - b[2] + 1) {
            print('Yes');
        }
        else {
            print('No');
        }
    }
}


You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting number also mustn't contain any leading zeroes.

The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.

Print a number in the decimal notation without leading zeroes — the result of the permutation. If it is impossible to rearrange the digits of the number a in the required manner, print 0.

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

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

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

function permute(arr, i) {
	if (i == arr.length) {
		var num = 0;
		for (var j = 0; j < arr.length; j += 1) {
			num = 10*num + arr[j];
		}
		print(num + ' % 7 = ' + (num%7));
		return;
	}
	permute(arr, i+1);
	var t = arr[i];
	for (var j = i+1; j < arr.length; j += 1) {
		arr[i] = arr[j];
		arr[j] = t;
		permute(arr, i+1);
		arr[j] = arr[i];
	}
	arr[i] = t;
}

function main() {
	var reverseMod = [1869, 1968, 1689, 6198, 1698, 1986, 1896];
	var s = trim(readline());

	var seek1 = true, seek6 = true, seek8 = true, seek9 = true;
	var digits = [];
	var zeros = [];
	for (var i = 0; i < s.length; i += 1) {
		if (s[i] == '1') {
			if (seek1) {
				seek1 = false;
				continue;
			}
		}
		else if (s[i] == '6') {
			if (seek6) {
				seek6 = false;
				continue;
			}
		}
		else if (s[i] == '8') {
			if (seek8) {
				seek8 = false;
				continue;
			}
		}
		else if (s[i] == '9') {
			if (seek9) {
				seek9 = false;
				continue;
			}
		}
		else if (s[i] == '0') {
			zeros.push('0');
			continue;
		}
		digits.push(parseInt(s[i]));
	}

	write(digits.join(''));

	var remainder = 0;
	for (var i = 0; i < digits.length; i += 1) {
		remainder = (10*remainder + digits[i]) % 7;
	}

	remainder = (10000*remainder) % 7;

	write(reverseMod[(7-remainder)%7]);
	print(zeros.join(''));
}

main();

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

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

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

function permute(arr, i) {
	if (i == arr.length) {
		var num = 0;
		for (var j = 0; j < arr.length; j += 1) {
			num = 10*num + arr[j];
		}
		print(num + ' % 7 = ' + (num%7));
		return;
	}
	permute(arr, i+1);
	var t = arr[i];
	for (var j = i+1; j < arr.length; j += 1) {
		arr[i] = arr[j];
		arr[j] = t;
		permute(arr, i+1);
		arr[j] = arr[i];
	}
	arr[i] = t;
}

function main() {
	var mods = [1869, 1968, 1689, 6198, 1698, 1986, 1896];
	var s = trim(readline());

	var seek1 = true, seek6 = true, seek8 = true, seek9 = true;
	var remainder = 0;
	var zeros = [];
	for (var i = s.length-1; i >= 0; i -= 1) {
		if (s[i] == '1') {
			if (seek1) {
				s = s.slice(0, i) + s.slice(i+1);
				seek1 = false;
				continue;
			}
		}
		else if (s[i] == '6') {
			if (seek6) {
				s = s.slice(0, i) + s.slice(i+1);
				seek6 = false;
				continue;
			}
		}
		else if (s[i] == '8') {
			if (seek8) {
				s = s.slice(0, i) + s.slice(i+1);
				seek8 = false;
				continue;
			}
		}
		else if (s[i] == '9') {
			if (seek9) {
				s = s.slice(0, i) + s.slice(i+1);
				seek9 = false;
				continue;
			}
		}
		else if (s[i] == '0') {
			s = s.slice(0, i) + s.slice(i+1);
			zeros.push('0');
			remainder = (10*remainder) % 7;
			continue;
		}
		remainder = (10*remainder + s[i]) % 7;
	}

	write(s);
	write(mods[(7-remainder)%7]);
	print(zeros.join(''));
}

main();

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

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

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

function permute(arr, i) {
	if (i == arr.length) {
		var num = 0;
		for (var j = 0; j < arr.length; j += 1) {
			num = 10*num + arr[j];
		}
		print(num + ' % 7 = ' + (num%7));
		return;
	}
	permute(arr, i+1);
	var t = arr[i];
	for (var j = i+1; j < arr.length; j += 1) {
		arr[i] = arr[j];
		arr[j] = t;
		permute(arr, i+1);
		arr[j] = arr[i];
	}
	arr[i] = t;
}

function main() {
	var mods = [1869, 1968, 1689, 6198, 1698, 1986, 1896];
	var s = trim(readline());

	var seek1 = true, seek6 = true, seek8 = true, seek9 = true;
	var zeros = [];
	for (var i = s.length-1; i >= 0; i -= 1) {
		if (s[i] == '1') {
			if (seek1) {
				s = s.slice(0, i) + s.slice(i+1);
				seek1 = false;
				continue;
			}
		}
		else if (s[i] == '6') {
			if (seek6) {
				s = s.slice(0, i) + s.slice(i+1);
				seek6 = false;
				continue;
			}
		}
		else if (s[i] == '8') {
			if (seek8) {
				s = s.slice(0, i) + s.slice(i+1);
				seek8 = false;
				continue;
			}
		}
		else if (s[i] == '9') {
			if (seek9) {
				s = s.slice(0, i) + s.slice(i+1);
				seek9 = false;
				continue;
			}
		}
		else if (s[i] == '0') {
			s = s.slice(0, i) + s.slice(i+1);
			zeros.push('0');
			continue;
		}
	}

	write(s);

	var remainder = 0;
	for (var i = 0; i < s.length; i += 1) {
		remainder = (10*remainder + parseInt(s[i])) % 7;
	}

	write(mods[(7-remainder)%7]);
	print(zeros.join(''));
}

main();


Pinkie Pie has bought a bag of patty-cakes with different fillings! But it appeared that not all patty-cakes differ from one another with filling. In other words, the bag contains some patty-cakes with the same filling.Pinkie Pie eats the patty-cakes one-by-one. She likes having fun so she decided not to simply eat the patty-cakes but to try not to eat the patty-cakes with the same filling way too often. To achieve this she wants the minimum distance between the eaten with the same filling to be the largest possible. Herein Pinkie Pie called the distance between two patty-cakes the number of eaten patty-cakes strictly between them.Pinkie Pie can eat the patty-cakes in any order. She is impatient about eating all the patty-cakes up so she asks you to help her to count the greatest minimum distance between the eaten patty-cakes with the same filling amongst all possible orders of eating!Pinkie Pie is going to buy more bags of patty-cakes so she asks you to solve this problem for several bags!

The first line contains a single integer $$$T$$$ ($$$1 \le T \le 100$$$): the number of bags for which you need to solve the problem. The first line of each bag description contains a single integer $$$n$$$ ($$$2 \le n \le 10^5$$$): the number of patty-cakes in it. The second line of the bag description contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le n$$$): the information of patty-cakes' fillings: same fillings are defined as same integers, different fillings are defined as different integers. It is guaranteed that each bag contains at least two patty-cakes with the same filling.  It is guaranteed that the sum of $$$n$$$ over all bags does not exceed $$$10^5$$$.

For each bag print in separate line one single integer: the largest minimum distance between the eaten patty-cakes with the same filling amongst all possible orders of eating for that bag.

NoteFor the first bag Pinkie Pie can eat the patty-cakes in the following order (by fillings): $$$1$$$, $$$6$$$, $$$4$$$, $$$7$$$, $$$1$$$, $$$6$$$, $$$4$$$ (in this way, the minimum distance is equal to $$$3$$$).For the second bag Pinkie Pie can eat the patty-cakes in the following order (by fillings): $$$1$$$, $$$4$$$, $$$6$$$, $$$7$$$, $$$4$$$, $$$1$$$, $$$6$$$, $$$4$$$ (in this way, the minimum distance is equal to $$$2$$$).

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

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

// import './array'
//
// import io from './io'
//
// function main() {
//   let [n] = io.nextNumbers()
//   let a = io.nextNumbers()
//
//   let m = {}
//
//   for (let x of a) {
//     m[x] = m[x] + 1 || 1
//   }
//
//   let v = Object.values(m).sortDesc() as number[]
//
//   let s = v[0]
//
//   let i = 1
//
//   let f = s
//   let c = 0
//
//   while (v[i] == s) {
//     f += s
//     i++
//     c++
//   }
//
//   io.puts(c + Math.floor((n - f) / (s - 1)))
// }
//
// io.runEachTest(main)
// // io.runMain(main)

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

    probC();
});

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

function probC(){
    let t = parseInt(readline());
    while(t > 0){
        t--;
        let count = new Array(100001);
        let n = parseInt(readline());
        let arr = readline().split(' ');
        let max = 0;

        for(let i = 0; i < n; i++){
            let index = parseInt(arr[i]);
            if(count[index])
                count[index]++;
            else
                count[index] = 1;

            max = Math.max(max, count[index]);
        }

        let maxCount = 0;
        for(let i = 0; i < count.length; i++){
            if(count[i] === max)
                maxCount++;
        }

        console.log(Math.floor((n-maxCount) / (max-1)) - 1);
    }
}

function main(){
    let n = parseInt(readline());
    let a = readline().split(' ');
    let map = new Array(100000 + 1);
    map.fill(0);
    let count = {'4': 0, '2': 0};
    for(let i = 0; i < a.length; i++){
        let index = parseInt(a[i]);
        if(map[index]){
            map[index] += 1;
            if(map[index] % 4 === 0)
                count[4] += 1;

            if(map[index] % 2 === 0)
                count[2] += 1;
        }
        else
            map[index] = 1;
    }

    let o = parseInt(readline());
    for(let i = 0; i < o; i++){
        let x = readline().split(' ');
        if(x[0] === '+'){
            map[parseInt(x[1])] += 1;
            if(map[parseInt(x[1])] % 4 === 0)
                count[4]++;

            if(map[parseInt(x[1])] % 2 === 0)
                count[2]++;
        }else{
            let f1 = map[parseInt(x[1])] % 4 === 0;
            let f2 = map[parseInt(x[1])] % 2 === 0;
            map[parseInt(x[1])] -= 1;
            if(f1 && map[parseInt(x[1])] % 4 !== 0)
                count[4]--;

            if(f2 && map[parseInt(x[1])] % 2 !== 0)
                count[2]--;
        }

        if(count[4] >= 2){
            console.log('yes');
        }else if(count[4] >= 1 && count[2]-(2*count[4]) >= 2){
            console.log('yes');
        }else{
            console.log('no');
        }
    }
}

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

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

// import './array'
//
// import io from './io'
//
// function main() {
//   let [n] = io.nextNumbers()
//   let a = io.nextNumbers()
//
//   let m = {}
//
//   for (let x of a) {
//     m[x] = m[x] + 1 || 1
//   }
//
//   let v = Object.values(m).sortDesc() as number[]
//
//   let s = v[0]
//
//   let i = 1
//
//   let f = s
//   let c = 0
//
//   u
//
//   while (v[i] == s) {
//     f += s
//     i++
//     c++
//   }
//
//   // io.debug(f)
//
//   io.puts(Math.floor((n - f + c) / (s - 1)))
// }
//
// io.runEachTest(main)
// // io.runMain(main)


Given a positive integer $$$k$$$, two arrays are called $$$k$$$-similar if:  they are strictly increasing;  they have the same length;  all their elements are positive integers between $$$1$$$ and $$$k$$$ (inclusive);  they differ in exactly one position. You are given an integer $$$k$$$, a strictly increasing array $$$a$$$ and $$$q$$$ queries. For each query, you are given two integers $$$l_i \leq r_i$$$. Your task is to find how many arrays $$$b$$$ exist, such that $$$b$$$ is $$$k$$$-similar to array $$$[a_{l_i},a_{l_i+1}\ldots,a_{r_i}]$$$.

The first line contains three integers $$$n$$$, $$$q$$$ and $$$k$$$ ($$$1\leq n, q \leq 10^5$$$, $$$n\leq k \leq 10^9$$$) — the length of array $$$a$$$, the number of queries and number $$$k$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots,a_n$$$ ($$$1 \leq a_i \leq k$$$). This array is strictly increasing  — $$$a_1 < a_2 < \ldots < a_n$$$. Each of the following $$$q$$$ lines contains two integers $$$l_i$$$, $$$r_i$$$ ($$$1 \leq l_i \leq r_i \leq n$$$).

Print $$$q$$$ lines. The $$$i$$$-th of them should contain the answer to the $$$i$$$-th query.

NoteIn the first example:In the first query there are $$$4$$$ arrays that are $$$5$$$-similar to $$$[2,4]$$$: $$$[1,4],[3,4],[2,3],[2,5]$$$.In the second query there are $$$3$$$ arrays that are $$$5$$$-similar to $$$[4,5]$$$: $$$[1,5],[2,5],[3,5]$$$.

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main()
});

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

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

}

// function to solve problems
function solve (){
  let [n,q,k] = readline().split(' ').map(x => +x)
  // let q = arr[1], k = arr[2]
  let myArr = readline().split(' ').map(x => +x)//new Array(n)

  // readline().split(' ').map((x,i) => {
  //   myArr[i] = +x
  // })

  // ====== SOLUTION ======
  while(q--) {
    let [l,r] = readline().split(' ').map(x => +x)
    let arrLen = r - l + 1
    let ans = 0

    ans += myArr[l-1] - 1 // * true

    ans += 2*((myArr[r-1] - myArr[l-1] + 1) - arrLen)

    // checkbackward of last Element
    ans += k - myArr[r-1] // * true
    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++]
}
// Make a Snippet for the code above this and then write your logic in main();

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

}

// function to solve problems
function solve (){
  let [n,q,k] = readline().split(' ').map(x => +x)
  // let q = arr[1], k = arr[2]
  let myArr = new Array(n)

  readline().split(' ').map((x,i) => {
    myArr[i] = +x
  })

  // ====== SOLUTION ======
  while(q--) {
    let [l,r] = readline().split(' ').map(x => +x)
    let arrLen = r - l + 1
    let ans = 0

    ans += myArr[l-1] - 1 // * true

    ans += 2*((myArr[r-1] - myArr[l-1] + 1) - arrLen)

    // checkbackward of last Element
    ans += k - myArr[r-1] // * true
    console.log(ans)
  }
}

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}
function getValue() {
  return parseInt(readline());
}
let mod = BigInt(1e9 + 7);
const solve = () => {
  let t = 1;
  while (t--) {
    let [n, q, k] = iInpArr();
    let arr = iInpArr(),
      objA = [];
    for (let i = 0; i < n; i++) {
      let a = arr[i] - 1,
        d = k - arr[i],
        b,
        c;
      if (i === 0) b = 0;
      else b = arr[i] - arr[i - 1] - 1;
      if (i === n - 1) c = 0;
      else c = arr[i + 1] - arr[i] - 1;
      objA[i] = { a, b, c, d };
    }
    let frd = {},
      sum = 0;
    for (let i = 0; i < n; i++) {
      sum += objA[i].b + objA[i].c;
      frd[i] = sum;
    }
    for (let i = 0; i < q; i++) {
      let [s, e] = iInpArr();
      s--;
      e--;
      if (s === e) console.log(objA[s].a + objA[s].d);
      else if (s + 1 === e)
        console.log(objA[s].a + objA[e].d + objA[s].c + objA[e].b);
      else {
        let sum = 0;
        sum += frd[e - 1] - frd[s];
        sum += objA[s].a + objA[e].d + objA[s].c + objA[e].b;
        console.log(sum);
      }
    }
  }
};
solve();

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

function main () {
	let [n, q, k] = rna();
	let a = rna();

	for (let i = 0; i < q; i++) {
		let [l, r] = rna();
		l--;r--;

		ans = 2 * (a[r] - a[l] - r + l ) + a[l] - 1 + k - a[r];
		console.log(ans);
	}
}

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

function main () {
	let [n, q, k] = rna();
	let a = rna();

	let sum = [0];
	for (let i = 1; i < n; i++) {
		sum[i] = sum[i-1] + a[i] - a[i-1] - 1;
	}

	for (let i = 0; i < q; i++) {
		let [l, r] = rna();
		l--;r--;

		ans = 2 * (sum[r] - sum[l]) + a[l] - 1 + k - a[r];
		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++];
}

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

function main() {

    // 1 1 7
    // 6 9, 15, 18
    var [n, q, k] = readline().split(' ').map((x, i) => {
        // if (minA > Number(x)) minA = Number(x)
        return parseInt(x)
    })
    var a = new Array(n + 1)
    readline().split(' ').map((x, i) => {
        // if (minA > Number(x)) minA = Number(x)
        a[i + 1] = x
    })
    var answer = 0
    for (var i = 0; i < q; i++) {
        var [l, r] = readline().split(' ').map((x, i) => {
            // if (minA > Number(x)) minA = Number(x)
            return parseInt(x)
        })
        answer = (a[l] - 1 + k-a[r]) + 2 * (a[r] - a[l] + 1 - r + l - 1)
        console.log(answer)
    }
}

function swap(a, b) {
    var c = a
    a = b
    b = c
}


Phoenix is playing with a new puzzle, which consists of $$$n$$$ identical puzzle pieces. Each puzzle piece is a right isosceles triangle as shown below.    A puzzle piece The goal of the puzzle is to create a square using the $$$n$$$ pieces. He is allowed to rotate and move the pieces around, but none of them can overlap and all $$$n$$$ pieces must be used (of course, the square shouldn't contain any holes as well). Can he do it?

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 10^9$$$) — the number of puzzle pieces.

For each test case, if Phoenix can create a square with the $$$n$$$ puzzle pieces, print YES. Otherwise, print NO.

NoteFor $$$n=2$$$, Phoenix can create a square like this:    For $$$n=4$$$, Phoenix can create a square like this:    For $$$n=6$$$, it is impossible for Phoenix to create a square.

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
let obj = {};
const precompute = () => {
  let n = 50000;
  for (let i = 1; i <= n; i++) obj[i * i] = 1;
};
const solve = () => {
  let t = parseInt(readline());
  precompute();
  while (t--) {
    let n = parseInt(readline());
    if (n % 2) {
      console.log("NO");
      continue;
    }
    let k = n / 2;
    if (obj[k]) console.log("YES");
    else if (obj[k / 2]) console.log("YES");
    else console.log("NO");
  }
};
solve();

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

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

// ********** Code Start **********
function main() {
  var a = parseInt(readline())
  while(a--){
    var b = parseInt(readline())
    var c = Math.floor(Math.sqrt(b/2))
    var d = Math.floor(Math.sqrt(b/4))
    print(c * c * 2 == b || d * d * 4 == b ?"YES":"NO")
  }
}

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

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

// ********** Code Start **********
function main() {
  let a = parseInt(readline());
  while (a--) {
    let b = parseInt(readline());
    let c = Math.floor(Math.sqrt(b / 2));
    let d = Math.floor(Math.sqrt(b / 4));
    print(c * c * 2 == b || d * d * 4 == b ? "YES" : "NO");
  }
}

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

//Don't have to see. end------------------------------------------

function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var isOK = false;
		for(var j = 1; j * j <= N; j++){
			if(j * j * 2 == N || j * j * 4 == N){
				isOK = true;
				break;
			}
		}
		myout((isOK) ? "YES" : "NO");
	}
}

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}

const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    if (n === 1) console.log("NO");
    else if (n === 3) console.log("NO");
    else if (n === 2) console.log("YES");
    else {
      while (n > 2) n = Math.floor(n / 2);
      if (n === 1) console.log("NO");
      else console.log("YES");
    }
  }
};
solve();

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}

const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    if (n === 1) console.log("NO");
    if (n === 3) console.log("NO");
    if (n === 2) console.log("YES");
    else {
      while (n > 2) n = Math.floor(n / 2);
      if (n === 1) console.log("NO");
      else console.log("YES");
    }
  }
};
solve();

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

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

// ********** Code Start **********
function main() {
  var a = parseInt(readline())
  while(a--){
    var b = parseInt(readline())
    var c = Math.floor(Math.sqrt(b/2))
    var d = Math.floor(Math.sqrt(b/4))
    print(d)
    print(c * c * 2 == b || d * d * 4 == b ?"YES":"NO")
  }
}

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

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

// ********** Code Start **********
function main() {
  var a = parseInt(readline())
  while(a--){
    var b = parseInt(readline())
    var c = Math.sqrt(b/2)
    var d = Math.sqrt(b/4)
    print(c * c * 2 == b || d * d * 4 == b ?"YES":"NO")
  }
}


You are given a table consisting of n rows and m columns.Numbers in each row form a permutation of integers from 1 to m.You are allowed to pick two elements in one row and swap them, but no more than once for each row. Also, no more than once you are allowed to pick two columns and swap them. Thus, you are allowed to perform from 0 to n + 1 actions in total. Operations can be performed in any order.You have to check whether it's possible to obtain the identity permutation 1, 2, ..., m in each row. In other words, check if one can perform some of the operation following the given rules and make each row sorted in increasing order.

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 20) — the number of rows and the number of columns in the given table.  Each of next n lines contains m integers — elements of the table. It's guaranteed that numbers in each line form a permutation of integers from 1 to m.

If there is a way to obtain the identity permutation in each row by following the given rules, print "YES" (without quotes) in the only line of the output. Otherwise, print "NO" (without quotes).

NoteIn the first sample, one can act in the following way:   Swap second and third columns. Now the table is 1 2 3 4 1 4 3 2  In the second row, swap the second and the fourth elements. Now the table is 1 2 3 4 1 2 3 4

var arr = readline().split(' ');
var m  = arr[1];
var n = arr[0];
var array = [];
for(var i = 0;  i < n; i++) {
    array[i] =  readline().split(' ');
}
var count = 0;
var flag = true;
var flag1 = false;

for(var i = 0; i < m; i++) {
    for(var j = i ; j < m; j++) {
        for (var k = 0; k < n; k++) {
            if (!checkRow(array[k], i, j)) {
                flag = false;
                break;
            }
        }
        if(flag) {
            print("YES");
            flag1 = true;
            break;
        }
        flag = true;
        if(flag1){
            break;
        }
    }
    if(flag1){
        break;
    }
}

if(!flag1) {
    print('NO');
}
function checkRow(array, i, j) {
    var myArr = array.slice();
    var temp = myArr[i];
    myArr[i] = myArr[j];
    myArr[j] = temp;

    //   console.log('myArr ' + myArr);

    var results = myArr.map(function(value, y) {
        //  console.log(value, myArr[y + 1] + ' -------')
        if (value == myArr[value - 1]) {
            return 1;
        }
        return 0;
    });

    // console.log('results ' + results);

    var sum = results.reduce(function(a, b) { return a + b; }, 0);

    //  console.log('sum  ' + sum );

    return sum + 2 >= results.length

}
//  // function readline(i) {
//  //     // var data = [
//  //     //     '1 3 2 4',
//  //     //     '1 3 4 2'
//  //     // ]
//  //     // var data = [
//  //     //     '1 2 3 4',
//  //     //     '2 3 4 1',
//  //     //     '3 4 1 2',
//  //     //     '4 1 2 3'
//  //     // ]
//  //     var data = [
//  //         '2 1 3 4 5 6',
//  //         '1 2 4 3 5 6',
//  //         '1 2 3 4 6 5'
//  //     ]
//  //     // var data = [
//  //     //     '1 3 2 5 4',
//  //     //     '4 3 2 1 5',
//  //     //     '1 3 5 4 2',
//  //     //     '1 4 2 3 5'
//  //     // ]
//  //
//  //     return data[i];
//  //    }

var arr = readline().split(' ');
var m  = arr[1];
var n = arr[0];
var array = [];
for(var i = 0;  i < n; i++) {
    array[i] =  readline().split(' ');
}
var count = 0;
var flag = true;
var flag1 = false;

for(var i = 0; i < m; i++) {
    for(var j = i ; j < m; j++) {
        for (var k = 0; k < n; k++) {
            // if (!checkRow(array[k], i, j)) {
            //     flag = false;
            //     break;
            // }
        }
        if(flag) {
            print("YES");
            flag1 = true;
            break;
        }
        flag = true;
        if(flag1){
            break;
        }
    }
    if(flag1){
        break;
    }
}

if(!flag1) {
    print('NO');
}
function checkRow(array, i, j) {
    var myArr = array.slice();
    var temp = myArr[i];
    myArr[i] = myArr[j];
    myArr[j] = temp;

    //   console.log('myArr ' + myArr);

    var results = myArr.map(function(value, y) {
        //  console.log(value, myArr[y + 1] + ' -------')
        if (value == myArr[value - 1]) {
            return 1;
        }
        return 0;
    });

    // console.log('results ' + results);

    var sum = results.reduce(function(a, b) { return a + b; }, 0);

    //  console.log('sum  ' + sum );

    return sum + 2 >= results.length

}
//  // function readline(i) {
//  //     // var data = [
//  //     //     '1 3 2 4',
//  //     //     '1 3 4 2'
//  //     // ]
//  //     // var data = [
//  //     //     '1 2 3 4',
//  //     //     '2 3 4 1',
//  //     //     '3 4 1 2',
//  //     //     '4 1 2 3'
//  //     // ]
//  //     var data = [
//  //         '2 1 3 4 5 6',
//  //         '1 2 4 3 5 6',
//  //         '1 2 3 4 6 5'
//  //     ]
//  //     // var data = [
//  //     //     '1 3 2 5 4',
//  //     //     '4 3 2 1 5',
//  //     //     '1 3 5 4 2',
//  //     //     '1 4 2 3 5'
//  //     // ]
//  //
//  //     return data[i];
//  //    }


Walking along a riverside, Mino silently takes a note of something."Time," Mino thinks aloud."What?""Time and tide wait for no man," explains Mino. "My name, taken from the river, always reminds me of this.""And what are you recording?""You see it, tide. Everything has its own period, and I think I've figured out this one," says Mino with confidence.Doubtfully, Kanno peeks at Mino's records. The records are expressed as a string $$$s$$$ of characters '0', '1' and '.', where '0' denotes a low tide, '1' denotes a high tide, and '.' denotes an unknown one (either high or low).You are to help Mino determine whether it's possible that after replacing each '.' independently with '0' or '1', a given integer $$$p$$$ is not a period of the resulting string. In case the answer is yes, please also show such a replacement to Mino.In this problem, a positive integer $$$p$$$ is considered a period of string $$$s$$$, if for all $$$1 \leq i \leq \lvert s \rvert - p$$$, the $$$i$$$-th and $$$(i + p)$$$-th characters of $$$s$$$ are the same. Here $$$\lvert s \rvert$$$ is the length of $$$s$$$.

The first line contains two space-separated integers $$$n$$$ and $$$p$$$ ($$$1 \leq p \leq n \leq 2000$$$) — the length of the given string and the supposed period, respectively. The second line contains a string $$$s$$$ of $$$n$$$ characters — Mino's records. $$$s$$$ only contains characters '0', '1' and '.', and contains at least one '.' character.

Output one line — if it's possible that $$$p$$$ is not a period of the resulting string, output any one of such strings; otherwise output "No" (without quotes, you can print letters in any case (upper or lower)).

NoteIn the first example, $$$7$$$ is not a period of the resulting string because the $$$1$$$-st and $$$8$$$-th characters of it are different.In the second example, $$$6$$$ is not a period of the resulting string because the $$$4$$$-th and $$$10$$$-th characters of it are different.In the third example, $$$9$$$ is always a period because the only constraint that the first and last characters are the same is already satisfied.Note that there are multiple acceptable answers for the first two examples, you can print any of them.

/**
 * Problem link - http://codeforces.com/contest/989/problem/B
 */

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

var input_stdin = '';
var input_stdin_array = '';
var input_currentline = 0;

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

process.stdin.on('end', function () {
  input_stdin_array = input_stdin.split('\n');
  main();
});

function readLine() {
  return input_stdin_array[input_currentline++];
}

function main() {
  let input = readLine().split(' ')
  let n = parseInt(input[0], 10)
  let p = parseInt(input[1], 10)
  let result = 'No'

  let str = readLine()

  let arr = str.split('')
    let isPeriod = true
    for (let i = 0 ; i < n - p ; ++i) {
        let currentValue = arr[i]
        let laterValue = arr[i + p]
        if ((currentValue === '0' && laterValue === '1') || (currentValue === '1' && laterValue === '0')) {
            isPeriod = false
            break
        } else if (currentValue === '.' && laterValue === '.') {
            isPeriod = false
            arr[i] = '0'
            arr[i + p] = '1'
            break
        } else if(currentValue === '.') {
            isPeriod = false
            arr[i] = laterValue === '0' ? '1' : '0'
            break
        } else if(laterValue === '.') {
            isPeriod = false
            arr[i + p] = currentValue === '0' ? '1' : '0'
            break
        }
    }

    if (!isPeriod) {
        arr = arr.map(function(elem, index) {
            if (elem === '.') {
                return '0'
            } else {
                return elem
            }
        })
        result = arr.join('')
    }

    process.stdout.write(result)
}

/**
 * Problem link - http://codeforces.com/contest/989/problem/B
 */

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

var input_stdin = '';
var input_stdin_array = '';
var input_currentline = 0;

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

process.stdin.on('end', function () {
  input_stdin_array = input_stdin.split('\n');
  main();
});

function readLine() {
  return input_stdin_array[input_currentline++];
}

function main() {
  let input = readLine().split(' ').map(Number)
  let n = input[0]
  let p = input[1]
  let result = 'No'

  let str = readLine()

  let arr = str.split('')
    let s = arr.length
    let isPeriod = true
    for (let i = 0 ; i < s - p ; ++i) {
        let currentValue = arr[i]
        let laterValue = arr[i + p]
        if ((currentValue === '0' && laterValue === '1') || (currentValue === '1' && laterValue === '0')) {
            isPeriod = false
            break
        } else if (currentValue === '.' && laterValue === '.') {
            isPeriod = false
            arr[i] = '0'
            arr[i + p] = '1'
            break
        } else if(currentValue === '.') {
            isPeriod = false
            arr[i] = laterValue === '0' ? '1' : '0'
            break
        } else if(laterValue === '.') {
            isPeriod = false
            arr[i + p] = currentValue === '0' ? '1' : '0'
            break
        }
    }

    if (!isPeriod) {
        arr = arr.map(function(elem, index) {
            if (elem === '.') {
                return '0'
            } else {
                return elem
            }
        })
        result = arr.join('')
    }

    process.stdout.write(result)
}

/**
 * Problem link - http://codeforces.com/contest/989/problem/B
 */

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

var input_stdin = '';
var input_stdin_array = '';
var input_currentline = 0;

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

process.stdin.on('end', function () {
  input_stdin_array = input_stdin.split('\n');
  main();
});

function readLine() {
  return input_stdin_array[input_currentline++];
}

function main() {
  let input = readLine().split(' ').map(Number)
  let n = input[0]
  let p = input[1]
  let result = 'No'

  let str = readLine()

  let arr = str.split('')
    let s = arr.length
    let isPeriod = true
    for (let i = 0 ; i < s - p ; i++) {
        let currentValue = arr[i]
        let laterValue = arr[i + p]
        if ((currentValue === '0' && laterValue === '1') || (currentValue === '1' && laterValue === '0')) {
            isPeriod = false
            break
        } else if (currentValue === '.' && laterValue === '.') {
            isPeriod = false
            arr[i] = '0'
            arr[i + p] = '1'
            break
        } else if(currentValue === '.') {
            isPeriod = false
            arr[i] = laterValue === '0' ? '1' : '0'
            break
        } else if(laterValue === '.') {
            isPeriod = false
            arr[i + p] = currentValue === '0' ? '1' : '0'
            break
        }
    }

    if (!isPeriod) {
        arr = arr.map(function(elem, index) {
            if (arr[index] === '.') {
                return '0'
            } else {
                return arr[index]
            }
        })
        result = arr.join('')
    }

    process.stdout.write(result)
}

/**
 * Problem link - http://codeforces.com/contest/989/problem/B
 */

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

var input_stdin = '';
var input_stdin_array = '';
var input_currentline = 0;

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

process.stdin.on('end', function () {
  input_stdin_array = input_stdin.split('\n');
  main();
});

function readLine() {
  return input_stdin_array[input_currentline++];
}

function main() {
  let input = readLine().split(' ').map(Number)
  let n = input[0]
  let p = input[1]
  let result = 'No'

  let str = readLine()

  let arr = str.split('')
    let s = arr.length
    let isPeriod = true
    for (let i = s - p - 1 ; i >=0 ; i--) {
        let currentValue = arr[i]
        let laterValue = arr[i + p]
        if ((currentValue === '0' && laterValue === '1') || (currentValue === '1' && laterValue === '0')) {
            isPeriod = false
            break
        } else if (currentValue === '.' && laterValue === '.') {
            isPeriod = false
            arr[i] = '0'
            arr[i + p] = '1'
            break
        } else if(currentValue === '.') {
            isPeriod = false
            arr[i] = laterValue === '0' ? '1' : '0'
            break
        } else if(laterValue === '.') {
            isPeriod = false
            arr[i + p] = currentValue === '0' ? '1' : '0'
            break
        }
    }

    if (!isPeriod) {
        arr = arr.map(function(elem, index) {
            if (arr[index] === '.') {
                return '0'
            } else {
                return arr[index]
            }
        })
        result = arr.join('')
    }

    process.stdout.write(result)
}

/**
 * Problem link - http://codeforces.com/contest/989/problem/B
 */

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

var input_stdin = '';
var input_stdin_array = '';
var input_currentline = 0;

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

process.stdin.on('end', function () {
  input_stdin_array = input_stdin.split('\n');
  main();
});

function readLine() {
  return input_stdin_array[input_currentline++];
}

function main() {
  let input = readLine().split(' ').map(Number)
  let n = input[0]
  let p = input[1]
  let result = 'No'

  let str = readLine()

  let arr = str.split('')
    let s = arr.length
    let isPeriod = true
    for (let i = 0 ; i < s - p ; i++) {
        if (i + p <= s) {
            let currentValue = arr[i]
            let laterValue = arr[i + p]
            if ((currentValue === '0' && laterValue === '1') || (currentValue === '1' && laterValue === '0')) {
                isFalse = true
                break
            } else if (currentValue === '.' && laterValue === '.') {
                isPeriod = false
                arr[i] = '0'
                arr[i + p] = '1'
                break
            } else if(currentValue === '.') {
                isPeriod = false
                arr[i] = laterValue === '0' ? '1' : '0'
                break
            } else if(laterValue === '.') {
                isPeriod = false
                arr[i + p] = currentValue === '0' ? '1' : '0'
                break
            }
        }
    }

    if (!isPeriod) {
        arr = arr.map(function(elem, index) {
            if (arr[index] === '.') {
                return '0'
            } else {
                return arr[index]
            }
        })
        result = arr.join('')
    }

    process.stdout.write(result)
}

/**
 * Problem link - http://codeforces.com/contest/989/problem/B
 */

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

var input_stdin = '';
var input_stdin_array = '';
var input_currentline = 0;

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

process.stdin.on('end', function () {
  input_stdin_array = input_stdin.split('\n');
  main();
});

function readLine() {
  return input_stdin_array[input_currentline++];
}

function main() {
  let input = readLine().split(' ').map(Number)
  let n = input[0]
  let p = input[1]
  let result = 'No'

  let str = readLine()

  let arr = str.split('')
    let s = arr.length
    let isPeriod = true
    for (let i = 0 ; i < s - p ; i++) {
        if (i + p <= n) {
            let currentValue = arr[i]
            let laterValue = arr[i + p]
            if ((currentValue === '0' && laterValue === '1') || (currentValue === '1' && laterValue === '0')) {
                isFalse = true
                break
            } else if (currentValue === '.' && laterValue === '.') {
                isPeriod = false
                arr[i] = '0'
                arr[i + p] = '1'
                break
            } else if(currentValue === '.') {
                isPeriod = false
                arr[i] = laterValue === '0' ? '1' : '0'
                break
            } else if(laterValue === '.') {
                isPeriod = false
                arr[i + p] = currentValue === '0' ? '1' : '0'
                break
            }
        }
    }

    if (!isPeriod) {
        arr = arr.map(function(elem, index) {
            if (arr[index] === '.') {
                return '0'
            } else {
                return arr[index]
            }
        })
        result = arr.join('')
    }

    process.stdout.write(result)
}