Being tired of participating in too many Codeforces rounds, Gildong decided to take some rest in a park. He sat down on a bench, and soon he found two rabbits hopping around. One of the rabbits was taller than the other.He noticed that the two rabbits were hopping towards each other. The positions of the two rabbits can be represented as integer coordinates on a horizontal line. The taller rabbit is currently on position $$$x$$$, and the shorter rabbit is currently on position $$$y$$$ ($$$x \lt y$$$). Every second, each rabbit hops to another position. The taller rabbit hops to the positive direction by $$$a$$$, and the shorter rabbit hops to the negative direction by $$$b$$$.  For example, let's say $$$x=0$$$, $$$y=10$$$, $$$a=2$$$, and $$$b=3$$$. At the $$$1$$$-st second, each rabbit will be at position $$$2$$$ and $$$7$$$. At the $$$2$$$-nd second, both rabbits will be at position $$$4$$$.Gildong is now wondering: Will the two rabbits be at the same position at the same moment? If so, how long will it take? Let's find a moment in time (in seconds) after which the rabbits will be at the same point.

Each test contains one or more test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Each test case contains exactly one line. The line consists of four integers $$$x$$$, $$$y$$$, $$$a$$$, $$$b$$$ ($$$0 \le x \lt y \le 10^9$$$, $$$1 \le a,b \le 10^9$$$) — the current position of the taller rabbit, the current position of the shorter rabbit, the hopping distance of the taller rabbit, and the hopping distance of the shorter rabbit, respectively.

For each test case, print the single integer: number of seconds the two rabbits will take to be at the same position. If the two rabbits will never be at the same position simultaneously, print $$$-1$$$.

NoteThe first case is explained in the description.In the second case, each rabbit will be at position $$$3$$$ and $$$7$$$ respectively at the $$$1$$$-st second. But in the $$$2$$$-nd second they will be at $$$6$$$ and $$$4$$$ respectively, and we can see that they will never be at the same position since the distance between the two rabbits will only increase afterward.

var tests = parseInt(readline())
for (var i = 0; i < tests; i++){
    var interim = readline().split(' ').map((val)=>{
        return parseInt(val);
        })
    var res = (interim[1] - interim[0])/(interim[2]+interim[3])
    print(Number.isInteger(res) ? res : -1)
}

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main() {
  var t = myconv(next(),1);
  var output = new Array(t);
  for(var i = 0; i < t; i++){
      var tmp = myconv(next(),4);
      var x = tmp[0];
      var y = tmp[1];
      var a = tmp[2];
      var b = tmp[3];
      if((y - x) % (a + b) == 0){
          output[i] = (y - x) / (a + b);
      }else{
          output[i] = "-1";
      }
  }
  myout(myconv(output,9));
}

var t = parseInt(readline());

while(t--)
{
    var input = readline().split(" ").map(function(x) { return parseInt(x); });
    var x = input[0];
    var y = input[1];
    var a = input[2];
    var b = input[3];

    var xy = Math.abs(x - y);
    var ab = a + b;
    if (xy % ab == 0)
        print(xy / ab);
    else
        print(-1);
}

var z = parseInt(readline());

var a;
var b;
var c;
var d;

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

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

    a = parseInt(l[0]);
    b = parseInt(l[1]);
    c = parseInt(l[2]);
    d = parseInt(l[3]);

    if(Math.floor((b-a)/(c+d)) === (b-a)/(c+d)){
        print((b-a)/(c+d));
    }
    else{
        print(-1);
    }
}

const main = (data) => {
  const n = data[0];

  for (let i = 1; i <= n; i++) {
    const [x, y, a, b] = data[i].split(' ').map(x => +x);

    if (Math.abs(x - y) % (a + b) == 0) {
      console.log(Math.abs(x - y) / (a + b));
    } else {
      console.log(-1);
    }
  }
};

let data = '';

process.stdin.on('data', input => data += input);
process.stdin.on('end', () => {
  data = data.split('\n');

  main(data);
});

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

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

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

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

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

function readInt(a, i) {
  if(i === undefined) return parseInt(a.shift())
  else return parseInt(a[i])
}

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

function main(input) {
  let ptr = 0
  let t = readInt(input, ptr++)
  while(t--) {
    const [x, y, a, b] = readInts(input, ptr++)
    if((y - x) % (a + b) === 0) wr((y - x) / (a + b))
    else wr( -1)

  }
}

// https://codeforces.com/problemset/problem/1304/A
"use strict";

// Interface of codeforces.com
const readline = require("readline");
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});
let n = NaN;
let input = [];
rl.on("line", line => {
  let output = NaN;
  input = line.split(" ").map(x => parseInt(x));
  if (isNaN(n)) {
    n = input[0];
  } else {
    output = solution(input);
    console.log(output);
  }
});
rl.on("close", () => {
  // console.log(input)
});
// End of interface
const solution = function(inputs) {
  let x = inputs[0];
  let y = inputs[1];
  let a = inputs[2];
  let b = inputs[3];

  let distance = y - x;
  let steps = a + b;
  if (distance % steps == 0) {
    return distance / steps;
  } else {
    return -1;
  }
};

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

  let [x, y, a, b] = d.split(' ').map(Number);
  let n = Math.abs(x - y);
  let ans = n % (a + b) ? -1 : n / (a + b);

  console.log(ans);

  c++;
});

