Vasily exited from a store and now he wants to recheck the total price of all purchases in his bill. The bill is a string in which the names of the purchases and their prices are printed in a row without any spaces. Check has the format "name1price1name2price2...namenpricen", where namei (name of the i-th purchase) is a non-empty string of length not more than 10, consisting of lowercase English letters, and pricei (the price of the i-th purchase) is a non-empty string, consisting of digits and dots (decimal points). It is possible that purchases with equal names have different prices.The price of each purchase is written in the following format. If the price is an integer number of dollars then cents are not written.Otherwise, after the number of dollars a dot (decimal point) is written followed by cents in a two-digit format (if number of cents is between 1 and 9 inclusively, there is a leading zero).Also, every three digits (from less significant to the most) in dollars are separated by dot (decimal point). No extra leading zeroes are allowed. The price always starts with a digit and ends with a digit.For example:  "234", "1.544", "149.431.10", "0.99" and "123.05" are valid prices,  ".333", "3.33.11", "12.00", ".33", "0.1234" and "1.2" are not valid. Write a program that will find the total price of all purchases in the given bill.

The only line of the input contains a non-empty string s with length not greater than 1000 — the content of the bill. It is guaranteed that the bill meets the format described above. It is guaranteed that each price in the bill is not less than one cent and not greater than 106 dollars.

Print the total price exactly in the same format as prices given in the input.

var total = function( check ) {
  var dollarsPattern,
    centsPattern,
    totalDollars,
    totalCents,
    totalFormatted,
    i;

  centsPattern = /(\.)(\d{2})($|[a-zA-Z])/g;
  totalCents = 0;

  // Clean check from cents.
  check = check.replace( centsPattern, function( match, p1, p2, p3 ) {
    totalCents += parseInt( p2, 10 );
    return p1 + p3;
  });

  // Clean check from dollar separators.
  check = check.replace( /\./g, "" );

  // Now it's easy to find all dollars.
  dollarsPattern = /\d+/g;
  totalDollars = 0;
  check.match( dollarsPattern ).forEach( d => totalDollars += parseInt( d, 10 ) );

  // Convert to right format.
  totalDollars += Math.floor( totalCents / 100 );
  totalCents = totalCents % 100;
  totalFormatted = "";
  if ( totalCents ) {
    totalFormatted = totalCents.toString();
    if ( totalCents < 10 ) {
      totalFormatted = "0" + totalFormatted;
    }
    totalFormatted = "." + totalFormatted;
  }
  if ( totalDollars ) {
    totalDollars = totalDollars.toString();
    for ( i = 0; i < totalDollars.length; ++i ) {
      if ( i % 3 === 0 && i !== 0 ) {
       totalFormatted = "." + totalFormatted;
      }
      totalFormatted = totalDollars[totalDollars.length - i - 1] + totalFormatted;
    }
  } else {
     totalFormatted = "0" + totalFormatted;
  }
  return totalFormatted;
};

print( total( readline() ) );

var total = function( check ) {
  var dollarsPattern,
    centsPattern,
    totalDollars,
    totalCents,
    totalFormatted,
    i;

  centsPattern = /\.(\d{2})(?:$|[a-zA-Z])/g;
  totalCents = 0;

  // Clean check from cents.
  check = check.replace( centsPattern, function( match, p1 ) {
    totalCents += parseInt( p1, 10 );
    return "";
  });
  // Clean check from dollar separators.
  check = check.replace( ".", "" );

  // Now it's easy to find all dollars.
  dollarsPattern = /\d+/g;
  totalDollars = 0;
  check.match( dollarsPattern ).forEach( d => totalDollars += parseInt( d, 10 ) );

  // Convert to right format.
  totalDollars += Math.floor( totalCents / 100 );
  totalCents = totalCents % 100;
  totalFormatted = "";
  if ( totalCents ) {
    totalFormatted = totalCents.toString();
    if ( totalCents < 10 ) {
      totalFormatted = "0" + totalFormatted;
    }
    totalFormatted = "." + totalFormatted;
  }
  if ( totalDollars ) {
    totalDollars = totalDollars.toString();
    for ( i = 0; i < totalDollars.length; ++i ) {
      if ( i % 3 === 0 && i !== 0 ) {
       totalFormatted = "." + totalFormatted;
      }
      totalFormatted = totalDollars[totalDollars.length - i - 1] + totalFormatted;
    }
  } else {
     totalFormatted = "0" + totalFormatted;
  }
  return totalFormatted;
};

print( total( readline() ) );


Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that:  the first elevator is currently on the floor $$$a$$$ (it is currently motionless),  the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.

The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.

Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output:   $$$1$$$, if it is better to call the first elevator;  $$$2$$$, if it is better to call the second one;  $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).

NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows:  At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor;  in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$;  in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.

"use strict";
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.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********
function main() {
  var testCases = +readline();
  let arr = [];
  for (let m = 0; m < testCases; m++) {
    var q = readline().split(" ");
    var a = +q[0];
    var w = +q[1];
    var e = +q[2];
    if (Math.abs(e - w) + (e - 1) === a - 1) arr.push(3);
    else if (Math.abs(e - w) + (e - 1) > a - 1) arr.push(1);
    else arr.push(2);
  }
  arr = arr.join("\n");
  console.log(arr);
}

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

let inputString = "";

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

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

  main();
});

function main() {
  const testCases = inputString[0];

  const answers = [];

  for (let i = 1; i <= testCases; i++) {
    let [a, b, c] = inputString[i].split(" ").map((s) => Number(s));

    let bDist = c < b ? b : (c - b) * 2 + b;
    a--;
    bDist--;

    if (a === bDist) answers.push(3);
    else if (a < bDist) answers.push(1);
    else answers.push(2);
  }

  answers.forEach((v) => console.log(v));
}

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*/
    var n = lines[0]
    for(j = 1; j <= n; j++){
        k = lines[j].split(" ").map(Number)

        a = Math.abs(k[0] - 1);
        b = Math.abs(k[2] - k[1]) + Math.abs(k[2] - 1);
          if (a < b) {
            console.log(1);
          } else if (b < a) {
            console.log(2);
          } else {
            console.log(3);
          }

    }

});

"use strict";

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

let inputString = "";
let currentLine = 0;

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

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

  main();
});

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

function main() {
  const t = readline();
  for (let i = 0; i < t; i++) {
    let sol = 3;

    const [a, b, c] = readline()
      .split(" ")
      .map((x) => parseInt(x));

    if (a - 1 < Math.abs(b - c) + Math.abs(c - 1)) sol = 1;
    else if (a - 1 > Math.abs(b - c) + Math.abs(c - 1)) sol = 2;
    console.log(sol);
  }
}

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    for(i = 1; i <= t; i++){
        var k = lines[i].split(' ').map(Number);
        var a = k[0], b = k[1], c = k[2];
        a--;
        b = Math.abs(c - b) + c - 1;
        console.log(a < b ? 1 : a > b ? 2 : 3);
    }
});

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

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
    inputString += inputStdin;
  });
process.stdin.on("end", (_) => {
  inputString = inputString.trim().split("\n").map((string) => {
    return string.trim();
  });
  main();
});
function readline() {
  return inputString[currentLine++];
}

function main() {
  var t = readline();
  for (var i = 0; i < t; i++) {
    var [a, b, c] = readline().trim().split(' ').map(Number);
    if ((a - 1) == ((Math.abs(b - c) + c) -1)) {
      process.stdout.write('3\n');
    }
    if ((a - 1) > ((Math.abs(b - c) + c) -1)) {
      process.stdout.write('2\n')
    }
    if ((a - 1) < ((Math.abs(b - c) + c) -1)) {
      process.stdout.write('1\n')
    }
  }
}
// https://codeforces.com/contest/1729/problem/B
  // function main() {
  //   let Alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
  //   let n = readline();
  //   for (let k = 0; k < n; k++) {
  //     var o = readline();
  //     var splittedSTR = readline().trim().split('');
  //     var output = [];
  //     for (var i = 0; i < o; i++) {
  //       if (splittedSTR[i + 1] == 0 && splittedSTR[i + 2] != 0) {
  //         splittedSTR[i] = `${splittedSTR[i - 1] + splittedSTR[i]}`;
  //         splittedSTR.splice(i + 1, 1)
  //         splittedSTR.splice(i - 1, 1)
  //       }
  //       if (o - i == 1) {
  //         for (var j = 0; j < splittedSTR.length; j++) {
  //           output.push(Alpha[splittedSTR[j] - 1])
  //           if (output.length == splittedSTR.length) {
  //             console.log(output.join(''));
  //           }
  //         }
  //       }
  //     }
  //   }
  // }

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

let c = 0;

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

  const [e1, e2, f] = d.split(" ").map(Number);
  const e1d = Math.abs(e1 - 1);
  const e2d = Math.abs(f - e2) + Math.abs(f - 1);

  if (e1d < e2d) {
    console.log(1);
  } else if (e2d < e1d) {
    console.log(2);
  } else {
    console.log(3);
  }

  c++;
});

rl.on("close", () => {});

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

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

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0; i < t; i++){
		let [a, b, c] = nl.nums();
		let x = 0;
		if (b > c) {
			x = b;
		} else {
			x = c + c - b;
		}
		if (a < x) {
			ans.push(1);
		} else if (a > x) {
			ans.push(2);
		} else {
			ans.push(3);
		}
	}
	console.log(ans.join('\n'));
};

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

/*
** Template
*/

// Common Template Starts //
//*
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++];
}
// Common Template Ends //

function getResult(inputs) {
    let a = inputs[0]
    let b = inputs[1]
    let c = inputs[2]

    if (a == 1 && b != 1) return 1
    if (a == b && c < b) return 3

    let opt1 = a - 1
    let opt2 = 0

    if (b >= c) {
        opt2 = b - 1
    } else if (b < c) {
        opt2 = c - b
        opt2 += c - 1
    }

    if (opt1 < opt2) return 1
    if (opt1 > opt2) return 2
    if (opt1 == opt2) return 3
}

function main() {
    let testCases = parseInt(readline())
    while (testCases--) {
        let inputs = readline()
        inputs = inputs.split(' ').map(Number)
        console.log(getResult(inputs))
    }
}
//*/
// console.clear()
// let inputs = ''
// inputs = '1 2 3'
// inputs = inputs.split(' ').map(Number)
// console.log( getResult(inputs) )
// inputs = '3 1 2'
// inputs = inputs.split(' ').map(Number)
// console.log( getResult(inputs) )
// inputs = '3 2 1'
// inputs = inputs.split(' ').map(Number)
// console.log( getResult(inputs) )
// process.exit(1)

'use strict';

var fs = require('fs');

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

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

function solve(read) {
  const rns = () => {
    return read().split(' ').filter(s => s !== '').map(Number);
  };
  const [a, b, c] = rns();
  const d = Math.abs(b - c) + c;
  if (a > d) return 2;else if (a < d) return 1;
  return 3;
}

function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < 100) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= 100) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

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

const readline = require('readline')

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

function solve(a, b, c) {
    const t1 = a - 1
    const t2 = c < b ? b - 1 : c - b + c - 1
    if (t1 < t2) return 1
    if (t1 > t2) return 2
    return 3
}

function twoElevator (lift1, from , to) {
    if (lift1 == 1) return 1
    var result1 = lift1 - 1
    var result2 = 0

    if (from > to) {
        result2 = from - to + to - 1
    } else { //
        result2 = 2 * to - from - 1
    }

    if (result1 === result2) return 3
    if (result1 > result2) {
        return 2
    } else {
        return 1
    }
}

function main() {

    var count = readline();

    var inp = [];

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

        inp = readline().split(' ').map(el => +el);
        var result = twoElevator(inp[0], inp[1], inp[2]);
        print(result);

    }

}
main()

var t = +readline();

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

      var nums = [];
    var arr = readline().split(' ').map((t) => +t)
    print(TwoElevators(arr[0],arr[1],arr[2]))

}

function TwoElevators(a,b,c){
    a -= 1;
    var test1 = Math.abs(b - c) + c - 1;
    if (test1 < a){
        return '2'
    }else if (test1 > a){
        return '1'
    }else {
        return '3'
    }
}

function foo(elev1, elev2from, elev2to) {
	var elev1time = elev1 - 1

    var elev2time = 0

    if(elev2to === 1) elev2time = elev2from - 1
  	else {
    	elev2time = Math.abs(elev2to - elev2from) + (elev2to - 1)
    }

  	if(elev1time < elev2time) return 1
  	else if(elev1time === elev2time) return 3
  	else return 2
}

var count = readline();

var inp;
var size;

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

    inp = readline().split(' ').map(el => +el);
    print(foo(inp[0], inp[1], inp[2]));

}

var limit = parseInt(readline());
for (var i = 0; i < limit; i++)
{
    var caseArray = readline().split(" ");
    var firstElevator = parseInt(caseArray[0]);
    var firstElevatorTime = firstElevator - 1;
    var secondElevator = parseInt(caseArray[1]);
    var secondElevatorDestination = parseInt(caseArray[2])
    var secondElevatorTime = 0;
    if (secondElevator > secondElevatorDestination)
    {
        secondElevatorTime = secondElevator - 1;
    }
    else
    {
        secondElevatorTime = ((secondElevatorDestination - secondElevator) + (secondElevatorDestination - 1))
    }
    var result = 0;
    if (firstElevatorTime > secondElevatorTime)
    {
        result = 2;
    }
    else if (firstElevatorTime < secondElevatorTime)
    {
        result = 1;
    }
    else
    {
        result = 3;
    }
    print(result);
}

T = readline();

while (T--) {
  str = readline()
    .split(" ")
    .map((el) => +el);
  a = str[0];
  b = str[1];
  c = str[2];

  bc = 0;

  if (b > c) bc = b;
  else bc = b + (c-b) * 2;

  ans = 0;
  if (a < bc) ans = 1;
  else if (a > bc) ans = 2;
  else ans = 3;

  print(ans);
}

var t = parseInt(readline());

for (var test = 0; test < t; test++) {
    var inp = readline().split(' ');
    var a = parseInt(inp[0]);
    var b = parseInt(inp[1]);
    var c = parseInt(inp[2]);

    var abs1 = a - 1;
    var abs2 = Math.abs(c - b) + c - 1;

    if (abs1 < abs2) {
        print('1');
    } else if (abs2 < abs1) {
        print('2');
    } else {
        print('3');
    }
}

    var t = readline();
    for(var i = 0 ; i < t ; i++){
        var inputs = readline().split(' '),
            a = inputs[0],
            b = inputs[1];
            c = inputs[2];
            firstElevator = a - 1;
            secondElevator = Math.abs(b - c) + (c - 1);
            if(firstElevator < secondElevator){
                print('1');
            }
            else if(firstElevator > secondElevator){
                print('2');
            }
            else{
                print('3');
            }
    }

"use strict";
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.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********
function main() {
  let testCases = +readline();
  let arr = [];
  for (let m = 0; m < testCases; m++) {
    let q = readline().split(" ");
    let a = +q[0];
    let w = +q[1];
    let e = +q[2];
    if (Math.abs(e * 2 - (w + 1)) === a - 1) {
      arr.push(3);
      continue;
    }
    if (Math.abs(e * 2 - (w + 1)) + (e - 1) > a - 1) {
      arr.push(1);
      continue;
    }
    arr.push(2);
  }
  arr = arr.join("\n");
  console.log(arr);
}

"use strict";
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.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********
function main() {
  let testCases = +readline();
  let arr = [];
  for (let m = 0; m < testCases; m++) {
    let q = readline().split(" ");
    let a = +q[0];
    let w = +q[1];
    let e = +q[2];
    if (Math.abs(e * 2 - (w + 1)) === a - 1) arr.push(3);
    else if (Math.abs(e * 2 - (w + 1)) + (e - 1) > a - 1) arr.push(1);
    else arr.push(2);
  }
  arr=arr.join("\n");
  console.log(arr);
}