/**
 * @author Sunwarul Islam
 * JavaScript Developer
*/
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStd => {
    inputString += inputStd;
});
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(str => {
        return str.trim();
    });
    main();
});

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

function main() {
    const t = +(readLine());
    for (let i = 0; i < t; i++) {
        const arr = readLine().split(' ').map(Number);
        const [x, y, a, b] = arr;
        const diff = y - x;
        const total = a + b;
        if (diff % total !== 0) {
            console.log('-1');
        } else {
            console.log(diff / total);
        }
    }
}

var data = "";

process.stdin.on("data", x => data += x);

// process.on("SIGINT", () => {
process.stdin.on("end", () => {

	var eol = data.indexOf("\r") ? (data.indexOf("\n") ? "\r\n" : "\r") : "\n";

	var lines = data.split(eol);

	var n = +lines.shift();

	for(let i = 0; i < n; i++) {

		var arr = [];
		var l = f.length;
		for(let ii = 0; ii < l; ii++) arr.push(lines[l*i+ii]);
		f.apply({}, arr);
	}

	process.exit(0);
});

function f(c) {

	var [x, y, a, b] = c.split(" ").map(x => +x);
	var val = (y-x)/(a+b);
	console.log(Number.isInteger(val) ? val : -1);
}

var data = "";

process.stdin.on("data", x => data += x);

// process.on("SIGINT", () => {
process.stdin.on("end", () => {

    var eol = data.indexOf("\r")+1 ? (data.indexOf("\n")+1 ? "\r\n" : "\r") : "\n";

    var lines = data.split(eol);

    var n = +lines.shift().split(" ")[0];

    if(lines[lines.length-1] == "") lines.pop();

    for(let i = 0; i < n; i++) {

        var arr = [];
        var l = f.length;
        for(let ii = 0; ii < l; ii++) arr.push(lines[l*i+ii]);
        if(!l) {
            arr = lines;
            i = n;
        }
        f.apply({}, arr);
    }

	console.log(ans);

    process.exit(0);
});

var ans = "";

function f(c) {
	var [x, y, a, b] = c.split(" ").map(x => +x);
	var val = (y-x)/(a+b);
	ans += (Number.isInteger(val) ? val : -1) + " ";
}

var data = "";

process.stdin.on("data", x => data += x);

// process.on("SIGINT", () => {
process.stdin.on("end", () => {

    var eol = data.indexOf("\r")+1 ? (data.indexOf("\n")+1 ? "\r\n" : "\r") : "\n";

    var lines = data.split(eol);

    var n = +lines.shift().split(" ")[0];

    if(lines[lines.length-1] == "") lines.pop();

    for(let i = 0; i < n; i++) {

        var arr = [];
        var l = f.length;
        for(let ii = 0; ii < l; ii++) arr.push(lines[l*i+ii]);
        if(!l) {
            arr = lines;
            i = n;
        }
        f.apply({}, arr);
    }

    process.exit(0);
});

function f(c) {
	var [x, y, a, b] = c.split(" ").map(x => +x);
	var val = (y-x)/(a+b);
	console.log(Number.isInteger(val) ? val : -1);
}

let fs = require('fs');

let txt = fs.readFileSync(0, "utf-8").split(/[\r\n]/).filter(data => data.length > 0);
txt.shift()

for (let i = 0; i < txt.length; i++) {
    doit(...txt[i].split(" ").filter(data=>data.length>0).map(data=>data*1))

}

function doit(x,y,a,b) {
    let r=(y-x)/(a+b);

    if(r==Math.floor(r)){
        console.log(r);

    }else{
        console.log(-1);

    }

}

var data = "";

process.stdin.on("data", x => data += x);

// process.on("SIGINT", () => {
process.stdin.on("end", () => {

    var eol = data.indexOf("\r")+1 ? (data.indexOf("\n")+1 ? "\r\n" : "\r") : "\n";

    var lines = data.split(eol);

    var n = +lines.shift().split(" ")[0];

    if(lines[lines.length-1] == "") lines.pop();

    for(let i = 0; i < n; i++) {

        var arr = [];
        var l = f.length;
        for(let ii = 0; ii < l; ii++) arr.push(lines[l*i+ii]);
        if(!l) {
            arr = lines;
            i = n;
        }
        f.apply({}, arr);
    }

	console.log(ans);

    process.exit(0);
});

var ans = "";

function f(c) {
	var [x, y, a, b] = c.split(" ").map(x => +x);
	var val = (y-x)/(a+b);
	ans += Number.isInteger(val) ? val : -1 + " ";
}


You are given a bracket sequence consisting of $$$n$$$ characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.The prefix is considered good if one of the following two conditions is satisfied:  this prefix is a regular bracket sequence;  this prefix is a palindrome of length at least two. A bracket sequence is called regular if it is possible to obtain a correct arithmetic expression by inserting characters '+' and '1' into this sequence. For example, sequences (())(), () and (()(())) are regular, while )(, (() and (()))( are not.The bracket sequence is called palindrome if it reads the same back and forth. For example, the bracket sequences )), (( and )(() are palindromes, while bracket sequences (), )( and ))( are not palindromes.You stop performing the operations when it's not possible to find a good prefix. Your task is to find the number of operations you will perform on the given string and the number of remaining characters in the string.You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the length of the bracket sequence. The second line of the test case contains $$$n$$$ characters '(' and/or ')' — the bracket sequence itself. It is guaranteed that the sum of $$$n$$$ over all test cases do not exceed $$$5 \cdot 10^5$$$ ($$$\sum n \le 5 \cdot 10^5$$$).

For each test case, print two integers $$$c$$$ and $$$r$$$ — the number of operations you will perform on the given bracket sequence and the number of characters that remain in the string after performing all operations.

"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());
    let arr = readline().trim();
    const checkPalindrome = (start, end, str) => {
      let i = start,
        j = end;
      while (i <= j) {
        if (str[i] !== str[j]) return false;
        i++;
        j--;
      }
      return true;
    };
    let i = 0,
      j = i + 1,
      cnt = 0;
    while (i + 1 < n) {
      if (arr[i] === "(") {
        cnt++;
        i += 2;
        j = i + 1;
      } else {
        while (arr[i] !== arr[j] && j < n) j++;
        if (j > n) break;
        else {
          if (checkPalindrome(i, j, arr)) {
            i = j + 1;
            j = i + 1;
            cnt++;
          } else j++;
        }
      }
    }
    if (i === n) console.log(`${cnt} ${0}`);
    else if (i === n - 1) console.log(`${cnt} ${1}`);
    else console.log(`${cnt} ${n - i}`);
  }
};
solve();

const readline = require('readline')

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

function solve(n, str) {
    let i = 0
    let op = 0
    while (i < n) {
        if (str[i] === '(') {
            if (i + 1 < n) {
                op++
                i += 2
            } else {
                break
            }
        } else {
            let j = i + 1
            while (j < n && str[j] === '(') j++
            if (j < n) {
                op++
                i = j + 1
            } else {
                break
            }
        }
    }
    return op + ' ' + (n - i)
}

'use strict'; /*jslint node:true, browser:true, es6:true*/
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
const print = console.log
const lines = []
rl.on('line', line => {
    lines.push(line);
});
rl.on('close', main)
let rli = 0;
function readline() {
    return lines[rli++];
}
const EPS = 1e-6;

function is_polindrom(s, from, to){
  while (from<to && s[from]==s[to]){
    to--;
    from++;
  }
  return from>=to;
}
function is_formula(s, from, to){
  let cnt = 0;
  for (;from<=to; from++){
    if (s[from]=='(')
      cnt++;
      else
      cnt--;
    if (cnt<0)
      return false;
  }
  return cnt==0;
}

function is_good(s, from, to){
  if (is_polindrom(s, from, to))
    return true;
  if (is_formula(s, from, to))
    return true;
}

function calc(s){
  let cnt = 0, remaining = 0;
  let start = 0;
  while (start<s.length){
    let was_good;
    for (let i=2; start+i-1<s.length; i++){
      if (is_good(s, start, start+i-1)){
        was_good = true;
        start = start+i;
        break;
      }
    }
    if (!was_good){
      remaining = s.length-start;
      break;
    }
    cnt++;
  }
  print(cnt, remaining)
}

function main() {
    let T = +readline();
    while (T--){
      let n = +readline();
      let str = readline();
      calc(str)
    }
}

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    var n = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            n = lines[i];
        }else{
            var k = lines[i].split('');
            var a = 0, b = 0;
            for(j = 1; j < n; j++){
                if(k[b] == '(' && k[j] == ')' || k[b] == k[j]){
                    j++, a++;
                    b = j;
                }
            }
            console.log(a, n - b);
        }
    }
});

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++];
}

/***
Educational Codeforces Round 125 (Div. 2)
2022-03-22

C. Bracket Sequence Deletion
***/

function main() {
  // INPUT: Number of test cases
  let t = readline();
  t = parseInt(t);
  let l, seq;
  for (let i = 0; i < t; i++) {
    // INPUT: the length of the bracket sequence
    l = readline();
    l = parseInt(l);
    // INPUT: the bracket sequence
    seq = readline();

    // # of operations doable (we can greed this one)
    let numOps = 0;
    // position pointers
    let start = 0;
    let end = 1; // semi-open interval
    while (end <= l) {
      const curSeq = seq.slice(start, end);
      if (isRegular(curSeq) || isPalindromic(curSeq)) {
        numOps++;
        start = end;
      }
      end++;
    }
    console.log(numOps + ' ' + (end - start - 1));
  }
}