"use strict";
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.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********
function main() {
  let testCases = +readline();
  let arr = [];
  for (let m = 0; m < testCases; m++) {
    let q = readline().split(" ");
    let a = +q[0];
    let w = +q[1];
    let e = +q[2];
    if (Math.abs(e * 2 - (w + 1)) === a - 1) arr.push(3);
    else if (Math.abs(e * 2 - (w + 1)) + (e - 1) > a - 1) arr.push(1);
    else arr.push(2);
  }
  console.log(arr.join("\n"));
}

"use strict";
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.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********
function main() {
  var testCases = +readline();
  let arr = [];
  for (let m = 0; m < testCases; m++) {
    var q = readline().split(" ");
    var a = +q[0];
    var w = +q[1];
    var e = +q[2];
    if (Math.abs(e - w )+ (e- 1) === a - 1) arr.push(3);
    if (Math.abs(e - w )+ (e- 1) > a - 1) arr.push(1);
    else arr.push(2);
  }
  arr = arr.join("\n");
  console.log(arr);
}

"use strict";
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.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********
function main() {
  var testCases = +readline();
  let arr = [];
  for (let m = 0; m < testCases; m++) {
    var q = readline().split(" ");
    var a = +q[0];
    var w = +q[1];
    var e = +q[2];
    if (Math.abs(e * 2 - (w + 1)) === a - 1) arr.push(3);
    if (Math.abs(e * 2 - (w + 1)) > a - 1) arr.push(1);
    else arr.push(2);
  }
  arr = arr.join("\n");
  console.log(arr);
}

"use strict";
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.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********
function main() {
  var testCases = +readline();
  let arr = [];
  for (let m = 0; m < testCases; m++) {
    var q = readline().split(" ");
    var a = +q[0];
    var w = +q[1];
    var e = +q[2];
    if (Math.abs(e * 2 - (w + 1)) === a - 1) arr.push(3);
    if (Math.abs(e * 2) - (w + 1) > a - 1) arr.push(1);
    else arr.push(2);
  }
  arr =arr.join("\n")
  console.log(arr);
}

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

let inputString = "";

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

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

  main();
});

function main() {
  const testCases = inputString[0];

  const answers = [];

  for (let i = 1; i <= testCases; i++) {
    const [a, b, c] = inputString[i].split(" ").map((s) => Number(s));

    if (a === 1) answers.push(1);
    else if (
      (a === 2 && b === 2 && c === 1) ||
      (a === 3 &&
        ((b === 1 && c === 2) || (b === 2 && c === 3) || (b === 3 && c === 1)))
    )
      answers.push(3);
    else answers.push(2);
  }

  answers.forEach((v) => console.log(v));
}

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

let inputString = "";

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

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

  main();
});

function main() {
  const testCases = inputString[0];

  const answers = [];

  for (let i = 1; i <= testCases; i++) {
    const [a, b, c] = inputString[i].split(" ").map((s) => Number(s));

    if (a === 1) answers.push(1);
    else if (
      (a === 2 && b === 2 && c === 1) ||
      (a === 3 && ((b === 3 && c === 1) || (b === 1 && c === 2)))
    )
      answers.push(3);
    else answers.push(2);
  }

  answers.forEach((v) => console.log(v + " "));
}

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

let inputString = "";

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

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

  main();
});

function main() {
  const testCases = inputString[0];

  const answers = [];

  for (let i = 1; i <= testCases; i++) {
    const [a, b, c] = inputString[i].split(" ").map((s) => Number(s));

    if (a === 1) answers.push(1);
    else if (
      (a === 2 && b === 2 && c === 1) ||
      (a === 3 && ((b === 3 && c === 1) || (b === 1 && c === 2)))
    )
      answers.push(3);
    else answers.push(2);
  }

  answers.forEach((v) => console.log(v + "\n"));
}

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

let inputString = "";

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

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

  main();
});

function main() {
  const testCases = inputString[0];

  const answers = [];

  for (let i = 1; i <= testCases; i++) {
    const [a, b, c] = inputString[i].split(" ").map((s) => Number(s));

    if (a === 1) answers.push(1);
    else if (
      (a === 2 && b === 2 && c === 1) ||
      (a === 3 && ((b === 3 && c === 1) || (b === 1 && c === 2)))
    )
      answers.push(3);
    else answers.push(2);
  }

  answers.forEach((v) => console.log(v));
}

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*/
    var n = lines[0]
    for(j = 1; j <= n; j++){
        k = lines[j].split(' ').map(Number)
        a = k[0]
        b = k[1]
        c = k[2]
        if(a == 1){
            console.log(1)
        }else{
            if(a == 3 && b == 2 && c == 1){
                console.log(2)
            }else{
                if(b + c == a){
                console.log(3)
                }else{
                    console.log(1)
                }
            }
        }

    }

});

let i = '';//.map(Number).sort(function(a, b){return a - b})
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0]
    for(j =1; j <= n; j++){
        k = lines[j].split(' ').map(Number)
        a = k[0]
        b = k[1]
        c = k[2]
        if(a == 1){
            console.log(1)
        }else{
            if(a == 3 && b == 2 && c == 1){
                console.log(2)
            }else{
                if(b + c == a){
                console.log(3)
                }else{
                    console.log(1)
                }
            }
        }

    }

});//k[k.length - 1] == '' ||

let i = '';//.map(Number).sort(function(a, b){return a - b})
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0]
    for(j =1; j <= n; j++){
        k = lines[j].split(' ').map(Number)
        a = k[0]
        b = k[1]
        c = k[2]
        if(a == 1){
            console.log(1)
        }else{
            if(a == 3 && b == 2 && c == 1){
                console.log(2)
            }else{
                console.log(3)
            }
        }

    }

});//k[k.length - 1] == '' ||

"use strict";

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

let inputString = "";
let currentLine = 0;

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

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

  main();
});

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

function main() {
  const t = readline();
  for (let i = 0; i < t; i++) {
    let sol = 3;

    const [a, b, c] = readline()
      .split(" ")
      .map((x) => parseInt(x));
    if (b < c) {
      if (a - 1 < Math.abs(b - c) + Math.abs(c - 1)) sol = a;
      else if (a - 1 > Math.abs(b - c) + Math.abs(c - 1)) sol = b;
    } else {
      if (a - 1 < Math.abs(b - c - 1)) sol = a;
      else if (a - 1 > Math.abs(b - c - 1)) sol = b;
    }

    console.log(sol);
  }
}

"use strict";

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

let inputString = "";
let currentLine = 0;

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

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

  main();
});

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

function main() {
  const t = readline();
  for (let i = 0; i < t; i++) {
    let sol = 3;

    const [a, b, c] = readline()
      .split(" ")
      .map((x) => parseInt(x));

    if (a - 1 < Math.abs(b - c) + Math.abs(c - 1)) sol = a;
    else if (a - 1 > Math.abs(b - c) + Math.abs(c - 1)) sol = b;
    console.log(sol);
  }
}

"use strict";

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

let inputString = "";
let currentLine = 0;

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

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

  main();
});

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

function main() {
  const t = readline();
  for (let i = 0; i < t; i++) {
    let sol = 3;

    const [a, b, c] = readline()
      .split(" ")
      .map((x) => parseInt(x));

    if (a < Math.abs(b - c) + Math.abs(c)) sol = a;
    else if (a > Math.abs(b - c) + Math.abs(c)) sol = b;
    console.log(sol);
  }
}

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    for(i = 1; i <= t; i++){
        var k = lines[i].split(' ').map(Number);
        var a = k[0], b = k[1], c = k[2] * 2;
        a--;
        b = Math.abs(c - b) - 1;
        console.log(a < b ? 1 : a > b ? 2 : 3);
    }
});

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

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
    inputString += inputStdin;
  });
process.stdin.on("end", (_) => {
  inputString = inputString.trim().split("\n").map((string) => {
    return string.trim();
  });
  main();
});
function readline() {
  return inputString[currentLine++];
}