function isRegular(seq) {
  let open = 0;
  for (let i = 0; i < seq.length; i++) {
    if (seq.charAt(i) === '(') {
      open++;
    } else {
      open--;
      if (open < 0) {
        return false;
      }
    }
  }
  return open === 0;
}

function isPalindromic(seq) {
  for (let i = 0; i < seq.length/2; i++) {
    if (seq.charAt(i) !== seq.charAt(seq.length - i - 1)) {
      return false;
    }
  }
  return seq.length >= 2;
}

var repeatTimes = readline();

while (repeatTimes--) {
    var n = readline()
    var s = readline()
    var oper = 0
    for (var i = 0; i < s.length; i++) {
        if ((s[0] === '(') && (s[1] === ')')) {
            s = s.slice(2)
            i = 0
            oper++
        } else if ((s[i] == s[0]) && (i !== 0)) {
            s = s.slice(i + 1)
            i = 0
            oper++
        }
    }

    print(oper, ' ', s.length)
}

"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());
    let arr = readline().trim();
    const checkPalindrome = (start, end, str) => {
      let i = 0,
        j = end;
      while (i <= j) {
        if (str[i] !== str[j]) return false;
        i++;
        j--;
      }
      return true;
    };
    let i = 0,
      j = i + 1,
      cnt = 0;
    while (i + 1 < n) {
      if (arr[i] === "(") {
        cnt++;
        i += 2;
        j = i + 1;
      } else {
        while (arr[i] !== arr[j] && j < n) j++;
        if (j > n) break;
        else {
          if (checkPalindrome(i, j, arr)) {
            i = j + 1;
            j = i + 1;
            cnt++;
          } else j++;
        }
      }
    }
    if (i === n) console.log(`${cnt} ${0}`);
    else if (i === n - 1) console.log(`${cnt} ${1}`);
    else console.log(`${cnt} ${n - i}`);
  }
};
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());
    let arr = readline().trim();
    const checkPalindrome = (start, end, str) => {
      let i = 0,
        j = end;
      while (i <= j) {
        if (str[i] !== str[j]) return false;
        i++;
        j--;
      }
      return true;
    };
    let i = 0,
      j = n - 1,
      cnt = 0;
    while (i + 1 < n) {
      if (arr[i] === "(") {
        cnt++;
        i += 2;
      } else {
        while (arr[i] !== arr[j]) j--;
        if (i !== j) {
          if (checkPalindrome(i, j, arr)) {
            i = j + 1;
            j = n - 1;
            cnt++;
          } else j--;
        } else break;
      }
    }
    if (i === n) console.log(`${cnt} ${0}`);
    else if (i === n - 1) console.log(`${cnt} ${1}`);
    else console.log(`${cnt} ${n - i}`);
  }
};
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());
    let arr = readline().trim();
    const checkPalindrome = (start, end, str) => {
      let i = 0,
        j = end;
      while (i <= j) {
        if (str[i] !== str[j]) return false;
        i++;
        j--;
      }
      return true;
    };
    const checkValid = (start, end, str) => {
      let o = 0,
        c = 0;
      while (start <= end) {
        if (str[start] === "(") o++;
        else c++;
        if (c > o) return false;
        start++;
      }
      if (o === c) return true;
    };
    let i = 0,
      j = n - 1,
      len = n,
      cnt = 0;

    while (i < j) {
      if (arr[i] === arr[j]) {
        if (checkPalindrome(i, j, arr)) {
          i = j + 1;
          j = n - 1;
          if (i > j) len = 0;
          else if (i === j) len = 1;
          else len = j - i + 1;
          cnt++;
          continue;
        }
      } else if (arr[i] === "(" && arr[j] === ")") {
        if (checkValid(i, j, arr)) {
          i = j + 1;
          j = n - 1;
          if (i > j) len = 0;
          else if (i === j) len = 1;
          else len = j - i + 1;
          cnt++;
          continue;
        }
      }
      j--;
    }
    console.log(`${cnt} ${len}`);
  }
};
solve();

const readline = require('readline')

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

function solve(n, str) {
    let i = 0
    let op = 0
    while (i < n) {
        let j = i
        let level = 0
        let fa = false
        while (j < n) {
            if (str[j] === '(') {
                level++
            } else {
                level--
            }
            if (level < 0) break
            if (!level) {
                fa = true
                break
            }
            j++
        }
        const a = fa ? j : i
        //
        j = i + 1
        let fb = false
        while (j < n) {
            if (isp(str, i, j)) {
                fb = true
                break
            }
            j++
        }
        const b = fb ? j : i
        j = Math.max(a, b)
    // console.log(a, b)
        if (i === j) break
        op++
        i = j + 1
    }
    return op + ' ' + (n - i)
}
function isp(str, i, j) {
    while (i < j) {
        if (str[i] !== str[j]) return false
        i++
        j--
    }
    return true
}

'use strict'; /*jslint node:true, browser:true, es6:true*/
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
const print = console.log
const lines = []
rl.on('line', line => {
    lines.push(line);
});
rl.on('close', main)
let rli = 0;
function readline() {
    return lines[rli++];
}
const EPS = 1e-6;

function is_polindrom(s, from, to){
  while (from<to && s[from]==s[to]){
    to--;
    from++;
  }
  return from>=to;
}
function is_formula(s, from, to){
  let cnt = 0;
  for (;from<=to; from++){
    if (s[from]=='(')
      cnt++;
      else
      cnt--;
    if (cnt<0)
      return false;
  }
  return cnt==0;
}

function is_good(s, from, to){
  if (is_polindrom(s, from, to))
    return true;
  if (is_formula(s, from, to))
    return true;
}

function calc(s){
  let cnt = 0, remaining = 0;
  let start = 0;
  while (start<s.length){
    let was_good;
    for (let i=2; start+i-1<s.length; i++){
      if (is_good(s, start, start+i-1)){
        was_good = true;
        start = start+i;
        break;
      }
    }
    if (!was_good){
      remaining = s.length-start;
      break;
    }
    cnt++;
  }
  print(cnt, remaining)
}

function main() {
    let T = +readline()[0];
    while (T--){
      let n = +readline()[0];
      let str = readline();
      calc(str)
    }
}


Polycarp started working at a bank. He was assigned to monitor the ATM. The ATM initially contains $$$s$$$ rubles.A queue of $$$n$$$ students lined up to him. Each student wants to either withdraw a certain amount of money or deposit it into an account. If $$$a_i$$$ is positive, then the student credits that amount of money via ATM. Otherwise, the student withdraws $$$|a_i|$$$ rubles.In the beginning, the ATM is turned off and an arbitrary number of students are not served. At some point, Polycarp turns on the ATM, which has an initial amount of $$$s$$$ rubles. Then, the remaining students start queueing at the ATM. If at some point in time there is less money in the ATM than the student wants to withdraw, then the student is not served and Polycarp turns off the ATM and does not turn it on anymore.More formally, the students that are served are forming a contiguous subsequence.Polycarp wants the ATM to serve the maximum number of students. Help him in this matter. Print the numbers of the first and last student, or determine that he will not be able to serve anyone.In other words, find such a longest continuous segment of students that, starting with the sum of $$$s$$$ at the ATM, all these students will be served. ATM serves students consistently (i.e. one after another in the order of the queue).

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Each test case consists of two lines. The first one contains integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 2\cdot10^5$$$; $$$0 \le s \le 10^9$$$) — the length of the $$$a$$$ array and the initial amount of rubles in the ATM. The second contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$) — elements of the $$$a$$$ array. Note that $$$a_i$$$ can be zero. It is guaranteed that the sum of the values $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$.

Print $$$t$$$ lines, each line must contain the answer to the corresponding set of input data: if the answer exists, print the numbers of the first and last served student. If there is no solution, then print -1 on the line. If there are several possible answers, print any.

NoteIn the first test case, the only correct answer is 2 4, since when serving students, the number of rubles at the ATM does not become negative, and this is the maximum number of students that can be served.In the second test case, the answer is -1, as there is not enough money for any student at the ATM.In the third test case, the answer can be either 1 2 or 4 5.

const readline = require('readline')

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

function solve(n, s, arr) {
    let now = 0
    const sum = Array(n)
    arr.forEach((x, i) => {
        now += x
        sum[i] = now
    })
    let max = 0
    let ans = 0
    let i = 0
    let j = 0
    while (j < n) {
        while (i <= j && s + sum[j] - (sum[i - 1] || 0) < 0) i++
        const len = j - i + 1
        if (len > max) {
            max = len
            ans = [i + 1, j + 1]
        }
        j++
    }
    return ans ? ans.join(' ') : -1
}