function main() {
  var t = readline();
  for (var i = 0; i < t; i++) {
    var [a, b, c] = readline().trim().split(' ').map(Number);
    if ((a - 1) == ((Math.abs(b - c) + c) -1)) {
      process.stdout.write('3');
    }
    if ((a - 1) > ((Math.abs(b - c) + c) -1)) {
      process.stdout.write('2')
    }
    if ((a - 1) < ((Math.abs(b - c) + c) -1)) {
      process.stdout.write('1')
    }
  }
}
// https://codeforces.com/contest/1729/problem/B
  // function main() {
  //   let Alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
  //   let n = readline();
  //   for (let k = 0; k < n; k++) {
  //     var o = readline();
  //     var splittedSTR = readline().trim().split('');
  //     var output = [];
  //     for (var i = 0; i < o; i++) {
  //       if (splittedSTR[i + 1] == 0 && splittedSTR[i + 2] != 0) {
  //         splittedSTR[i] = `${splittedSTR[i - 1] + splittedSTR[i]}`;
  //         splittedSTR.splice(i + 1, 1)
  //         splittedSTR.splice(i - 1, 1)
  //       }
  //       if (o - i == 1) {
  //         for (var j = 0; j < splittedSTR.length; j++) {
  //           output.push(Alpha[splittedSTR[j] - 1])
  //           if (output.length == splittedSTR.length) {
  //             console.log(output.join(''));
  //           }
  //         }
  //       }
  //     }
  //   }
  // }

function twoElevator (lift1, from, to) {
    if (lift1 == 1) return 1
    var result1 = lift1 - 1
    var result2 = 0
    if (from > to) {
        result2 = from - to
    } else { //
        result2 = 2 * (to - from)
    }
    if (result1 === result2) return 3
    if (result1 > result2) {
        return 2
    } else {
        return 1
    }
}

function main() {

    var count = readline();

    var inp = [];

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

        inp = readline().split(' ').map(el => +el);
        var result = twoElevator(inp[0], inp[1], inp[2]);
        print(result);

    }

}
main()

var t = +readline();

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

      var nums = [];
    var arr = readline().split(' ').map((t) => +t)
    print(TwoElevators(arr[0],arr[1],arr[2]))

}

function TwoElevators(a,b,c){
    a -= 1;
    var test1 = Math.abs(b - c - 1);
    if (test1 < a){
        return '2'
    }else if (test1 > a){
        return '1'
    }else {
        return '3'
    }
}


Vasya is writing an operating system shell, and it should have commands for working with directories. To begin with, he decided to go with just two commands: cd (change the current directory) and pwd (display the current directory).Directories in Vasya's operating system form a traditional hierarchical tree structure. There is a single root directory, denoted by the slash character "/". Every other directory has a name — a non-empty string consisting of lowercase Latin letters. Each directory (except for the root) has a parent directory — the one that contains the given directory. It is denoted as "..".The command cd takes a single parameter, which is a path in the file system. The command changes the current directory to the directory specified by the path. The path consists of the names of directories separated by slashes. The name of the directory can be "..", which means a step up to the parent directory. «..» can be used in any place of the path, maybe several times. If the path begins with a slash, it is considered to be an absolute path, that is, the directory changes to the specified one, starting from the root. If the parameter begins with a directory name (or ".."), it is considered to be a relative path, that is, the directory changes to the specified directory, starting from the current one.The command pwd should display the absolute path to the current directory. This path must not contain "..".Initially, the current directory is the root. All directories mentioned explicitly or passed indirectly within any command cd are considered to exist. It is guaranteed that there is no attempt of transition to the parent directory of the root directory.

The first line of the input data contains the single integer n (1 ≤ n ≤ 50) — the number of commands. Then follow n lines, each contains one command. Each of these lines contains either command pwd, or command cd, followed by a space-separated non-empty parameter. The command parameter cd only contains lower case Latin letters, slashes and dots, two slashes cannot go consecutively, dots occur only as the name of a parent pseudo-directory. The command parameter cd does not end with a slash, except when it is the only symbol that points to the root directory. The command parameter has a length from 1 to 200 characters, inclusive. Directories in the file system can have the same names.

For each command pwd you should print the full absolute path of the given directory, ending with a slash. It should start with a slash and contain the list of slash-separated directories in the order of being nested from the root to the current folder. It should contain no dots.

7
pwd
cd /home/vasya
pwd
cd ..
pwd
cd vasya/../petya
pwd

var count = +readline(),
	command,
	temp,
	paths = [],
	path = '/',
	ans;

function filterDoublePoint(temp) {
	for (var i = 0, len = temp.length; i < len; i++) {
		if (temp[i] === '..') {
			temp.splice(i - 1, 2);
			i -= 2;
		}
	}
	return temp.join('/');
}

for (var i = 0; i < count; i++) {
	command = readline().split(' ');
	if (command[0] === 'pwd') {
		paths[i] = path;
	} else {
		temp = command[1].split('/');
		if (temp[0]) {
			path += command[1] + '/';
			path = filterDoublePoint(path.split('/'));
		} else {
			path = command[1] + '/';
			path = filterDoublePoint(path.split('/'));
		}
	}
}

print(paths.join('\n'));

var commandsNumber = readline();
var path = [];
var pathStr;
var command;

for(var i = 0; i < commandsNumber; i++){
  command = readline();
  if(command == "pwd"){
    for(var j = 0; j < path.length; j++){
      if(path[j] == "/") path.splice(j,1, "");
    }

    if(path.length == 0) print("/");
    else{
      pathStr = path.join("/");
      pathStr = "/" + pathStr + "/";
      print(pathStr);
    }
  }
  else{
    command = command.split(" ");
    command = command[1];
    command = command.split("/");
    if(command[0] === ""){
      command.splice(0,1);
      for(var j = 0; j < command.length; j++){
        if(command[j] == "..") {command.splice(j-1, 2); j = 0}
      }
      path = command;
    }
    else{
      path = path.concat(command);
      for(var j = 0; j < path.length; j++){
        if(path[j] == "..") {path.splice(j-1, 2); j = 0;}
      }
    }
  }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function print(s){
    process.stdout.write(s);
}

function println(s){
    console.log(s);
}
// Make a Snippet for the code above this and then write your logic in main();

function main(){
    var n = parseInt(readline().split(' ')[0]);
    var path = [];
    var j = 0;

    for(var i=0; i<n; i++){
        var args = readline().split(' ');
        if(args[0] == "pwd"){
            print("/");
            for(j=0; j<path.length; j++){
                print(path[j]);
                print("/");
            }
            print("\n");
        }else{
            if(args[1][0] == '/'){ //absolute
                path = []
                var ops = args[1].split('/');
                for(j=0; j<ops.length; j++){
                    if(ops[j] == ".."){
                        path.pop();
                    }else if(ops[j] != ""){
                        path.push(ops[j]);
                    }
                }
            }else{ //relative
                var ops = args[1].split('/');
                for(j=0; j<ops.length; j++){
                    if(ops[j] == ".."){
                        path.pop();
                    }else if(ops[j] != ""){
                        path.push(ops[j]);
                    }
                }
            }

        }
    }

}

;(function () {

	var n = +readline();

	var p = [];
	var c, t;
	for (var i = 0; i < n; i++) {
		c = readline();

		if (c == 'pwd') {
			print(('/' + p.join('/') + '/').replace(/\/\//g, '/'));
			continue;
		}

		c = c.split(' ')[1].split('/');

		for (var j = 0; j < c.length; j++)
			switch (c[j]) {
				case '':
					p = [];
					break;

				case '..':
					p.pop();
					break;

				default:
					p.push(c[j]);
			}
	}

}).call(this)

var count = +readline();
var abspath = [];

for (var i=0; i<count; i++) {
    var cmd = readline();
    cmd = cmd.split(' ');
    if (cmd[0] == 'cd') {
        var path = cmd[1].split('/');
        if (cmd[1][0] == '/') { abspath.length = 0;  }
        for (var j=0; j<path.length; j++) {
            if(path[j] == '..') { abspath.pop(); }
            else { abspath.push(path[j]); }
        }
    }
    else {
        if (!abspath.length){
            print('/');
        } else if (abspath[0] == ''){
            print(abspath.join('/') + '/');
        } else {
            print('/' + abspath.join('/') + '/');
        }
    }
}

var count = +readline(),
	command,
	temp,
	paths = [],
	path = '/',
	ans;

function filterDoublePoint(temp) {
	for (var i = 0, len = temp.length; i < len; i++) {
		if (temp[i] === '..') {
			temp.splice(i - 1, 2);
			i -= 2;
		}
	}
	return temp.join('/');
}

for (var i = 0; i < count; i++) {
	command = readline().split(' ');
	if (command[0] === 'pwd') {
		paths[i] = path;
	} else {
		temp = command[1].split('/');
		if (temp[0]) {
			path += command[1] + '/';
			path = filterDoublePoint(path.split('/'));
		} else {
			path = command[1] + '/';
			path = filterDoublePoint(path.split('/'));
		}
	}
}

write(paths.join('\n'));

var count = +readline(),
	command,
	temp,
	paths = [],
	path = '/',
	ans;

function filterDoublePoint(temp) {
	for (var i = 0, len = temp.length; i < len; i++) {
		if (temp[i] === '..') {
			temp.splice(i - 1, 2);
			i -= 2;
		}
	}
	return temp.join('/');
}

for (var i = 0; i < count; i++) {
	command = readline().split(' ');
	if (command[0] === 'pwd') {
		paths[i] = path;
	} else {
		temp = command[1].split('/');
		if (temp[0]) {
			path += command[1] + '/';
			path = filterDoublePoint(path.split('/'));
		} else {
			path = command[1] + '/';
			path = filterDoublePoint(path.split('/'));
		}
	}
}

write(paths.join('/n'));

var count = +readline(),
	command,
	temp,
	paths = [],
	path = '/',
	ans;

function filterDoublePoint(temp) {
	for (var i = 0, len = temp.length; i < len; i++) {
		if (temp[i] === '..') {
			temp.splice(i - 1, 2);
			i -= 2;
		}
	}
	return temp.join('/');
}

for (var i = 0; i < count; i++) {
	command = readline().split(' ');
	if (command[0] === 'pwd') {
		paths[i] = path;
	} else {
		temp = command[1].split('/');
		if (temp[0]) {
			path += command[1] + '/';
			path = filterDoublePoint(path.split('/'));
		} else {
			path = command[1] + '/';
			path = filterDoublePoint(path.split('/'));
		}
	}
}

print(paths.join('/n'));

var commandsNumber = readline();
var path = [""];
var pathStr;
var command;

for(var i = 0; i < commandsNumber; i++){
  command = readline();
  if(command == "pwd"){
    for(var j = 0; j < path.length; j++){
      if(path[j] == "/") path.splice(j,1, "");
    }

    if((path[0] == "" && path.length == 1) || path.length == 0) print("/");
    else{
      pathStr = path.join("/");
      pathStr = "/" + pathStr + "/";
      print(pathStr);
    }
  }
  else{
    command = command.split(" ");
    command = command[1];
    command = command.split("/");
    if(command[0] === ""){
      command.splice(0,1);
      for(var j = 0; j < command.length; j++){
        if(command[j] == "..") {command.splice(j-1, 2); j = 0}
      }
      path = command;
    }
    else{
      path = path.concat(command);
      for(var j = 0; j < path.length; j++){
        if(path[j] == "..") {path.splice(j-1, 2); j = 0;}
      }
    }
  }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function print(s){
    process.stdout.write(s);
}

function println(s){
    console.log(s);
}
// Make a Snippet for the code above this and then write your logic in main();

function main(){
    var n = parseInt(readline().split(' ')[0]);
    var path = [];
    var j = 0;

    for(var i=0; i<n; i++){
        var args = readline().split(' ');
        if(args[0] == "pwd"){
            print("/");
            for(j=0; j<path.length; j++){
                print(path[j]);
                print("/");
            }
            print("\n");
        }else{
            var ops = args[1].split('/');
            for(j=0; j<ops.length; j++){
                if(ops[j] == ".."){
                    path.pop();
                }else if(ops[j] !== ""){
                    path.push(ops[j]);
                }
            }
        }
    }

}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function print(s){
    process.stdout.write(s);
}

function println(s){
    console.log(s);
}
// Make a Snippet for the code above this and then write your logic in main();

function main(){
    var n = parseInt(readline().split(' ')[0]);
    var path = [];
    var j =0;

    for(var i=0; i<n; i++){
        var args = readline().split(' ');
        if(args[0] == "pwd"){
            print("/");
            for(j=0; j<path.length; j++){
                print(path[j]);
                print("/");
            }
            print("\n");
        }else{
            var ops = args[1].split('/');
            for(j=1; j<ops.length; j++){
                if(ops[j] == ".."){
                    path.pop();
                }else{
                    path.push(ops[j]);
                }
            }
        }
    }

}

;(function () {

	var n = +readline();

	var p = [];
	var c, t;
	for (var i = 0; i < n; i++) {
		c = readline();

		if (c == 'pwd') {
			print('/' + p.join('/'));
			continue;
		}

		c = c.split(' ')[1].split('/');

		for (var j = 0; j < c.length; j++)
			switch (c[j]) {
				case '':
					p = [];
					break;

				case '..':
					p.pop();
					break;

				default:
					p.push(c[j]);
			}
	}

}).call(this)

;(function () {

	var n = +readline();

	var p = [];
	var c, t;
	for (var i = 0; i < n; i++) {
		c = readline();

		if (c == 'pwd') {
			print('/' + p.join('/') + '/');
			continue;
		}

		c = c.split(' ')[1].split('/');

		for (var j = 0; j < c.length; j++)
			switch (c[j]) {
				case '':
					p = [];
					break;

				case '..':
					p.pop();
					break;

				default:
					p.push(c[j]);
			}
	}

}).call(this)

var count = +readline();
var abspath = [];

for (var i=0; i<count; i++) {
    var cmd = readline();
    cmd = cmd.split(' ');
    if (cmd[0] == 'cd') {
        var path = cmd[1].split('/');
        if (cmd[1][1] == '/') { abspath = [];  }
        for (var j=0; j<path.length; j++) {
            if(path[j] == '..') { abspath.pop(); }
            else { abspath.push(path[j]); }
        }
    }
    else {
        if (!abspath.length){
            print('/');
        } else if (abspath[0] == ''){
            print(abspath.join('/') + '/');
        } else {
            print('/' + abspath.join('/') + '/');
        }
    }
}

var count = +readline();
var abspath = [];

for (var i=0; i<count; i++) {
    var cmd = readline();
    cmd = cmd.split(' ');
    if (cmd[0] == 'cd') {
        var path = cmd[1].split('/');
        if (cmd[1][1] == '/') { abspath = []; }
        for (var j=0; j<path.length; j++) {
            if(path[j] == '..') { abspath.pop(); }
            else { abspath.push(path[j]); }
        }
    }
    else {
        print(abspath.join('/') + '/');
    }
}

var count = +readline();
var abspath = [];

for (var i=0; i<count; i++) {
    var cmd = readline();
    cmd = cmd.split(' ');
    if (cmd[0] == 'cd') {
        var path = cmd[1].split('/');
        if (cmd[1][1] == '/') { abspath = [];  }
        for (var j=0; j<path.length; j++) {
            if(path[j] == '..') { abspath.pop(); }
            else { abspath.push(path[j]); }
        }
    }
    else {
        if (abspath[0] == ''){
            print(abspath.join('/') + '/');
        } else {
            print('/' + abspath.join('/') + '/');
        }
    }
}

var count = +readline(),
	command,
	temp,
	paths = [],
	path = '/';

function filterDoublePoint(temp) {
	for (var i = 0, len = temp.length; i < len; i++) {
		if (temp[i] === '..') {
			temp.splice(i - 1, 2);
			i -= 2;
		}
	}
	return temp.join('/');
}

for (var i = 0; i < count; i++) {
	command = readline().split(' ');
	if (command[0] === 'pwd') {
		paths[i] = path;
	} else {
		temp = command[1].split('/');
		if (temp[0]) {
			path += command[1] + '/';
			path = filterDoublePoint(path.split('/'));
		} else {
			path = command[1] + '/';
			path = filterDoublePoint(path.split('/'));
		}
	}
}

for (var i = 0, len = paths.length; i < len; i++) {
	print(paths[i]);
}

var count = +readline(),
	command,
	temp,
	paths = [],
	path = '/';

function filterDoublePoint(temp) {
	for (var i = 0, len = temp.length; i < len; i++) {
		if (temp[i] === '..') {
			temp.splice(i - 1, 2);
			i -= 2;
		}
	}
	return temp.join('/') + '/';
}

for (var i = 0; i < count; i++) {
	command = readline().split(' ');
	if (command[0] === 'pwd') {
		paths[i] = path;
	} else {
		temp = command[1].split('/');
		if (temp[0]) {
			path += command[1] + '/';
			path = filterDoublePoint(path.split('/'));
		} else {
			path = command[1] + '/';
			path = filterDoublePoint(path.split('/'));
		}
	}
}

for (var i = 0, len = paths.length; i < len; i++) {
	print(paths[i]);
}


You are given a string $$$s$$$, consisting of $$$n$$$ letters, each letter is either 'a' or 'b'. The letters in the string are numbered from $$$1$$$ to $$$n$$$.$$$s[l; r]$$$ is a continuous substring of letters from index $$$l$$$ to $$$r$$$ of the string inclusive. A string is called balanced if the number of letters 'a' in it is equal to the number of letters 'b'. For example, strings "baba" and "aabbab" are balanced and strings "aaab" and "b" are not.Find any non-empty balanced substring $$$s[l; r]$$$ of string $$$s$$$. Print its $$$l$$$ and $$$r$$$ ($$$1 \le l \le r \le n$$$). If there is no such substring, then print $$$-1$$$ $$$-1$$$.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of the testcase contains a single integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of the string. The second line of the testcase contains a string $$$s$$$, consisting of $$$n$$$ letters, each letter is either 'a' or 'b'.

For each testcase print two integers. If there exists a non-empty balanced substring $$$s[l; r]$$$, then print $$$l$$$ $$$r$$$ ($$$1 \le l \le r \le n$$$). Otherwise, print $$$-1$$$ $$$-1$$$.

NoteIn the first testcase there are no non-empty balanced subtrings.In the second and third testcases there are multiple balanced substrings, including the entire string "abbaba" and substring "baba".

var t = readline();
for (var i = 0; i < t; ++i) {
  var n = readline(),
    input = readline().split("") , counter = 1;
    for(var j = 0 ; j < n - 1 ; ++j){
        if(input[j] != input[j + 1]){
            print(parseInt(input.indexOf(input[j]) + 1) + ' ' + parseInt(input.indexOf(input[j + 1]) + 1));
            break;
        }
        else{
            input[j] = '';
            counter++;
        }
    }
    if(counter == n){
        print(`-1 -1`);
    }
}

const t = parseInt(readline());

for (var _ = 0; _ < t; _++) {
  var n = parseInt(readline());
  var s = readline();
  var l = s.indexOf('ab');

  if (l < 0)
    l = s.indexOf('ba');

  var r = l >= 0? l + 1: -1;

  if (l >= 0) {
    r++;
    l++;
  }

  print(l, r);
}

function run(){
    var n = readline();
    var s = readline();
    for(var i = 1; i < n; i++){
        if(s[i] != s[i - 1]){
            print(i, i + 1);
            return;
        }
    }
    print(-1, -1);
}

var tc = readline();
while(tc--) {
    run();
}

var t=+readline();
while(t--){
    var n=+readline();
    var s=readline();
    var flag=0;
    for(var i=0; i<n; i++){
        if(s[i]=='a' && s[i+1]=='b'){
            print(i+1,i+2);
            flag=1;
            break;
        }
        if(s[i]=='b' && s[i+1]=='a'){
            print(i+1, i+2);
            flag=1;
            break;
        }
    }
    if(flag===0){
        print(-1,-1);
    }

}

let q = '';
process.stdin.on('data', c => q += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = q.split(EOL);
    var t = lines[0];
    var e = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            e = lines[i];
        }else{
            var check = false;
            var n = lines[i].split('');
            if(e == 1){
                console.log(-1, -1);
            }else{
                for(j = 0; j < e-1; j++){
                    if(n[j] != n[j + 1]){
                        console.log(j + 1, j + 2);
                        check = true;
                        break;
                    }
                }
                if(!check){
                    console.log(-1, -1);
                }
            }
        }
    }
});

const readline = require('readline')

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

function solve(n, str) {
    const sum = []
    for (let i = 0; i < str.length; i++) {
        const [a, b] = i ? sum[i - 1] : [0, 0]
        if (str[i] === 'a') {
            sum[i] = [a + 1, b]
        } else {
            sum[i] = [a, b + 1]
        }
    }
    for (let i = 0; i < str.length; i++) {
        const [a1, b1] = i ? sum[i - 1] : [0, 0]
        for (let j = i; j < str.length; j++) {
            const [a2, b2] = sum[j]
            if (a2 - a1 === b2 - b1) return [i + 1, j + 1]
        }
    }
    return [-1, -1]
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = BigInt(next());
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());}
function 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();
	while(hasNext()){
		var N = nextInt();
		var S = next();
		var L = -1;
		var R = -1;
		for(var i = 0; i < N; i++){
			for(var j = i; j < N; j++){
				var AC = 0;
				var BC = 0;
				for(var k = i; k <= j; k++){
					if(S[k] == "a"){
						AC++;
					}else{
						BC++;
					}
				}
				if(AC == BC){
					L = i + 1;
					R = j + 1;
				}
			}
		}
		myout(L + " " + R);
	}
}