NIT, the cleaver, is new in town! Thousands of people line up to orz him. To keep his orzers entertained, NIT decided to let them solve the following problem related to $$$\operatorname{or} z$$$. Can you solve this problem too?You are given a 1-indexed array of $$$n$$$ integers, $$$a$$$, and an integer $$$z$$$. You can do the following operation any number (possibly zero) of times:  Select a positive integer $$$i$$$ such that $$$1\le i\le n$$$. Then, simutaneously set $$$a_i$$$ to $$$(a_i\operatorname{or} z)$$$ and set $$$z$$$ to $$$(a_i\operatorname{and} z)$$$. In other words, let $$$x$$$ and $$$y$$$ respectively be the current values of $$$a_i$$$ and $$$z$$$. Then set $$$a_i$$$ to $$$(x\operatorname{or}y)$$$ and set $$$z$$$ to $$$(x\operatorname{and}y)$$$. Here $$$\operatorname{or}$$$ and $$$\operatorname{and}$$$ denote the bitwise operations OR and AND respectively.Find the maximum possible value of the maximum value in $$$a$$$ after any number (possibly zero) of operations.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$z$$$ ($$$1\le n\le 2000$$$, $$$0\le z<2^{30}$$$). The second line of each test case contains $$$n$$$ integers $$$a_1$$$,$$$a_2$$$,$$$\ldots$$$,$$$a_n$$$ ($$$0\le a_i<2^{30}$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^4$$$.

For each test case, print one integer — the answer to the problem.

NoteIn the first test case of the sample, one optimal sequence of operations is:  Do the operation with $$$i=1$$$. Now $$$a_1$$$ becomes $$$(3\operatorname{or}3)=3$$$ and $$$z$$$ becomes $$$(3\operatorname{and}3)=3$$$.  Do the operation with $$$i=2$$$. Now $$$a_2$$$ becomes $$$(4\operatorname{or}3)=7$$$ and $$$z$$$ becomes $$$(4\operatorname{and}3)=0$$$.  Do the operation with $$$i=1$$$. Now $$$a_1$$$ becomes $$$(3\operatorname{or}0)=3$$$ and $$$z$$$ becomes $$$(3\operatorname{and}0)=0$$$. After these operations, the sequence $$$a$$$ becomes $$$[3,7]$$$, and the maximum value in it is $$$7$$$. We can prove that the maximum value in $$$a$$$ can never exceed $$$7$$$, so the answer is $$$7$$$.In the fourth test case of the sample, one optimal sequence of operations is:  Do the operation with $$$i=1$$$. Now $$$a_1$$$ becomes $$$(7\operatorname{or}7)=7$$$ and $$$z$$$ becomes $$$(7\operatorname{and}7)=7$$$.  Do the operation with $$$i=3$$$. Now $$$a_3$$$ becomes $$$(30\operatorname{or}7)=31$$$ and $$$z$$$ becomes $$$(30\operatorname{and}7)=6$$$.  Do the operation with $$$i=5$$$. Now $$$a_5$$$ becomes $$$(27\operatorname{or}6)=31$$$ and $$$z$$$ becomes $$$(27\operatorname{and}6)=2$$$.

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

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

  /**
   * readNumber()        - int
   * readArray()         - generic space separated array
   * readBoolean()       - bool
   * readChar()          - char
   * readLine()          - string
   * readNumberArray()   - numeric array
   */

  /** Code Starts */

  const solve = () => {
    const [n, z] = inputReader.readNumberArray();
    const arr = inputReader.readNumberArray();
    let res = 0;

    for (let el of arr) res = Math.max(res, el | z);
    console.log(res);
  };

  let tc = inputReader.readNumber();
  for (let t = 0; t < tc; ++t) solve();

  /** Transliterate : cp-convert -s forces.js -d out.js */
}

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

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

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

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

  return {
    readNumber,
    readNumberArray,
  };
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

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

    for (let test = 0; test < N; test++) {
        let [n, z] = readline().split(' ').map(Number);
        let arr = readline().split(' ').map(Number);
        let max = -Infinity;
        for (let i = 0; i < arr.length; i++) {
            let r = arr[i] | z;
            if (r > max) {
                max = r;
            }
        }
        output(max);
    }
}

'use strict';

function solve(n, m, a) {
  let res = 0;
  for (let num of a) {
    res = Math.max(res, num | m);
  }
  return res;
}

async function main(read) {
  try {
    let t = Number(await read());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      const [n, m] = (await read()).split(' ').map(Number);
      const a = (await read()).split(' ').map(Number);
      res[i] = solve(n, m, a);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', async () => {
  inputs = str.split('\n').values();
  const output = await main(read);
  process.stdout.write(output);
});

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

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

var T = readline();
// var inf = 10000000000;
for(var qe=1;qe<=T;qe++) {
  var [n,z] = readline().split(' ').map((x) => parseInt(x));
  var a = readline().split(' ').map((x) => parseInt(x));
  var ans = 0;

  for(var i=0;i<n;i++) {
    for(var j=0;j<n;j++) {
      if(j != i) {
        ans = max(ans, a[i]|(a[j]&z))
      } else {
        ans = max(ans, a[i]|z);
      }
    }
  }
  // console.log(mx, a)
  if(n == 1) ans = a[0]|z;
  console.log(ans);
}

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

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

  /**
   * readNumber()        - int
   * readArray()         - generic space separated array
   * readBoolean()       - bool
   * readChar()          - char
   * readLine()          - string
   * readNumberArray()   - numeric array
   */

  /** Code Starts */

  const solve = () => {
    const [n, z] = inputReader.readNumberArray();
    const arr = inputReader.readNumberArray();
    let res = 0;

    for (let el of arr) res = Math.max(res, el | res);
    console.log(res);
  };

  let tc = inputReader.readNumber();
  for (let t = 0; t < tc; ++t) solve();

  /** Transliterate : cp-convert -s forces.js -d out.js */
}

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

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

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

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

  return {
    readNumber,
    readNumberArray,
  };
}