var t = readline();
for (var i = 0; i < t; ++i) {
  var n = readline(),
    input = readline().split("") , counter = 1;
    for(var j = 0 ; j < n - 1 ; ++j){
        if(input[j] != input[j + 1]){
            print(parseInt(input.indexOf(input[j]) + 1) + ' ' + parseInt(input.indexOf(input[j + 1]) + 1));
            break;
        }
        else{
            counter++;
        }
    }
    if(counter == n){
        print(`-1 -1`);
    }
}

var t = readline();
for (var i = 0; i < t; ++i) {
  var n = readline(),
    input = readline().split("") , counter = 1;
    for(var j = 0 ; j < n - 1 ; ++j){
        if(input[j] != input[j + 1]){
            print(input.indexOf(input[j]) + ' ' + input.indexOf(input[j + 1]));
            break;
        }
        else{
            counter++;
        }
    }
    if(counter == n){
        print(`-1 -1`);
    }
}

const t = parseInt(readline());

for (var _ = 0; _ < t; _++) {
  var n = parseInt(readline());
  var s = readline();
  var l = s.indexOf('ab');

  if (l < 0)
    l = s.indexOf('ba');

  var r = l >= 0? l + 1: -1;

  print(++l, ++r);
}

const t = parseInt(readline());

for (var _ = 0; _ < t; _++) {
  var n = parseInt(readline());
  var s = readline();
  var l = s.indexOf('ab');

  if (l < 0)
    l = s.indexOf('ba');

  var r = l >= 0? l + 1: -1;

  print(l, r);
}

let q = '';
process.stdin.on('data', c => q += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = q.split(EOL);
    var t = lines[0];
    var e = 0;
    for(i = 1; i <= t * 2; i++){
        var n = lines[i].split('');
        if(i % 2 == 1){
            e = n[0];
        }else{
            var check = false;
            if(e == 1){
                console.log(-1, -1);
            }else{
                for(j = 0; j < e-1; j++){
                    if(n[j] != n[j + 1]){
                        console.log(j + 1, j + 2);
                        check = true;
                        break;
                    }
                }
                if(!check){
                    console.log(-1, -1);
                }
            }
        }
    }
});