A remote island chain contains n islands, labeled 1 through n. Bidirectional bridges connect the islands to form a simple cycle — a bridge connects islands 1 and 2, islands 2 and 3, and so on, and additionally a bridge connects islands n and 1. The center of each island contains an identical pedestal, and all but one of the islands has a fragile, uniquely colored statue currently held on the pedestal. The remaining island holds only an empty pedestal.The islanders want to rearrange the statues in a new order. To do this, they repeat the following process: First, they choose an island directly adjacent to the island containing an empty pedestal. Then, they painstakingly carry the statue on this island across the adjoining bridge and place it on the empty pedestal.Determine if it is possible for the islanders to arrange the statues in the desired order.

The first line contains a single integer n (2 ≤ n ≤ 200 000) — the total number of islands. The second line contains n space-separated integers ai (0 ≤ ai ≤ n - 1) — the statue currently placed on the i-th island. If ai = 0, then the island has no statue. It is guaranteed that the ai are distinct. The third line contains n space-separated integers bi (0 ≤ bi ≤ n - 1) — the desired statues of the ith island. Once again, bi = 0 indicates the island desires no statue. It is guaranteed that the bi are distinct.

Print "YES" (without quotes) if the rearrangement can be done in the existing network, and "NO" otherwise.

NoteIn the first sample, the islanders can first move statue 1 from island 1 to island 2, then move statue 2 from island 3 to island 1, and finally move statue 1 from island 2 to island 3.In the second sample, the islanders can simply move statue 1 from island 1 to island 2.In the third sample, no sequence of movements results in the desired position.

function solve(x, y) {
  x = x.filter(function(input) { return input !== 0})
  y = y.filter(function(input) { return input !== 0})
  x = x.join('')
  y = y.join('')
  if((x + x).indexOf(y) > -1) return 'YES'
  return 'NO'
}

var numOfIslands = readline().split(" ").map(function(x) { return parseInt(x); })[0];
var current = readline().split(" ").map(function(x) { return parseInt(x); })
var desired = readline().split(" ").map(function(x) { return parseInt(x); })
print(solve(current, desired))

function solve(x, y) {
  x = x.join('').replace('0', '')
  y = y.join('').replace('0', '')
  if((x + x).indexOf(y) > -1) return 'YES'
  return 'NO'
}

var numOfIslands = readline().split(" ").map(function(x) { return parseInt(x); })[0];
var current = readline().split(" ").map(function(x) { return parseInt(x); })
var desired = readline().split(" ").map(function(x) { return parseInt(x); })
print(solve(current, desired))


Kolya got an integer array $$$a_1, a_2, \dots, a_n$$$. The array can contain both positive and negative integers, but Kolya doesn't like $$$0$$$, so the array doesn't contain any zeros.Kolya doesn't like that the sum of some subsegments of his array can be $$$0$$$. The subsegment is some consecutive segment of elements of the array. You have to help Kolya and change his array in such a way that it doesn't contain any subsegments with the sum $$$0$$$. To reach this goal, you can insert any integers between any pair of adjacent elements of the array (integers can be really any: positive, negative, $$$0$$$, any by absolute value, even such a huge that they can't be represented in most standard programming languages).Your task is to find the minimum number of integers you have to insert into Kolya's array in such a way that the resulting array doesn't contain any subsegments with the sum $$$0$$$.

The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 200\,000$$$) — the number of elements in Kolya's array. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^{9} \le a_i \le 10^{9}, a_i \neq 0$$$) — the description of Kolya's array.

Print the minimum number of integers you have to insert into Kolya's array in such a way that the resulting array doesn't contain any subsegments with the sum $$$0$$$.

NoteConsider the first example. There is only one subsegment with the sum $$$0$$$. It starts in the second element and ends in the fourth element. It's enough to insert one element so the array doesn't contain any subsegments with the sum equal to zero. For example, it is possible to insert the integer $$$1$$$ between second and third elements of the array.There are no subsegments having sum $$$0$$$ in the second example so you don't need to do anything.

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

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}
function pow(base, n) {
  if (n === 0) return 1;
  let p = pow(base, Math.floor(n / 2));
  let res = mul(mod(p), mod(p));
  if (n % 2 === 1) res = mul(mod(res), base);
  return res;
}
function highestOneBit(i) {
  i |= i >> 1;
  i |= i >> 2;
  i |= i >> 4;
  i |= i >> 8;
  i |= i >> 16;
  return i - (i >>> 1);
}
function permutation(arr, len, store = "", permutations = []) {
  if (store.length === len) {
    permutations.push(store);
    return;
  }
  for (let i = 0; i < arr.length; i++) {
    const newArr = [...arr];
    const newChar = newArr.splice(i, 1);
    permutation(newArr, len, store.concat(newChar), permutations);
  }
  return permutations;
}

function main() {
  const len = +readLine();
  const arr = readLine()
    .split(" ")
    .map((n) => parseInt(n));

  let [count, cSum, map] = [0, 0, {}];

  for (let i = 0; i < len; i++) {
    cSum += arr[i];
    if (!cSum || map[cSum]) {
      map = {};
      count++;
      cSum = arr[i];
    }
    map[cSum] = true;
  }

  console.log(count);
}

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

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var list = nextIntArray();
  var output = 0;
  var now = 0;
  var used = new Set([0]);
  for(var i = 0; i < N; i++){
    now += list[i];
    if(used.has(now)){
      output++;
      used = new Set([0]);
      now = list[i];
    }
    used.add(now);
  }
  myout(output);
}