let q = '';
process.stdin.on('data', c => q += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = q.split(EOL);
    var t = lines[0];
    var e = 0;
    for(i = 1; i <= t * 2; i++){
        var n = lines[i].split(' ').map(Number);
        if(i % 2 == 1){
            e = n[0];
        }else{
            var check = false;
            if(e == 1){
                console.log(-1, -1);
            }else{
                for(j = 0; j < e-1; j++){
                    if(n[j] != n[j + 1]){
                        console.log(j + 1, j + 2);
                        check = true;
                        break;
                    }
                }
                if(!check){
                    console.log(-1, -1);
                }
            }
        }
    }
});

const readline = require('readline')

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

function solve(n, str) {
    const sum = []
    for (let i = 0; i < str.length; i++) {
        const [a, b] = i ? sum[i - 1] : [0, 0]
        if (str[i] === 'a') {
            sum[i] = [a + 1, b]
        } else {
            sum[i] = [a, b + 1]
        }
    }
    for (let i = 0; i < str.length; i++) {
        const [a1, b1] = i ? sum[i - 1] : [0, 0]
        for (let j = i; j < str.length; j++) {
            const [a2, b2] = sum[j]
            if (a2 - a1 === b2 - b1) return [i, j]
        }
    }
    return [-1, -1]
}


For the first place at the competition, Alex won many arrays of integers and was assured that these arrays are very expensive. After the award ceremony Alex decided to sell them. There is a rule in arrays pawnshop: you can sell array only if it can be compressed to a generator.This generator takes four non-negative numbers $$$n$$$, $$$m$$$, $$$c$$$, $$$s$$$. $$$n$$$ and $$$m$$$ must be positive, $$$s$$$ non-negative and for $$$c$$$ it must be true that $$$0 \leq c < m$$$. The array $$$a$$$ of length $$$n$$$ is created according to the following rules:   $$$a_1 = s \bmod m$$$, here $$$x \bmod y$$$ denotes remainder of the division of $$$x$$$ by $$$y$$$;  $$$a_i = (a_{i-1} + c) \bmod m$$$ for all $$$i$$$ such that $$$1 < i \le n$$$. For example, if $$$n = 5$$$, $$$m = 7$$$, $$$c = 4$$$, and $$$s = 10$$$, then $$$a = [3, 0, 4, 1, 5]$$$.Price of such an array is the value of $$$m$$$ in this generator.Alex has a question: how much money he can get for each of the arrays. Please, help him to understand for every array whether there exist four numbers $$$n$$$, $$$m$$$, $$$c$$$, $$$s$$$ that generate this array. If yes, then maximize $$$m$$$.

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of arrays. The first line of array description contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the size of this array. The second line of array description contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \leq a_i \leq 10^9$$$ ) — elements of the array.  It is guaranteed that the sum of array sizes does not exceed $$$10^5$$$.

For every array print:    $$$-1$$$, if there are no such four numbers that generate this array;  $$$0$$$, if $$$m$$$ can be arbitrary large;  the maximum value $$$m$$$ and any appropriate $$$c$$$ ($$$0 \leq c < m$$$) in other cases.

'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();
var mod = 998244353n
var maxN = 10e6 + 1

function main() {
  var x = parseInt(readline())
  //
  Array(parseInt(x)).fill(1).map((t, iii) => {
    var n = parseInt(readline())
    //   var a = new Array(n)
    //   var marked = new Array(n).fill(false)
    //   var found = new Array(n).fill(false)
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });

    var allEqual = true
    for (let i = 0; i < n - 1; i++) {
      if (a[i] !== a[i + 1]) allEqual = false
    }

    if (allEqual) return console.log(0)

    var diff = 0
    var diff1 = 0
    var first = true
    var first1 = true
    var isExist = true
    var isExist1 = true
    for (let i = 0; i < n - 1; i++) {
      if (a[i] < a[i + 1]) {
        if (first) {
          diff = a[i + 1] - a[i]
          first = false
          continue
        }
        if (a[i + 1] - a[i] !== diff) isExist = false
      } else {
        if (first1) {
          diff1 = a[i+1] - a[i]
          first1 = false
          continue
        }
        if (a[i+1] - a[i] !== diff1) isExist1 = false

      }
    }

    if (!isExist || !isExist1) return console.log(-1)

    var value = diff
    var mod1 = diff - diff1
    // console.log(mod1, diff, diff1)

    // check all raise
    var allRaise = true
    for (let i = 0; i < n - 1; i++) {
      if (a[i] + diff !== a[i + 1]) {
        allRaise = false
      }
    }
    if (allRaise) return console.log(0)
    // check all raise

    // check all raise
    var allDown = true
    for (let i = 0; i < n - 1; i++) {
      if (a[i] + diff1 !== a[i + 1]) {
        allDown = false
      }
    }
    if(allDown){
      console.log(0)
      return
    }
    // check all raise

// console.log(mod1, diff1, diff)
    var exist = true
    for (let i = 0; i < n - 1; i++) {
      if (a[i] >= mod1) exist = false
      if ((a[i] + value) % mod1 !== a[i + 1]) {
        exist = false
        // console.log(a[i], a[i+1])
      }
    }
    if (!exist) return console.log(-1)
    console.log(mod1, value)
  })
}

function find(value, a) {
  var l = -1
  var r = a.length
  while (r > l + 1) {
    var m = Math.floor((r + l) / 2)
    // console.log(a[m], f, l, r)
    if (a[m] <= value) l = m
    if (a[m] > value) r = m
  }
  return r
}

function getInt(num){
    return parseInt(num, 10)
}

var t = parseInt(readline(), 10);

for(var i = 0; i < t; i++){
    var line1 = readline().split(' ').map(getInt);
    var line2 = readline().split(' ').map(getInt);
    print(solution(line1[0], line2));
}
function solution(n, arr){
    if(n === 1){
        return 0;
    }
    if(isMInfinite(arr)){
        return 0;
    }
    var c;
    var j = 1;
    while(arr[j] < arr[j-1] && j < n){
        j++;
    }
    /*if(j === n){
        return -1;
    }*/
    c = arr[j] - arr[j-1];
    var k = 1;

    while(arr[k] > arr[k-1] && k < n){
        k++;
    }
    var m = c + arr[k-1] - arr[k];
    if(checkArr(arr,c,m, n)){
        return m + ' ' + c;
    }else{
        return -1;
    }

}
function isMInfinite(arr){
    var c = arr[1] - arr[0];

    return !arr.some(function(item, i){
        return (i && item - arr[i-1] !== c);
    })
}

function checkArr(arr,c,m, n){
    if(arr[0] >= m){
        return false;
    }
    for(var i = 1; i < n; i++){
        if(arr[i] !== (arr[i-1] + c) % m){
            return false;

        }
    }
    return true;
}

'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();
var mod = 998244353n
var maxN = 10e6 + 1