function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn, init) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b, fn);
  if (b < a) return [];
  let arr = Array(b - a + 1).fill(0);
  if (init) init(arr);
  for (let i = a; i <= b; i++) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.for = function (a, b, fn) {
  let res
  for (let i = a; i <= b; i++) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.forR = function (a, b, fn) {
  let res
  for (let i = a; i >= b; i--) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}
// [m] = extendedEuclid(a, 998244353);
// let MOD = 998244353n;
// let gt = Arr(n, (i, a) => i == 0 ? 1n : a[i - 1] * BigInt(i) % MOD);
// let rgt = Arr(n, (i, a) => i <= 1 ? 1n : MOD - MOD / BigInt(i) * a[998244353 % i] % MOD);
// for (let i = 2; i < n; i++) rgt[i] = rgt[i] * rgt[i - 1] % MOD;
// let nCk = (n, k) => gt[n] * rgt[k] * rgt[n - k] % MOD;
// for (let i = dm[l.l]; i <= n + n; i += i & -i) s[i]++; // start from index 1

// let p = [2, 3, 5];
// for (let i = 6; i < 1e5; i += 6) {
//   let j, x = i + 1;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
//   x = i + 5;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let n = $(), a = $(n), m = { 0: 1 }, s = 0, res = 0;
  For(n, i => {
    if (m[s + a[i]]) { res++; s = a[i]; m = { [s]: 1, 0: 1 } }
    else m[s += a[i]] = 1;
  })
  log(res)
}

function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn, init) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b, fn);
  if (b < a) return [];
  let arr = Array(b - a + 1).fill(0);
  if (init) init(arr);
  for (let i = a; i <= b; i++) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.for = function (a, b, fn) {
  let res
  for (let i = a; i <= b; i++) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.forR = function (a, b, fn) {
  let res
  for (let i = a; i >= b; i--) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
let MOD = 998244353
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + MOD) % MOD;
}
// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[998244353 % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

// let p = [2];
// for (let i = 3; i < 1e5; i += 2) {
//   let j, x = Math.sqrt(i);
//   for (j = 0; p[j] <= x; j++) if (i % p[j] == 0) break;
//   if (i % p[j] != 0) p.push(i);
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let n = $(), a = $(n), m = { 0: 1 }, s = 0, res = 0;
  For(n, i => {
    if (m[s + a[i]]) { res++; s = a[i]; m = { [s]: 1, 0: 1 } }
    else m[s += a[i]] = 1;
  })
  log(res)
}

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

    D();
});

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

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function D(){
    let n = pi(readline());
    let a = ti(readline().split(' '));
    let map = {};
    map[0] = 1;
    let sum = 0;
    let count = 0;
    for(let i = 0; i < a.length; i++){
        sum += a[i];
        if(map[sum] !== undefined){
            count += 1;
            map = {};
            map[0] = 1;
            sum = a[i];
        }

        map[sum] = 1;
    }

    console.log(count);
}

'use strict'
function mlt() { return readline().split(' ').map(x => parseInt(x)); }
function inp() { return parseInt(readline()) }
function solv() {
    var x = inp();
    var s = mlt();
    var st = new Set()
    var pf = 0
    st.add(pf)
    var res = 0
    for (var n = 0; n < x; n++) {
        pf += s[n];
        if (!st.has(pf)) {
            st.add(pf)
        }
        else {
            st.add(pf + 1e10);
            st.add(pf + 1e10 + s[n]);
            res++;
            pf = 1e10 + s[n] + pf;
        }
    }
    print(res)
}
var tc = 1;
// tc= parseInt(readline())
while (tc--) solv()

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

    D();
});

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

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function D(){
    let n = pi(readline());
    let a = ti(readline().split(' '));
    let map = {};
    let sum = 0;
    let count = 0;
    let arr = new Array(n);
    let f = 0;
    for(let i = 0; i < a.length; i++){
        sum += a[i];
        if(map[sum] !== undefined){
            count += 1;
        }else{
            map[sum] = i;
        }
        if(sum === 0)
            f = 1;
        arr[i] = sum;
    }

    console.log(arr);
    console.log(f === 0 ? count : count + 1);
}

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

    D();
});

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

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function D(){
    let n = pi(readline());
    let a = ti(readline().split(' '));
    let map = {};
    let sum = 0;
    let count = 0;
    //let arr = new Array(n);
    let f = 0;
    for(let i = 0; i < a.length; i++){
        sum += a[i];
        if(map[sum] !== undefined){
            count += 1;
        }else{
            map[sum] = i;
        }
        if(sum === 0)
            f = 1;
    }

    //console.log(arr);
    console.log(f === 0 ? count : count + 1);
}