function main() {
  var x = parseInt(readline())
  //
  Array(parseInt(x)).fill(1).map((t, iii) => {
    var n = parseInt(readline())
    //   var a = new Array(n)
    //   var marked = new Array(n).fill(false)
    //   var found = new Array(n).fill(false)
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });

    var allEqual = true
    for (let i = 0; i < n - 1; i++) {
      if (a[i] !== a[i + 1]) allEqual = false
    }

    if (allEqual) return console.log(0)

    var diff = 0
    var diff1 = 0
    var first = true
    var first1 = true
    var isExist = true
    var isExist1 = true
    for (let i = 0; i < n - 1; i++) {
      if (a[i] < a[i + 1]) {
        if (first) {
          diff = a[i + 1] - a[i]
          first = false
          continue
        }
        if (a[i + 1] - a[i] !== diff) isExist = false
      } else {
        if (first1) {
          diff1 = a[i+1] - a[i]
          first1 = false
          continue
        }
        if (a[i+1] - a[i] !== diff1) isExist1 = false

      }
    }

    if (!isExist || !isExist1) return console.log(-1)

    var value = diff
    var mod1 = diff - diff1
    // console.log(mod1, diff, diff1)

    // check all raise
    var allRaise = true
    for (let i = 0; i < n - 1; i++) {
      if (a[i] + diff !== a[i + 1]) {
        allRaise = false
      }
    }
    if (allRaise) return console.log(0)
    // check all raise

    // check all raise
    var allDown = true
    for (let i = 0; i < n - 1; i++) {
      if (a[i] + diff1 !== a[i + 1]) {
        allDown = false
      }
    }
    if(allDown){
      console.log(a[0]+1, a[0]+1+diff1)
      return
    }
    // check all raise

    var exist = true
    for (let i = 0; i < n - 1; i++) {
      if (a[i] >= mod1) exist = false
      if ((a[i] + value) % mod1 !== a[i + 1]) {
        exist = false
        // console.log(a[i], a[i+1])
      }
    }
    if (!exist) return console.log(-1)
    console.log(mod1, value)
  })
}

function find(value, a) {
  var l = -1
  var r = a.length
  while (r > l + 1) {
    var m = Math.floor((r + l) / 2)
    // console.log(a[m], f, l, r)
    if (a[m] <= value) l = m
    if (a[m] > value) r = m
  }
  return r
}

'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();
var mod = 998244353n
var maxN = 10e6 + 1

function main() {
  var x = parseInt(readline())
  //
  Array(parseInt(x)).fill(1).map((t, iii) => {
    var n = parseInt(readline())
    //   var a = new Array(n)
    //   var marked = new Array(n).fill(false)
    //   var found = new Array(n).fill(false)
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });

    var allEqual = true
    for (let i = 0; i < n - 1; i++) {
      if (a[i] !== a[i + 1]) allEqual = false
    }

    if(allEqual) return  console.log(0)

    var diff
    var first= true
    var isExist = true
    for (let i = 0; i < n - 1; i++) {
      if (a[i] < a[i + 1]) {
        if(first){
          diff = a[i + 1] - a[i]
          first = false
          continue
        }
        if(a[i + 1] - a[i] !== diff) isExist = false
      }
    }
    var value = diff
    // console.log(diff)
    if (!isExist) return console.log(-1)

    // check all raise
    var allRaise = true
    for (let i = 0; i < n-1; i++) {
      if (a[i] + value !== a[i + 1]) {
        allRaise = false
      }
    }
    if (allRaise) return console.log(0)

    var mod1 = -1
    for (let i = 0; i < n - 1; i++) {
      if (a[i] > a[i + 1]) mod1 = a[i] + value - a[i+1]
    }

    var exist = true
    for (let i = 0; i < n-1; i++) {
      if(a[i] >= mod1) exist = false
      if ((a[i] + value) % mod1 !== a[i + 1]) {
        exist = false
        // console.log(a[i], a[i+1])
      }
    }
    if (!exist) return console.log(-1)
    console.log(mod1, value)
  })
}

function find(value, a) {
  var l = -1
  var r = a.length
  while (r > l + 1) {
    var m = Math.floor((r + l) / 2)
    // console.log(a[m], f, l, r)
    if (a[m] <= value) l = m
    if (a[m] > value) r = m
  }
  return r
}

'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();
var mod = 998244353n
var maxN = 10e6 + 1

function main() {
  var x = parseInt(readline())
  //
  Array(parseInt(x)).fill(1).map((t, iii) => {
    var n = parseInt(readline())
    //   var a = new Array(n)
    //   var marked = new Array(n).fill(false)
    //   var found = new Array(n).fill(false)
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });

    var allEqual = true
    for (let i = 0; i < n - 1; i++) {
      if (a[i] !== a[i + 1]) allEqual = false
    }

    if(allEqual) return  console.log(0)

    var diff
    var first= true
    var isExist = true
    for (let i = 0; i < n - 1; i++) {
      if (a[i] < a[i + 1]) {
        if(first){
          diff = a[i + 1] - a[i]
          first = false
          continue
        }
        if(a[i + 1] - a[i] !== diff) isExist = false
      }
    }
    var value = diff
    // console.log(diff)
    if (!isExist) return console.log(-1)

    var mod1
    for (let i = 0; i < n - 1; i++) {
      if (a[i] > a[i + 1]) mod1 = a[i] + value - a[i+1]
    }

    var exist = true
    for (let i = 0; i < n-1; i++) {
      if(a[i] >= mod1) exist = false
      if ((a[i] + value) % mod1 !== a[i + 1]) {
        exist = false
        // console.log(a[i], a[i+1])
      }
    }
    if (!exist) return console.log(-1)
    console.log(mod1, value)
  })
}

function find(value, a) {
  var l = -1
  var r = a.length
  while (r > l + 1) {
    var m = Math.floor((r + l) / 2)
    // console.log(a[m], f, l, r)
    if (a[m] <= value) l = m
    if (a[m] > value) r = m
  }
  return r
}

function solution(n, arr){
    if(n === 1){
        return 0;
    }
    if(isMInfinite(arr)){
        return 0;
    }
    var c;
    var j = 1;
    while(arr[j] < arr[j-1] && j < n){
        j++;
    }
    c = arr[j] - arr[j-1];
    var k = 1;

    while(arr[k] > arr[k-1] && k < n){
        k++;
    }
    var m = c + arr[k-1] - arr[k];
    if(checkArr(arr,c,m, n)){
        return m + ' ' + c;
    }else{
        return -1;
    }

}
function isMInfinite(arr){
    var c = arr[1] - arr[0];

    return !arr.some(function(item, i){
        return (i && item - arr[i-1] !== c);
    })
}

function checkArr(arr,c,m, n){
    if(arr[0] >= m){
        return false;
    }
    for(var i = 1; i < n; i++){
        if(arr[i] !== (arr[i-1] + c) % m){
            return false;

        }
    }
    return true;
}


Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems, A, B, C, D and E. For each of these problem, depending on when the given problem was solved and whether it was solved at all, the participants receive some points. Besides, a contestant can perform hacks on other contestants. For each successful hack a contestant earns 100 points, for each unsuccessful hack a contestant loses 50 points. The number of points for every contestant is represented by the sum of points he has received from all his problems, including hacks.You are suggested to determine the leader for some room; the leader is a participant who has maximum points.

The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessful hacks and the number of points he has received from problems A, B, C, D, E correspondingly. The handle of each participant consists of Latin letters, digits and underscores and has the length from 1 to 20 characters. There are the following limitations imposed upon the numbers:    0 ≤ plusi, minusi ≤ 50;  150 ≤ ai ≤ 500 or ai = 0, if problem A is not solved;  300 ≤ bi ≤ 1000 or bi = 0, if problem B is not solved;  450 ≤ ci ≤ 1500 or ci = 0, if problem C is not solved;  600 ≤ di ≤ 2000 or di = 0, if problem D is not solved;  750 ≤ ei ≤ 2500 or ei = 0, if problem E is not solved.  All the numbers are integer. All the participants have different handles. It is guaranteed that there is exactly one leader in the room (i.e. there are no two participants with the maximal number of points).

Print on the single line the handle of the room leader.

NoteThe number of points that each participant from the example earns, are as follows:   Petr — 3860  tourist — 4140  Egor — 4030  c00lH4x0R —  - 350  some_participant — 2220 Thus, the leader of the room is tourist.

'use strict'

const {EOL} = require('os')

let ipt = ''
process.stdin.on('data', s => ipt += s)
process.stdin.on('end', () => {
  const ils = ipt.split(EOL).slice(1, -1).map(l => l.split(' '))
  console.log(ils.map(([n, s, f, a, b, c, d, e]) => [
      n,
      s * 100 - f * 50 + +a + +b + +c + +d + +e
    ]).reduce((l, u) => u[1] > l[1] ? u : l)[0]
  )
})