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

const ra = ()=>readline().split(' ').map(a=>+a);

function div(val, by){
    return (val - val % by) / by;
}

const cnk = (n, k) => {
    let res = 1;
    for (let i = 1; i <= k; i++)
        res = res * (n - k + i) / i;
    return Math.round(res + 0.01);
}

const sumab = (a, b) => {
    let x = (b - a + 1);
    let y = a + b;
    if (x % 2 === 0) {
        x = Math.round(x / 2);
    } else {
        y = Math.round(y / 2);
    }
    return BigInt(x) * BigInt(y);
}

const calc = (n, k, h)=>{
    let result = 0n;

    let intervals = [];

    for (let i = 0; i < n; i++) {
        intervals.push([k[i] - h[i], k[i]]);
    }
    intervals = intervals.sort((i1, i2) => {
        let x = i1[0] - i2[0];
        if (x === 0) {
            return i1[1] - i2[1];
        } else {
            return x;
        }
    })

    let [l, r] = intervals[0];

    for (let i = 1; i < intervals.length; i++) {
        let [curL, curR] = intervals[i];
        if (curL < r) {
            r = Math.max(r, curR);
        } else {
            result += sumab(1, r - l);
            l = curL;
            r = curR;
        }
    }
    result += sumab(1, r - l);

    return result;
};

function main() {
    let T = +readline();
    for (let t = 1; t <= T; t++){
        let n = +readline();
        let k = ra();
        let h = ra();
        console.log(`${calc(n, k, h)}`);
    }
}

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

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

function main () {
	let T = rn();
	while (T--) {
		const n = rn();
		const k = rna();
		const h = rna();

		const st = [];
		for (let i = 0; i < n; i++) {
			const [L, R] = [k[i] - h[i] + 1, k[i]];

			while (st.length) {
				const [l, r] = st.pop();
				if (L > r) {
					st.push([l, r]);
					st.push([L, R]);
					break;
				} else if (L < l) {
					continue;
				} else if (L >= l) {
					st.push([l, R]);
					break;
				}
			}

			if (!st.length) {
				st.push([L, R]);
			}
		}

		let ans = 0n;
		for (const [l, r] of st) {
			ans += BigInt(r - l + 1) * BigInt(r - l + 2) / 2n;
		}

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

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

const ra = ()=>readline().split(' ').map(a=>+a);

function div(val, by){
    return (val - val % by) / by;
}

const cnk = (n, k) => {
    let res = 1;
    for (let i = 1; i <= k; i++)
        res = res * (n - k + i) / i;
    return Math.round(res + 0.01);
}

const sumab = (a, b) => {
    let x = (b - a + 1);
    let y = a + b;
    if (x % 2 === 0) {
        x = Math.round(x / 2);
    } else {
        y = Math.round(y / 2);
    }
    return BigInt(x) * BigInt(y);
}

const calc = (n, k, h)=>{
    let result = 0n;

    let intervals = [];

    for (let i = 0; i < n; i++) {
        intervals.push([k[i] - h[i], k[i]]);
    }
    intervals = intervals.sort((i1, i2) => {
        let x = i1[0] - i2[0];
        if (x === 0) {
            return i1[1] - i2[1];
        } else {
            return x;
        }
    })

    for (let i = 1; i < intervals.length; i++) {
        let cur = intervals[i], prev = intervals[i - 1];
        if (cur[0] < prev[1]) {
            cur[0] = prev[0];
            cur[1] = Math.max(prev[1], cur[1]);
            intervals.shift();
            i--;
        }
    }

    for (let i = 0; i < intervals.length; i++) {
        let cur = intervals[i];
        result += sumab(1, cur[1] - cur[0]);
    }
    return result;
};

function main() {
    let T = +readline();
    for (let t = 1; t <= T; t++){
        let n = +readline();
        let k = ra();
        let h = ra();
        console.log(`${calc(n, k, h)}`);
    }
}

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

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

function main () {
	let T = rn();
	while (T--) {
		const n = rn();
		const k = rna();
		const h = rna();

		const st = [];
		for (let i = 0; i < n; i++) {
			const [L, R] = [k[i] - h[i] + 1, k[i]];

			while (st.length) {
				const [l, r] = st.pop();
				if (L > r) {
					st.push([l, r]);
					st.push([L, R]);
					break;
				} else if (L < l) {
					continue;
				} else if (L >= l) {
					st.push([l, R]);
					break;
				}
			}

			if (!st.length) {
				st.push([L, R]);
			}
		}

		let ans = 0;
		for (const [l, r] of st) {
			ans += (r - l + 1) * (r - l + 2) / 2;
		}

		console.log(ans);
	}
}


const fs = require("fs");

const input = fs.readFileSync(0, "utf8").trim().split("\n");

const testCases = [];
let T;

function parseInput() {
  T = parseInt(input[0]);
  let index = 0;

  for (let i = 0; i < T; i++) {
    index++;
    const [n, m, sx, sy, d] = input[index]
      .split(" ")
      .map((item) => parseInt(item));
    const testCase = {
      n,
      m,
      sx,
      sy,
      d,
    };

    testCases.push(testCase);
  }
}

function solution(testCase) {
  const { n, m, sx, sy, d } = testCase;

  if (
    (sy - d <= 1 && sy + d >= m) ||
    (sx - d <= 1 && sx + d >= n) ||
    (sx + d >= n && sy + d >= m) ||
    (sx - d <= 1 && sy - d <= 1)
  )
    console.log(-1);
  else {
    console.log(n - 1 + m - 1);
  }
}

parseInput();

testCases.forEach(solution);

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, m, sx, sy, d] = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(n, m, sx, sy, d)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, m, sx, sy, d) {
    sx--; sy--
    if (!ok(0, 0) || !ok(n - 1, m - 1)) return -1
    const top = !ok(0, sy)
    const bottom = !ok(n - 1, sy)
    const left = !ok(sx, 0)
    const right = !ok(sx, m - 1)
    if (top && bottom || top && left
        || bottom && right || left && right) return -1
    return n + m - 2
    function ok(i, j) {
        return Math.abs(sx - i) + Math.abs(sy - j) > d
    }
}

var repeatTimes = readline();

while (repeatTimes--) {
    var a = readline().split(' ')
    var n = parseInt(a[0])
    var m = parseInt(a[1])
    var sx = parseInt(a[2])
    var sy = parseInt(a[3])
    var d = parseInt(a[4])
    if(((sx - d <= 1 || sy + d >= m) && (sx + d >= n || sy - d <= 1)))
				print(-1);
			else
				print(n+m-2);
}

var tests = parseInt(readline());
    var n, m, sx, sy, d;

    for (var t=0; t < tests; t++) {
        var a = readline().split(' ').map(x=>parseInt(x));
        n = a[0];
        m = a[1];
        sx = a[2];
        sy = a[3];
        d = a[4];

        if ((sx - d <= 1 && sy - d <= 1) || (sx + d >= n && sy + d >= m)
        || (sx - d <= 1 && sx + d >= n ) || ( sy - d <= 1 && sy + d >= m)) {
            print(-1);
            continue;
        }
        print(n + m - 2);
    }

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

function distance(ax, ay, bx, by) {
    return Math.abs(ax - bx) + Math.abs(ay - by);
}

function solve([n, m, sx, sy, d]) {
    if (distance(n, m, sx, sy) <= d) {
        return -1;
    }

    // compute vertical block
    if (distance(sx, 1, sx, sy) <= d && distance(sx, m, sx, sy) <= d) {
        return -1;
    }

    // compute horizontal block
    if (distance(1, sy, sx, sy) <= d && distance(n, sy, sx, sy) <= d) {
        return -1;
    }

    if (distance(sx, m, sx, sy) <= d && distance(n, sy, sx, sy) <= d) {
        return -1;
    }

    if (distance(sx, 1, sx, sy) <= d && distance(1, sy, sx, sy) <= d) {
        return -1;
    }

    return n - 1 + m - 1;
}

var input = '';
process.stdin.on('data', function(chunk) {
    input += chunk;
});

process.stdin.on('end', function() {
    const lines = input.trim().split('\n');
    for (let i = 1; i < lines.length; i += 1) {
        const solution = solve(lines[i].split(' ').map(Number))
        process.stdout.write(String(solution) + '\n');
    }
});

var inputString = [], currentLine = 0;
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var readline = require('readline');
var rl = readline.createInterface(process.stdin);
rl.on('line', line => { inputString.push(line) });
process.stdin.on('end', () => {  main()  });

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

function main() {
    const t = +readLine();
    for(let i = 0; i < t; i++){
        // const n = +readLine();
        const arr = readLine().split(' ').map(p => +p);
        let result = myFunc(arr[0], arr[1], arr[2], arr[3], arr[4]);
        console.log(result);
    }
}

function myFunc(l, c, sx, sy, d){

    if(sy + d >= c && sy - d <= 1) return -1; //ocupa toda linha
    if(sx + d >= l && sx - d <= 1) return -1; //ocupa toda coluna

    if(sy + d >= c && sx + d >= l) return -1; // contorna objetivo
    if(sy - d <= 1 && sx - d <= 1) return -1; // contorna jogador

    return l + c - 2;

}

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

function main() {
    const t = +readLine();
    for(let i = 0; i < t; i++){
        // const n = +readLine();
        const arr = readLine().split(' ').map(p => +p);
        let result = myFunc(arr[0], arr[1], arr[2], arr[3], arr[4]);
        console.log(result);
    }
}

function myFunc(l, c, sx, sy, d){

    if(sy + d >= c && sy - d <= 1) return -1; //ocupa toda linha
    if(sx + d >= l && sx - d <= 1) return -1; //ocupa toda coluna

    if(sy + d >= c && sx + d >= l) return -1; // contorna objetivo
    if(sy - d <= 1 && sx - d <= 1) return -1; // contorna jogador

    return l + c - 2;

}

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 134 (Div. 2)
2022-08-26

B. Deadly Laser
***/

function main() {
  // INPUT: Number of test cases
  let t = readline();
  t = parseInt(t);
  for (let tc = 0; tc < t; tc++) {
    // INPUT: grid size (n, m); laser at (sx, sy); range d
    let args = readline();
    args = args.split(" ");
    args = args.map((k) => parseInt(k));
    const [n, m] = args.slice(0, 2);

    if (badLaser(...args)) {
      console.log(-1);
    } else {
      // number of steps will always be the same
      // if it is possible robot can always take
      // either right->down or down->right the whole board
      console.log(n + m - 2);
    }
  }
}

// Manhattan distance between 2 points
function manDist(x1, y1, x2, y2) {
  return Math.abs(x1 - x2) + Math.abs(y1 - y2);
}

// Is the route impossible?
function badLaser(n, m, sx, sy, d) {
  return (
    (sx - 1 <= d && sy - 1 <= d) ||
    (n - sx <= d && m - sy <= d) ||
    (sx - 1 <= d && n - sx <= d) ||
    (m - sy <= d && sy - 1 <= d)
  );
}

let fs = require("fs");
let sc = {
    _buf: new Buffer.alloc(1 << 14),
    _bufPos: 0,
    _bufLen: 0,
    _ensure: function ()
    {
        if (this._bufPos === this._bufLen)
        {
            this._bufPos = 0;
            this._bufLen = fs.readSync(0, this._buf, 0, this._buf.length, null);
        }
    },
    _isws: function (ch)
    {
        return ch === 32 || ch === 9 || ch === 10 || ch === 13;
    },
    _islf: function (ch)
    {
        return ch === 10 || ch === 13;
    },
    _peekChar: function ()
    {
        this._ensure();
        return this._bufPos === this._bufLen ? 0 : this._buf[this._bufPos];
    },
    _skipWs: function ()
    {
        while (this._isws(this._peekChar()))
            this._bufPos++;
    },
    _readUntil: function (stop)
    {
        this._ensure();
        if (this._bufPos === this._bufLen)
            throw new Error("eof");
        let start = this._bufPos;
        let before = null;
        for (; ;)
        {
            if (this._bufPos === this._bufLen)
            {
                let len = this._bufPos - start, preLen = (before ? before.length : 0);
                let nbuf = new Buffer(len + preLen);
                if (before)
                    before.copy(nbuf);
                before = nbuf;
                this._buf.copy(before, preLen, start);
                this._ensure();
                start = this._bufPos;
            }
            if (this._bufPos === this._bufLen || stop(this._buf[this._bufPos])) break;
            this._bufPos++;
        }
        if (!before)
            return this._buf.toString("utf8", start, this._bufPos);
        let after = this._buf.slice(start, this._bufPos);
        let res = new Buffer(before.length + after.length);
        before.copy(res);
        after.copy(res, before.length);
        return res.toString();
    },

    nextToken: function ()
    {
        this._skipWs();
        return this._readUntil(this._isws);
    },
    L: function ()
    {
        let line = this._readUntil(this._islf);
        if (this._peekChar() === 13) this._bufPos++;
        if (this._peekChar() === 10) this._bufPos++;
        return line;
    },
    N: function ()
    {
        return +this.nextToken();
    },
    S: function ()
    {
        return this.nextToken();
    }
};

// DO NOT CHANGE TEMPLATE BEFORE

const Def = Number(1e9);

const Solve = () =>
{
    let n = sc.N(), m = sc.N(), sx = sc.N(), sy = sc.N(), d = sc.N();

    // console.log(`n = ${n} and m = ${m} and sx = ${sx} and sy = ${sy} and d = ${d}`);

    if ((sx + d >= n && sy + d >= m) || (sx - d <= 1 && sy - d <= 1) || (sx + d >= n && sx - d <= 1) || (sy + d >= m && sy - d <= 1))
    {
        console.log(-1);
        return;
    }

    // if ((sx + d >= n && sx - d <= 1) || (sy + d >= m && sy - d <= 1))
    // {
    //     console.log(-1);
    //     return;
    // }

    console.log(n + m - 2);

    // let arr = new Array(n).fill(new Array(m).fill(0));

    // arr[sx - 1][sy - 1] = 1;
    //
    // for (let i = 0; i < n; ++i)
    // {
    //     for (let j = 0; j < m; ++j)
    //     {
    //         console.log(arr[i][j]);
    //     }
    // }

}

const main = () =>
{
    let cases = sc.N();
    while (cases-- > 0) Solve();

    // Solve();
}
main();

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

function distance(ax, ay, bx, by) {
    return Math.abs(ax - bx) + Math.abs(ay - by);
}

function solve([n, m, sx, sy, d]) {
    if (distance(n, m, sx, sy) <= d) {
        return -1;
    }

    // compute vertical block
    // if (distance(sx, 1, sx, sy) <= d && distance(sx, m, sx, sy) <= d) {
    //     return -1;
    // }

    // compute horizontal block
    // if (distance(1, sy, sx, sy) <= d && distance(n, sy, sx, sy) <= d) {
    //     return -1;
    // }

    if (distance(sx, m, sx, sy) <= d && distance(n, sy, sx, sy) <= d) {
        return -1;
    }

    return n - 1 + m - 1;
}

var input = '';
process.stdin.on('data', function(chunk) {
    input += chunk;
});

process.stdin.on('end', function() {
    const lines = input.trim().split('\n');
    for (let i = 1; i < lines.length; i += 1) {
        const solution = solve(lines[i].split(' ').map(Number))
        process.stdout.write(String(solution) + '\n');
    }
});

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

function distance(ax, ay, bx, by) {
    return Math.abs(ax - bx) + Math.abs(ay - by);
}

function solve([n, m, sx, sy, d]) {
    if (distance(n, m, sx, sy) <= d) {
        return -1;
    }

    // compute vertical block
    if (distance(sx, 1, sx, sy) <= d && distance(sx, m, sx, sy) <= d) {
        return -1;
    }

    // compute horizontal block
    if (distance(1, sy, sx, sy) <= d && distance(n, sy, sx, sy) <= d) {
        return -1;
    }

    if (distance(sx, m, sx, sy) <= d && distance(n, sy, sx, sy) <= d) {
        return -1;

    }

    return n - 1 + m - 1;
}

var input = '';
process.stdin.on('data', function(chunk) {
    input += chunk;
});

process.stdin.on('end', function() {
    const lines = input.trim().split('\n');
    for (let i = 1; i < lines.length; i += 1) {
        const solution = solve(lines[i].split(' ').map(Number))
        process.stdout.write(String(solution) + '\n');
    }
});

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

function distance(ax, ay, bx, by) {
    return Math.abs(ax - bx) + Math.abs(ay - by);
}

function solve([n, m, sx, sy, d]) {
    if (distance(n, m, sx, sy) <= d) {
        return -1;
    }

    // compute vertical block
    // if (distance(sx, 1, sx, sy) <= d && distance(sx, m, sx, sy) <= d) {
    //     return -1;
    // }

    // compute horizontal block
    // if (distance(1, sy, sx, sy) <= d && distance(n, sy, sx, sy) <= d) {
    //     return -1;
    // }

    return n - 1 + m - 1;
}

var input = '';
process.stdin.on('data', function(chunk) {
    input += chunk;
});

process.stdin.on('end', function() {
    const lines = input.trim().split('\n');
    for (let i = 1; i < lines.length; i += 1) {
        const solution = solve(lines[i].split(' ').map(Number))
        process.stdout.write(String(solution) + '\n');
    }
});

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

function distance(ax, ay, bx, by) {
    return Math.abs(ax - bx) + Math.abs(ay - by);
}

function solve([n, m, sx, sy, d]) {
    if (distance(n, m, sx, sy) <= d) {
        return -1;
    }

    // compute vertical block
    if (distance(sx, 1, sx, sy) <= d && distance(sx, m, sx, sy) <= d) {
        return -1;
    }

    // compute horizontal block
    if (distance(1, sy, sx, sy) <= d && distance(n, sy, sx, sy) <= d) {
        return -1;
    }

    return n - 1 + m - 1;
}

var input = '';
process.stdin.on('data', function(chunk) {
    input += chunk;
});

process.stdin.on('end', function() {
    const lines = input.trim().split('\n');
    for (let i = 1; i < lines.length; i += 1) {
        const solution = solve(lines[i].split(' ').map(Number))
        process.stdout.write(String(solution) + '\n');
    }
});

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

function distance(ax, ay, bx, by) {
    return Math.abs(ax - bx) + Math.abs(ay - by);
}

function solve([n, m, sx, sy, d]) {
    if (distance(m, n, sx, sy) <= d) {
        return -1;
    }

    // compute vertical block
    if (distance(sx, 1, sx, sy) <= d && distance(sx, n, sx, sy) <= d) {
        return -1;
    }

    // compute horizontal block
    if (distance(1, sy, sx, sy) <= d && distance(m, sy, sx, sy) <= d) {
        return -1;
    }

    return n - 1 + m - 1;
}

var input = '';
process.stdin.on('data', function(chunk) {
    input += chunk;
});

process.stdin.on('end', function() {
    const lines = input.trim().split('\n');
    for (let i = 1; i < lines.length; i += 1) {
        const solution = solve(lines[i].split(' ').map(Number))
        process.stdout.write(String(solution) + '\n');
    }
});

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

function distance(ax, ay, bx, by) {
    return Math.abs(ax - bx) + Math.abs(ay - by);
}

function solve([n, m, sx, sy, d]) {
    if (distance(n, m, sx, sy) <= d) {
        return -1;
    }

    // compute vertical block
    if (distance(sx, 1, sx, sy) <= d && distance(sx, n, sx, sy) <= d) {
        return -1;
    }

    // compute horizontal block
    if (distance(1, sy, sx, sy) <= d && distance(m, sy, sx, sy) <= d) {
        return -1;
    }

    return n - 1 + m - 1;
}

var input = '';
process.stdin.on('data', function(chunk) {
    input += chunk;
});

process.stdin.on('end', function() {
    const lines = input.trim().split('\n');
    for (let i = 1; i < lines.length; i += 1) {
        const solution = solve(lines[i].split(' ').map(Number))
        process.stdout.write(String(solution) + '\n');
    }
});

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

function distance(ax, ay, bx, by) {
    return Math.abs(ax - bx) + Math.abs(ay - by);
}

function solve([n, m, sx, sy, d]) {
    if (d === 0) {
        return n - 1 + m - 1;
    }

    if (distance(n, m, sx, sy) <= d) {
        return -1;
    }

    // compute vertical block
    if (distance(sx, 1, sx, sy) <= d && distance(sx, m, sx, sy) <= d) {
        return -1;
    }

    // compute horizontal block
    if (distance(1, sy, sx, sy) <= d && distance(n, sy, sx, sy) <= d) {
        return -1;
    }

    return n - 1 + m - 1;
}

var input = '';
process.stdin.on('data', function(chunk) {
    input += chunk;
});

process.stdin.on('end', function() {
    const lines = input.trim().split('\n');
    for (let i = 1; i < lines.length; i += 1) {
        const solution = solve(lines[i].split(' ').map(Number))
        process.stdout.write(String(solution) + '\n');
    }
});

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

function main() {
    const t = +readLine();
    for(let i = 0; i < t; i++){
        // const n = +readLine();
        const arr = readLine().split(' ').map(p => +p);
        let result = myFunc(arr[0], arr[1], arr[2], arr[3], arr[4]);
        console.log(result);
    }
}

function myFunc(l, c, sx, sy, d){

    if(sy + d >= c && sy - d <= 1) return -1;
    if(sx + d >= l && sx - d <= 1) return -1;

    // if(sx == l && sy + d >= c) return -1;
    // if(sy == c && sx + d >= l) return -1;

    if(sy + d >= c && sx + d >= l) return -1;
    if(sy + d <= 1 && sx + d <= 1) return -1;

    return l + c - 2;

}

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

function main() {
    const t = +readLine();
    for(let i = 0; i < t; i++){
        // const n = +readLine();
        const arr = readLine().split(' ').map(p => +p);
        let result = myFunc(arr[0], arr[1], arr[2], arr[3], arr[4]);
        console.log(result);
    }
}

function myFunc(l, c, sx, sy, d){

    if(sy + d >= c && sy - d <= 1) return -1;
    if(sx + d >= l && sx - d <= 1) return -1;

    if(sx == l && sy + d >= c) return -1;
    if(sy == c && sx + d >= l) return -1;

    if(sy + d >= c && sx + d >= l) return -1;

    return l + c - 2;

}

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

function main() {
    const t = +readLine();
    for(let i = 0; i < t; i++){
        // const n = +readLine();
        const arr = readLine().split(' ').map(p => +p);
        let result = myFunc(arr[0], arr[1], arr[2], arr[3], arr[4]);
        console.log(result);
    }
}

function myFunc(l, c, sx, sy, d){

    if(sy + d >= c && sy - d <= 1) return -1;
    if(sx + d >= l && sx - d <= 1) return -1;

    if(sx == l && sy + d >= c) return -1;
    if(sy == c && sx + d >= l) return -1;

    return l + c - 2;

}

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 134 (Div. 2)
2022-08-26

B. Deadly Laser
***/

function main() {
  // INPUT: Number of test cases
  let t = readline();
  t = parseInt(t);
  for (let tc = 0; tc < t; tc++) {
    // INPUT: grid size (n, m); laser at (sx, sy); range d
    let args = readline();
    args = args.split(" ");
    args = args.map((k) => parseInt(k));
    const [n, m] = args.slice(0, 2);

    if (badLaser(...args)) {
      console.log(-1);
    } else {
      // number of steps will always be the same
      // if it is possible robot can always take
      // either right->down or down->right the whole board
      console.log(n + m - 2);
    }
  }
}

// Manhattan distance between 2 points
function manDist(x1, y1, x2, y2) {
  return Math.abs(x1 - x2) + Math.abs(y1 - y2);
}

// Is the route impossible?
function badLaser(n, m, sx, sy, d) {
  return (sx - 1 <= d && sy - 1 <= d) || (n - sx <= d && m - sy <= d);
}

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 134 (Div. 2)
2022-08-26

B. Deadly Laser
***/

function main() {
  // INPUT: Number of test cases
  let t = readline();
  t = parseInt(t);
  for (let tc = 0; tc < t; tc++) {
    // INPUT: grid size (n, m); laser at (sx, sy); range d
    let args = readline();
    args = args.split(" ");
    args = args.map((k) => parseInt(k));
    const [n, m, sx, sy, d] = args;

    if (manDist(n, m, sx, sy) <= d) {
      console.log(-1);
    } else {
      // number of steps will always be the same
      // if it is possible robot can always take
      // either right->down or down->right the whole board
      console.log(n + m - 2);
    }
  }
}

// Manhattan distance between 2 points
function manDist(x1, y1, x2, y2) {
  return Math.abs(x1 - x2) + Math.abs(y1 - y2);
}

let fs = require("fs");
let sc = {
    _buf: new Buffer.alloc(1 << 14),
    _bufPos: 0,
    _bufLen: 0,
    _ensure: function ()
    {
        if (this._bufPos === this._bufLen)
        {
            this._bufPos = 0;
            this._bufLen = fs.readSync(0, this._buf, 0, this._buf.length, null);
        }
    },
    _isws: function (ch)
    {
        return ch === 32 || ch === 9 || ch === 10 || ch === 13;
    },
    _islf: function (ch)
    {
        return ch === 10 || ch === 13;
    },
    _peekChar: function ()
    {
        this._ensure();
        return this._bufPos === this._bufLen ? 0 : this._buf[this._bufPos];
    },
    _skipWs: function ()
    {
        while (this._isws(this._peekChar()))
            this._bufPos++;
    },
    _readUntil: function (stop)
    {
        this._ensure();
        if (this._bufPos === this._bufLen)
            throw new Error("eof");
        let start = this._bufPos;
        let before = null;
        for (; ;)
        {
            if (this._bufPos === this._bufLen)
            {
                let len = this._bufPos - start, preLen = (before ? before.length : 0);
                let nbuf = new Buffer(len + preLen);
                if (before)
                    before.copy(nbuf);
                before = nbuf;
                this._buf.copy(before, preLen, start);
                this._ensure();
                start = this._bufPos;
            }
            if (this._bufPos === this._bufLen || stop(this._buf[this._bufPos])) break;
            this._bufPos++;
        }
        if (!before)
            return this._buf.toString("utf8", start, this._bufPos);
        let after = this._buf.slice(start, this._bufPos);
        let res = new Buffer(before.length + after.length);
        before.copy(res);
        after.copy(res, before.length);
        return res.toString();
    },

    nextToken: function ()
    {
        this._skipWs();
        return this._readUntil(this._isws);
    },
    L: function ()
    {
        let line = this._readUntil(this._islf);
        if (this._peekChar() === 13) this._bufPos++;
        if (this._peekChar() === 10) this._bufPos++;
        return line;
    },
    N: function ()
    {
        return +this.nextToken();
    },
    S: function ()
    {
        return this.nextToken();
    }
};

// DO NOT CHANGE TEMPLATE BEFORE

const Def = Number(1e9);

const Solve = () =>
{
    let n = sc.N(), m = sc.N(), sx = sc.N(), sy = sc.N(), d = sc.N();

    if ((sx + d >= n && sy + d >= m) || (sx - d <= 1 && sy - d <= 1))
    {
        console.log(-1);
        return;
    }

    // if ((sx + d >= n && sx - d <= 1) || (sy + d >= m && sy - d <= 1))
    // {
    //     console.log(-1);
    //     return;
    // }

    console.log(n + m - 2);

    // let arr = new Array(n).fill(new Array(m).fill(0));

    // arr[sx - 1][sy - 1] = 1;
    //
    // for (let i = 0; i < n; ++i)
    // {
    //     for (let j = 0; j < m; ++j)
    //     {
    //         console.log(arr[i][j]);
    //     }
    // }

}

const main = () =>
{
    let cases = sc.N();
    while (cases-- > 0) Solve();

    // Solve();
}
main();

let fs = require("fs");
let sc = {
    _buf: new Buffer.alloc(1 << 14),
    _bufPos: 0,
    _bufLen: 0,
    _ensure: function ()
    {
        if (this._bufPos === this._bufLen)
        {
            this._bufPos = 0;
            this._bufLen = fs.readSync(0, this._buf, 0, this._buf.length, null);
        }
    },
    _isws: function (ch)
    {
        return ch === 32 || ch === 9 || ch === 10 || ch === 13;
    },
    _islf: function (ch)
    {
        return ch === 10 || ch === 13;
    },
    _peekChar: function ()
    {
        this._ensure();
        return this._bufPos === this._bufLen ? 0 : this._buf[this._bufPos];
    },
    _skipWs: function ()
    {
        while (this._isws(this._peekChar()))
            this._bufPos++;
    },
    _readUntil: function (stop)
    {
        this._ensure();
        if (this._bufPos === this._bufLen)
            throw new Error("eof");
        let start = this._bufPos;
        let before = null;
        for (; ;)
        {
            if (this._bufPos === this._bufLen)
            {
                let len = this._bufPos - start, preLen = (before ? before.length : 0);
                let nbuf = new Buffer(len + preLen);
                if (before)
                    before.copy(nbuf);
                before = nbuf;
                this._buf.copy(before, preLen, start);
                this._ensure();
                start = this._bufPos;
            }
            if (this._bufPos === this._bufLen || stop(this._buf[this._bufPos])) break;
            this._bufPos++;
        }
        if (!before)
            return this._buf.toString("utf8", start, this._bufPos);
        let after = this._buf.slice(start, this._bufPos);
        let res = new Buffer(before.length + after.length);
        before.copy(res);
        after.copy(res, before.length);
        return res.toString();
    },

    nextToken: function ()
    {
        this._skipWs();
        return this._readUntil(this._isws);
    },
    L: function ()
    {
        let line = this._readUntil(this._islf);
        if (this._peekChar() === 13) this._bufPos++;
        if (this._peekChar() === 10) this._bufPos++;
        return line;
    },
    N: function ()
    {
        return +this.nextToken();
    },
    S: function ()
    {
        return this.nextToken();
    }
};

// DO NOT CHANGE TEMPLATE BEFORE

const Def = Number(1e9);

const Solve = () =>
{
    let n = sc.N(), m = sc.N(), sx = sc.N(), sy = sc.N(), d = sc.N();

    if ((sx + d >= n && sx - d <= 1) || (sy + d >= m && sy - d <= 1))
    {
        console.log(-1);
        return;
    }

    console.log(n + m - 2);

    let arr = new Array(n).fill(new Array(m).fill(0));

    // arr[sx - 1][sy - 1] = 1;
    //
    // for (let i = 0; i < n; ++i)
    // {
    //     for (let j = 0; j < m; ++j)
    //     {
    //         console.log(arr[i][j]);
    //     }
    // }

}

const main = () =>
{
    let cases = sc.N();
    while (cases-- > 0) Solve();

    // Solve();
}
main();

const fs = require("fs");

const input = fs.readFileSync(0, "utf8").trim().split("\n");

const testCases = [];
let T;

function parseInput() {
  T = parseInt(input[0]);
  let index = 0;

  for (let i = 0; i < T; i++) {
    index++;
    const [n, m, sx, sy, d] = input[index]
      .split(" ")
      .map((item) => parseInt(item));
    const testCase = {
      n,
      m,
      sx,
      sy,
      d,
    };

    testCases.push(testCase);
  }
}

function solution(testCase) {
  const { n, m, sx, sy, d } = testCase;

  if (
    (sy - d <= 1 && sy + d >= m) ||
    (sx - d <= 1 && sx + d >= n) ||
    Math.abs(sx - n) + Math.abs(sy - m) <= d
  )
    console.log(-1);
  else {
    console.log(n - 1 + m - 1);
  }
}

parseInput();

testCases.forEach(solution);

const fs = require("fs");

const input = fs.readFileSync(0, "utf8").trim().split("\n");

const testCases = [];
let T;

function parseInput() {
  T = parseInt(input[0]);
  let index = 0;

  for (let i = 0; i < T; i++) {
    index++;
    const [n, m, sx, sy, d] = input[index]
      .split(" ")
      .map((item) => parseInt(item));
    const testCase = {
      n,
      m,
      sx,
      sy,
      d,
    };

    testCases.push(testCase);
  }
}

function solution(testCase) {
  const { n, m, sx, sy, d } = testCase;

  if ((sy - d <= 1 && sy + d >= m) || (sx - d <= 1 && sx + d >= n))
    console.log(-1);
  else {
    console.log(n - 1 + m - 1);
  }
}

parseInput();

testCases.forEach(solution);


var readline = require('readline');
var inputString = [], currentLine = 0;
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var rl = readline.createInterface(process.stdin);
rl.on('line', line => { inputString.push(line) });
process.stdin.on('end', () => {  main()  });

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

function main() {
    const t = +readLine();
    for(let i = 0; i < t; i++){
        const n = +readLine();
        const skill = readLine().split(' ').map(p => +p);
        const damage = readLine().split(' ').map(p => +p);
        let result = myFunc(n, skill, damage);
        console.log(result);
    }
}

function myFunc(n, skill, damage){
    let fire = [];
    let ice = [];
    let resp = 0;

    for(let i = 0; i < n; i++){
        if(skill[i] == 0) fire.push(damage[i]);
        else ice.push(damage[i]);
    }

    fire.sort((a, b) => a - b);
    ice.sort((a, b) => a - b);

    if(fire.length == ice.length){
        if(fire[0] <= ice[0]) resp = fire[0] + (2*ice[0]);
        else resp = (2*fire[0]) + ice[0];
        for(let i = 1; i < fire.length; i++){
            resp += (fire[i] * 2) + (ice[i]*2);
        }
    }
    else if(fire.length > ice.length){
        let diff = fire.length - ice.length;
        for(let i = 0; i < fire.length; i++){
            if(i < diff) resp += fire[i];
            else resp += (fire[i] * 2) + (ice[i-diff]*2);
        }
    }
    else{
        let diff = ice.length - fire.length;
        for(let i = 0; i < ice.length; i++){
            if(i < diff) resp += ice[i];
            else resp += (fire[i-diff] * 2) + (ice[i]*2);
        }
    }

    return resp

}

// 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 //

const getSolution = (n,a,b) => {
    if( n == 1 ) return b[0]

    let fire = a.filter( n => n === 0 )
    let frost = a.filter( n => n === 1 )

    if( fire.length === n || frost.length === n ) return b.reduce((partialSum, a) => partialSum + a, 0)

    let skills = []
    for( let i = 0; i< n; i++){
        skills.push({
           'attack' : a[i],
           'damage' : b[i]
        })
    }

    fire = skills.filter( s => s.attack === 0 ).sort((a,b) => b.damage - a.damage)
    frost = skills.filter( s => s.attack === 1 ).sort((a,b) => b.damage - a.damage)

    let damage = []
    let init = 0
    while( fire.length < frost.length )
    {
        damage.push( frost[frost.length - 1].damage )
        frost.pop()
        init = 0
    }

    while( frost.length < fire.length )
    {
        damage.push( fire[fire.length - 1].damage )
        fire.pop()
        init = 1
    }

    if( damage.length == 0 ) {

        let firemin = fire[fire.length - 1].damage
        let frostmin = frost[frost.length - 1].damage

        if( firemin <= frostmin ) {
            damage.push( fire[fire.length - 1].damage )
            fire.pop()
        } else {
            damage.push( frost[frost.length - 1].damage )
            frost.pop()
        }

        for( let f of fire )
        {
            damage.push( 2 * f.damage )
        }

        for( let f of frost )
        {
            damage.push( 2 * f.damage )
        }

    }  else {
        for( let f of fire )
        {
            damage.push( 2 * f.damage )
        }

        for( let f of frost )
        {
            damage.push( 2 * f.damage )
        }
    }

    return damage.reduce((partialSum, a) => partialSum + a, 0)
}

// Driver Function Starts //
function main() {

    let testcases = parseInt(readline())
    while (testcases--) {

        let n = parseInt(readline())
        let a = readline().split(' ').map(Number)
        let b = readline().split(' ').map(Number)
        console.log(getSolution(n, a, b))
    }

}
// Driver Function Ends //

// 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 //

const getSolution = (n, d) => {
    const a = [];
    a.push(d[0])
    for (let i = 1; i < n; i++) {

        let k = a.length - 1

        let op = ((a[k] - d[i]) < 0) ? (a[k] + d[i]) : (a[k] - d[i])
        a.push(op)

        k = a.length - 1
        if (a[k] - a[k - 1] < d[i]) return -1

    }

    return a.join(' ')
}

// Driver Function Starts //
function main() {

    let testcases = parseInt(readline())
    while (testcases--) {

        let n = parseInt(readline())
        let d = readline().split(' ').map(Number)
        console.log(getSolution(n, d))
    }

}
// Driver Function Ends //


function readStringArray() {
  return readline().split(" ");
}
function readNumArray() {
  return readStringArray().map(Number);
}

var good = new Set([0, 1, 2, 5, 8]);

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var hm = readNumArray();
    var h = hm[0];
    var m = hm[1];
    var hcmc = readline().split(':').map(Number);
    var hc = hcmc[0];
    var mc = hcmc[1];
    print(findNextGood(hc, mc, h, m));
  }
}

function isGoodH(num, m) {
  var first = switch25(Math.floor(num / 10));
  var second = switch25(num % 10);

  return good.has(first) && good.has(second)
    && (second * 10 + first) < m;
}

function isGoodM(num, h) {
  var first = switch25(Math.floor(num / 10));
  var second = switch25(num % 10);

  return good.has(first) && good.has(second)
    && (second * 10 + first) < h;
}

function findNextGood(hc, mc, h, m) {
  while (!isGoodM(mc , h)) {
    mc++;
    if (mc >= m) {
      mc = 0;
      hc++;
      if (hc >= h) {
        hc = 0;
      }
    }
  }

  while (!isGoodH(hc , m)) {
    hc++;
    mc = 0;
    if (hc >= h) {
      hc = 0;
    }
  }
  var hours = hc;
  var ph = hours > 9 ? String(hours) : '0' + hours;
  var minutes = mc;
  var pm = minutes > 9 ? String(minutes) : '0' + minutes;

  return ph + ':' + pm;
}

function switch25(num) {
  if (num === 2) return 5;
  if (num === 5) return 2;
  return num;
}
main();

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

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

function getPaddedString (x) {
	if (x < 10)
		return '0' + x;
	return String(x);
}

function check (hh, mm, h, m) {
	const mp = new Map([['0', '0'] , ['1', '1'], ['2', '5'], ['5', '2'], ['8', '8']]);

	hh = getPaddedString(hh);
	mm = getPaddedString(mm);
	for (const d of hh + mm) {
		if (!mp.has(d))
			return false
	}

	const hr = [mp.get(hh[0]), mp.get(hh[1])];
	const mr = [mp.get(mm[0]), mp.get(mm[1])];

	return Number(hr[1] + hr[0]) < m && Number(mr[1] + mr[0]) < h;
}

function main () {
	let T = rn();
	while (T--) {
		const [h, m] = rna();

		let [hh, mm]  = rl().split(':').map(x => Number(x));
		while (true) {
			if (check(hh, mm, h, m))
				break;
			mm = (mm + 1) % m;
			if (mm == 0) {
				hh = (hh + 1) % h;
			}
		}

		console.log(getPaddedString(hh) + ':' + getPaddedString(mm));
	}
}

function readStringArray() {
  return readline().split(" ");
}
function readNumArray() {
  return readStringArray().map(Number);
}

var good = new Set([0, 1, 2, 5, 8]);

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var hm = readNumArray();
    var h = hm[0];
    var m = hm[1];
    var hcmc = readline().split(':').map(Number);
    var hc = hcmc[0];
    var mc = hcmc[1];
    print(findNextGood(hc, mc, h, m));
  }
}

function isGoodH(num, m) {
  var first = switch25(Math.floor(num / 10));
  var second = switch25(num % 10);

  return good.has(first) && good.has(second)
    && (second * 10 + first) < m;
}

function isGoodM(num, h) {
  var first = switch25(Math.floor(num / 10));
  var second = switch25(num % 10);

  return good.has(first) && good.has(second)
    && (second * 10 + first) < h;
}

function findNextGood(hc, mc, h, m) {
  while (!isGoodM(mc , h)) {
    mc++;
    if (mc >= m) {
      mc = 0;
      hc++;
      if (hc >= h) {
        hc = 0;
      }
    }
  }
  var minutes = mc;
  var pm = minutes > 9 ? String(minutes) : '0' + minutes;

  while (!isGoodH(hc , m)) {
    hc++;
    if (hc >= h) {
      hc = 0;
    }
  }
  var hours = hc;
  var ph = hours > 9 ? String(hours) : '0' + hours;

  return ph + ':' + pm;
}

function switch25(num) {
  if (num === 2) return 5;
  if (num === 5) return 2;
  return num;
}
main();

function readStringArray() {
  return readline().split(" ");
}
function readNumArray() {
  return readStringArray().map(Number);
}

var good = new Set([0, 1, 2, 5, 8]);

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var hm = readNumArray();
    var h = hm[0];
    var m = hm[1];
    var hcmc = readline().split(':').map(Number);
    var hc = hcmc[0];
    var mc = hcmc[1];
    print(findNextGood(hc, mc, h, m));
  }
}

function isGoodH(num, m) {
  var first = switch25(Math.floor(num / 10));
  var second = switch25(num % 10);

  return good.has(first) && good.has(second)
    && (second * 10 + first) < m;
}

function isGoodM(num, h) {
  var first = switch25(Math.floor(num / 10));
  var second = switch25(num % 10);

  return good.has(first) && good.has(second)
    && (second * 10 + first) < h;
}

function findNextGood(hc, mc, h, m) {
  while (!isGoodM(mc , h)) {
    mc++;
    if (mc >= m) {
      mc = 0;
      hc++;
    }
  }
  var minutes = mc;
  var pm = minutes > 9 ? String(minutes) : '0' + minutes;

  while (!isGoodH(hc , m)) {
    hc++;
    if (hc >= h) {
      hc = 0;
    }
  }
  var hours = hc;
  var ph = hours > 9 ? String(hours) : '0' + hours;

  return ph + ':' + pm;
}

function switch25(num) {
  if (num === 2) return 5;
  if (num === 5) return 2;
  return num;
}
main();

function readStringArray() {
  return readline().split(" ");
}
function readNumArray() {
  return readStringArray().map(Number);
}

var good = new Set([0, 1, 2, 5, 8]);

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var hm = readNumArray();
    var h = hm[0];
    var m = hm[1];
    var hcmc = readline().split(':').map(Number);
    var hc = hcmc[0];
    var mc = hcmc[1];
    print(findNextGood(hc, mc, h, m));
  }
}

function isGoodH(num, m) {
  var first = switch25(Math.floor(num / 10));
  var second = switch25(num % 10);

  return good.has(first) && good.has(second)
    && (second * 10 + first) < m;
}

function isGoodM(num, h) {
  var first = switch25(Math.floor(num / 10));
  var second = switch25(num % 10);

  return good.has(first) && good.has(second)
    && (second * 10 + first) < h;
}

function findNextGood(hc, mc, h, m) {
  while (!isGoodH(hc , m)) {
    hc++;
    mc = 0;
    if (hc >= h) {
      hc = 0;
    }
  }
  var hours = hc;
  var ph = hours > 9 ? String(hours) : '0' + hours;
  while (!isGoodM(mc , h)) {
    mc++;
    if (mc >= m) {
      mc = 0;
    }
  }
  var minutes = mc;
  var pm = minutes > 9 ? String(minutes) : '0' + minutes;
  return ph + ':' + pm;
}

function switch25(num) {
  if (num === 2) return 5;
  if (num === 5) return 2;
  return num;
}
main();

function readStringArray() {
  return readline().split(" ");
}
function readNumArray() {
  return readStringArray().map(Number);
}

var good = new Set([0, 1, 2, 5, 8]);

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var hm = readNumArray();
    var h = hm[0];
    var m = hm[1];
    var hcmc = readline().split(':').map(Number);
    var hc = hcmc[0];
    var mc = hcmc[1];
    print(findNextGood(hc, mc, h, m));
  }
}

function isGoodH(num, m) {
  var first = Math.floor(num / 10);
  var second = num % 10;

  return good.has(first) && good.has(second)
    && (second * 10 + first) < m;
}

function isGoodM(num, h) {
  var first = Math.floor(num / 10);
  var second = num % 10;

  return good.has(first) && good.has(second)
    && (second * 10 + first) < h;
}

function findNextGood(hc, mc, h, m) {
  while (!isGoodH(hc , m)) {
    hc++;
    mc = 0;
    if (hc >= h) {
      hc = 0;
    }
  }
  var hours = hc;
  var ph = hours > 9 ? String(hours) : '0' + hours;
  while (!isGoodM(mc , h)) {
    mc++;
    if (mc >= m) {
      mc = 0;
    }
  }
  var minutes = mc;
  var pm = minutes > 9 ? String(minutes) : '0' + minutes;
  return ph + ':' + pm;
}
main();

function readStringArray() {
  return readline().split(" ");
}
function readNumArray() {
  return readStringArray().map(Number);
}

var good = new Set([0, 1, 2, 5, 8]);

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var hm = readNumArray();
    var h = hm[0];
    var m = hm[1];
    var hcmc = readline().split(':').map(Number);
    var hc = hcmc[0];
    var mc = hcmc[1];
    print(findNextGood(hc, mc, h, m));
  }
}

function isGoodH(num, m) {
  var first = Math.floor(num / 10);
  var second = num % 10;

  return good.has(first) && good.has(second)
    && (second * 10 + first) < m;
}

function isGoodM(num, h) {
  var first = Math.floor(num / 10);
  var second = num % 10;

  return good.has(first) && good.has(second)
    && (second * 10 + first) < h;
}

function findNextGood(hc, mc, h, m) {
  while (!isGoodH(hc , m)) {
    hc++;
    if (hc >= h) {
      hc = 0;
    }
  }
  var hours = hc;
  var ph = hours > 9 ? String(hours) : '0' + hours;
  while (!isGoodM(mc , h)) {
    mc++;
    if (mc >= m) {
      mc = 0;
    }
  }
  var minutes = mc;
  var pm = minutes > 9 ? String(minutes) : '0' + minutes;
  return ph + ':' + pm;
}
main();


"use strict";

/*
var write = console.log.bind();
var k = 0;
var readline = function() {

	switch ( k++ ) {
		case 0: return '4 4'
		case 1: return '0 0 0 0'
		case 2: return '1 0 0 1'
		case 3: return '0 1 1 0'
		case 4: return '0 1 0 0'
	}
};
*/

let input = readline().split(' ').map(e => +e);
let n = input[0],
	m = input[1];

let grid = [];

for ( let i = 0; i < n; i++ )
	grid.push(readline().split(' ').map(e => +e));

let accum = 0, dir;

for ( let i = 0; i < n; i++ ) {
	dir = false;
	for ( let j = 0; j < m; j++ ) {
		if ( dir && grid[i][j] === 0 )
			accum++;
		else if ( grid[i][j] === 1 )
			dir = true;
	}
}

for ( let i = 0; i < n; i++ ) {
	dir = false;
	for ( let j = m-1; j >= 0; j-- ) {
		if ( dir && grid[i][j] === 0 )
			accum++;
		else if ( grid[i][j] === 1 )
			dir = true;
	}
}

for ( let i = 0; i < m; i++ ) {
	dir = false;
	for ( let j = 0; j < n; j++ ) {
		if ( dir && grid[j][i] === 0 )
			accum++;
		else if ( grid[j][i] === 1 )
			dir = true;
	}
}

for ( let i = 0; i < m; i++ ) {
	dir = false;
	for ( let j = n-1; j >= 0; j-- ) {
		if ( dir && grid[j][i] === 0 )
			accum++;
		else if ( grid[j][i] === 1 )
			dir = true;
	}
}

write(accum);

const mapSize = readline().split(" ").map(x => Number(x));
const height = mapSize[0];
const width = mapSize[1];
const map = new Array(height);
const createCell = cell => cell.charCodeAt(0) === 48 /* 0 */;
for (var y = 0; y < height; y++)
  map[y] = readline().split(" ").slice(0, width).map(createCell);
var result = 0;
for (var y = 0; y < height; y++) {
  var row = map[y];
  for (var x = 0; x < width; x++) {
    if (row[x]) continue;
    var cy;
    var cx;
    for (cy = y - 1; cy >= 0 && map[cy][x]; cy--)
      result++;
    for (cy = y + 1; cy < height && map[cy][x]; cy++)
      result++;
    for (cx = x - 1; cx >= 0 && row[cx]; cx--)
      result++;
    for (cx = x + 1; cx < width && row[cx]; cx++)
      result++;
  }
}
print(result);

var input = readline()
  .split(" ")
  .map((val) => parseInt(val));
var n = input[0],
  m = input[1];
var theater = [];
for (var i = 0; i < n; i++) {
  var inp = readline()
    .split(" ")
    .map((val) => parseInt(val));
  theater.push(inp);
}
var count = 0;
for (var i = 0; i < n; i++) {
  for (var j = 0; j < m; j++) {
    if (theater[i][j] == 1) {
      var left = j - 1,
        top = i - 1,
        bottom = i + 1;
      while (left >= 0) {
        if (theater[i][left] == 0) count++;
        if (theater[i][left] == 1) break;
        left--;
      }
      while (top >= 0) {
        if (theater[top][j] == 0) count++;
        if (theater[top][j] == 1) break;
        top--;
      }
      while (bottom < n) {
        if (theater[bottom][j] == 0) count++;
        if (theater[bottom][j] == 1) {
          break;
        }
        bottom++;
      }
      j++;

      while (j < m) {
        if (theater[i][j] == 0) count++;
        if (theater[i][j] == 1) {
          j--;
          break;
        }
        j++;
      }
    }
  }
}
print(count);

const mapSize = readline().split(" ").map(x => Number(x));
const height = mapSize[0];
const width = mapSize[1];
const map = new Array(height);
for (var i = 0; i < height; i++)
  map[i] = readline().split(" ").slice(0, width).map(cell => cell == "0");
var result = 0;
for (var y = 0; y < height; y++) {
  var row = map[y];
  for (var x = 0; x < height; x++) {
    if (row[x]) continue;
    var cy;
    var cx;
    for (cy = y - 1; cy >= 0 && map[cy][x]; cy--)
      result++;
    for (cy = y + 1; cy < height && map[cy][x]; cy++)
      result++;
    for (cx = x - 1; cx >= 0 && row[cx]; cx--)
      result++;
    for (cx = x + 1; cx < width && row[cx]; cx++)
      result++;
  }
}
print(result);


for(var t=Number(readline());t;t--){
 var n = readline().trim().split(/\s/).map(x=>Number(x));
 var a = readline().trim().split(/\s/).map(x=>Number(x));
 a.sort((a, b) => a - b);
 var v = 0;
 for(var i=0;(i<n[0])&&(n[1]>=0);i++){
  if(a[i]==v) continue;
  n[1] -= (a[i]-v-1);
  v=a[i];
  if(n[1]<0)v--;
 }
 v+=n[1];
 print(v);
}

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

function main() {

    const c = parseInt(stdin.shift());

    for (let i = 0; i < c; i++) {
        let input1 = stdin.shift().split(" ");
        let n = parseInt(input1[0]);
        let x = parseInt(input1[1]);
        let p = new Array(201).fill(false);
        p[0] = true;
        stdin.shift()
            .split(" ")
            .map(function (x) {p[x] = true;});

        let j = 0;
        while (x > -1) {
            if (!p[j]) {
                x--;
            }
            j++;
        }

        console.log(j - 2);
    }
}

var test = parseInt(readline());
while (test--) {
    var firstInput = readline().split(' ').map(y => parseInt(y));
    var n = firstInput[0]; var x = firstInput[1];
    var secondInput = readline().split(' ').map(x => parseInt(x));
    secondInput.sort((a, b) => a - b)
    var count = 0;
    for (var i = 1; i < n + x; i++) {
        var found = secondInput.find(element => element == i);
        if (!found) {
            count++;
        }
        if (count == x) {
            count = 0;
            break;
        }
    }

    for (var j = i + 1; j < 105; j++) {
        var get = secondInput.find(element => element == j);
        if (!get) break;
    }
    print(j - 1)
}

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

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

  if (c % 2) {
    c++;
    [n, x] = d.split(' ').map(Number);
    return;
  }

  const arr = d.split(' ').map(Number);
  arr.sort((a, b) => a - b);
  let ans = 0;
  let count = 1;

  while (x > 0) {
    if (!arr.includes(count)) {
      x--;

      if (x === 0) {
        while (arr.includes(count + 1)) {
          count++;
        }
      }
    }

    ans = Math.max(ans, count);
    count++;
  }

  console.log(ans);

  c++;
});

// Q:

const readline = require('readline');

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

let input = [];

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

rl.on('close', () => {
    const test = parseInt(input[0]);
    let n, x, a;
    for (let t = 0; t < test; t++) {
        [n, x] = input[2*t + 1].split(' ').map((a) => parseInt(a));
        a = input[2*t + 2].split(' ').map((a) => parseInt(a));
        console.log(solution(a, n, x));
    }
})

function solution(a, n, x) {
    let rankAchieved = Array(n+x).fill(false);
    for (let i = 0; i < n; i++) {
        rankAchieved[a[i]] = true;
    }
    for (let k = n+x; k > 0; k--) {
        let v = 0;
        for (let i = 1; i <= k; i++) {
            if (!rankAchieved[i]) {
                v += 1;
            }
        }
        if (v <= x) {
            return k;
        }
    }
}

var test = parseInt(readline());
while (test--) {
    var firstInput = readline().split(' ').map(y => parseInt(y));
    var n = firstInput[0]; var x = firstInput[1];
    var secondInput = readline().split(' ').map(x => parseInt(x));
    secondInput.sort((a, b) => a - b)
    var count = 0;
    for (var i = 1; i < n + x; i++) {
        var found = secondInput.find(element => element == i);
        if (!found) {
            count++;
        }
        if (count == x) {
            count = 0;
            break;
        }
    }

    var get = secondInput.find(element => element == i + 1);
    if (get) print(i + 1);
    else print(i);
}

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

function main() {

    const c = parseInt(stdin.shift());

    for (let i = 0; i < c; i++) {
        let input1 = stdin.shift().split(" ");
        let n = parseInt(input1[0]);
        let x = parseInt(input1[1]);
        let p = new Array(201).fill(false);
        p[0] = true;
        stdin.shift()
            .split(" ")
            .map(function (x) {p[x] = true;});

        let j = 0;
        while (x > -1) {
            if (!p[j]) {
                x--;
            }
            j++;
        }

        console.log(j);
    }
}


function main() {
    var line = readline().split(' ').map(Number);
    var n = line[0];
    var t = line[1];
    var time = t;
    var data = readline().split(' ').map(Number);
    var start = 0;
    var i=0;
    var max = 0;
    var res = 0;
    while(i < n){
        while(t - data[i] < 0 && data[i] <= time){
            t += data[start];
            res--;
            start++;
        }
        if(data[i] <= time){
        t-=data[i];
        res++;
        }
        if(res>max){
            max = res;
        }
        i++
    }
    print(max)
}

main()

(function main() {
    var toInt = function(x) {
        return parseInt(x);
    }
    var firstline = readline().split(" ").map(toInt);
    var n = firstline[0],
        t = firstline[1];

    var ar = readline().split(" ").map(toInt);
    // NOT ar.sort(function(a, b){return a-b});

    ar.reduce(function(sum, next, id, array) {
        var tmp = sum + next;
        array[id] = tmp;
        return tmp;
    });

    ar.splice(0,0,0);

    print((function() {
        function binarysearch(end) {
            var left = 0,
            right = end;
            var mid;
            while (left <= right) {
                mid = Math.floor((left + right) /2);
                var sub = ar[end] - ar[mid];

                if (sub == t) {
                    return end - mid;
                } else if (sub > t) {
                    left = mid + 1;
                } else {
                    right = mid;
                    if (left == right) {
                        return end - mid;
                    }
                }
            }
        }
        var count = -1;
        for(var i = 1; i < ar.length; ++i) {
            var tmp = binarysearch(i);
            if (count < tmp)
                count = tmp;
        }
        if (count > -1)
            return count;
        return 0;
    })());
})();

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

var n = parseInt(line[0]);
var t = parseInt(line[1]);

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

var max = 0;
books[-1] = 0;
var j = -1;
var total = 0;
for(var i = 0; i < n; i++ ) {
    if(j == n){
        break;
    }
    if(i == j) {
        i++;
    }
    if(parseInt(books[i]) + total <= t){
        if(i - j  > max){
            max = i - j ;
        }
        total +=parseInt(books[i]);
    } else {
        if(total != 0){
            total -= parseInt(books[j+1]);
        }
        j++;
        i--;
    }
}

print(max);

;(function () {

	print(function(n, t) {
		var a = readline().split(' ').map(Number), ret = 0;

		for (var i = 0, j = 0, s = 0; i < n; i++) {
			s += a[i];
			while (s > t) s -= a[j++];
			ret = Math.max(ret, i - j + 1);
		}

		return ret;
	}.apply(null, readline().split(' ').map(Number)));

}).call(this);

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

// Make a Snippet for the code above this and then write your logic in main()
function main() {
  const input = readline().split(' ').map(Number)
  const [numOfBooks, freeMinutes] = input
  const books = readline().split(' ').map(Number)
  helper(numOfBooks, freeMinutes, books)
}

function helper(numOfBooks, freeMinutes, books) {
  let left = 0
  let right = 0
  let sum = 0
  let max = 0
  while (right < numOfBooks) {
    if (sum + books[right] <= freeMinutes) {
      sum += books[right]
      right++
    } else {
      max = Math.max(right - left, max)
      sum -= books[left]
      left++
    }
  }

  console.log(Math.max(right - left, max))
}

print(function(n, t) {
	var a = rn(),
		l = 0,
		r = 0,
		sum = 0,
		ans = 0;
	while (r < n) {
		sum += a[r++];
		while (sum > t)
			sum -= a[l++];
		if (r - l > ans)
			ans = r - l;
	}
	return ans;
}.apply(0, rn()));

function rn() {
	return readline().split(' ').map(Number);
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function printResult(x) {
    process.stdout.write(x);
}

function main() {
    const nm = readLine().split(' ').map(Number);
    const arr = readLine().split(' ').map(Number);

    const n = nm[0];
    const m = nm[1];

    // console.log(nm, requirements, complexities)
    const result = books(n, m, arr);
    printResult(result.toString());
}

const books = (n, m, a) => {
    let left = 0;
    let right = 0;
    let count = 0;
    let sum = 0;
    for (let i = 0; i < n; i++) {
        left = i;
        sum += a[left];

        if (left === right) {
            if (a[left] > m) {
                if (right === n - 1) break;
                right++;
                sum = 0;
                continue;
            } else if (a[left] === m) {
                count = Math.max(count, 1);
                if (right === n - 1) break;
                right++;
                sum = 0;
                continue;
            } else {
                if (right === n - 1) {
                    count = Math.max(count, 1);
                    break;
                }
                right++;
            }
        }
        while (right < n) {
            if (a[right] === m) {
                count = right - left > 1 ? Math.max(count, right - left) : 1;
                i = right;
                right++;
                sum = 0;
                break;
            } else if (a[right] > m) {
                count = right > left ? Math.max(count, right - left) : 0;
                i = right;
                right++;
                sum = 0;
                break;
            }
            sum += a[right];
            if (sum < m) {
                if (right === n - 1) return Math.max(count, right - left + 1);
                right++;
            } else if (sum === m) {
                count = right > left ? Math.max(count, right - left + 1) : 1;
                if (count === m || right === n - 1) return count;
                if (count > 1) {
                    sum = sum - (a[left] + a[left + 1]);
                } else if (count === 1) {
                    sum = 0;
                } else {
                    sum = 0;
                }

                right++;
                break;
            } else {
                count = right > left ? Math.max(count, right - left) : 0;
                if (count === m || right === n - 1) return count;
                if (count > 1) {
                    sum = sum - (a[left] + a[left + 1]);
                } else if (count === 1) {
                    sum = 0;
                } else {
                    sum = 0;
                }
                right++
                break;
            }
        }
    }

    return count;
};

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function printResult(x) {
    process.stdout.write(x);
}

function main() {
    const nm = readLine().split(' ').map(Number);
    const arr = readLine().split(' ').map(Number);

    const n = nm[0];
    const m = nm[1];

    const result = books(n, m, arr);
    printResult(result.toString());
}

const books = (n, m, a) => {
    let left = 0;
    let right = 0;
    let count = 0;
    let sum = 0;
    for (let i = 0; i < n; i++) {
        left = i;
        sum += a[left];

        if (left === right) {
            if (a[left] >= m) {
                if (a[left] === m) count = Math.max(count, 1);
                if (right === n - 1) break;
                sum = 0;
                right++;
                continue;
            } else {
                if (right === n - 1) {
                    count = Math.max(count, 1);
                    break;
                }
                right++;
            }
        }
        while (right < n) {
            if (a[right] >= m) {
                if (a[right] === m) count = right - left > 1 ? Math.max(count, right - left) : 1;
                else count = right > left ? Math.max(count, right - left) : 0;

                i = right;
                right++;
                sum = 0;
                break;
            }

            sum += a[right];
            if (sum < m) {
                if (right === n - 1) return Math.max(count, right - left + 1);
                right++;
            } else {
                if (sum === m) count = right > left ? Math.max(count, right - left + 1) : 1;
                else count = right > left ? Math.max(count, right - left) : 0;

                if (count === m || right === n - 1) return count;

                sum = count > 1 ? sum - (a[left] + a[left + 1]) : 0;
                right++;
                break;
            }
        }
    }

    return count;
};

print(function(n, t) {
	var a = rn(),
		l = 0,
		r = 0,
		sum = 0,
		ans = 0;
	while (r < n) {
		sum += a[r++];
		while (sum > t)
			sum -= a[l++];
		ans = Math.max(r - l, ans);
	}
	return ans;
}.apply(0, rn()));

function rn() {
	return readline().split(' ').map(Number);
}

print(function(n, t) {
	var s = 0;
	var a = readline().split(' ').map(Number);
	var b = new Int32Array(n + 1);
	var ans = 0;
	for (var i = 0; i < n; i++)
		b[i + 1] = b[i] + a[i];

	for (var i = 1; i <= n; i++) {
		var x = findCeil(b, b[i] - t, 0, n);
		if (x > -1) {
			ans = Math.max(ans, i - x);
		}
	}

	return ans;

}.apply(0, readline().split(' ').map(Number)));

function findCeil(a, v, l, h) {
	var m;
	if (v <= a[l]) return l;
	if (v > a[h]) return -1;
	while (l <= h) {
		m = l + h >> 1;
		if (v <= a[m]) {
			if (v > a[m - 1]) return m;
			else h = m - 1;
		} else {
			if (v <= a[m + 1]) return m + 1;
			else l = m + 1;
		}
	}
	return -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 printResult(x) {
    process.stdout.write(x);
}

function main() {
    const nm = readLine().split(' ').map(Number);
    const arr = readLine().split(' ').map(Number);

    const n = nm[0];
    const m = nm[1];

    const result = books(n, m, arr);
    printResult(result.toString());
}

const books = (n, m, a) => {
    let left = 0;
    let right = 0;
    let count = 0;
    let sum = 0;
    for (let i = 0; i < n; i++) {
        left = i;
        sum += a[left];

        if (left === right) {
            if (a[left] >= m) {
                if (a[left] === m) count = Math.max(count, 1);
                if (right === n - 1) break;
                sum = 0;
                right++;
                continue;
            } else {
                if (right === n - 1) {
                    count = Math.max(count, 1);
                    break;
                }
                right++;
            }
        }
        while (right < n) {
            if (a[right] >= m) {
                if (a[right] === m) {
                    count = right - left > 1 ? Math.max(count, right - left) : 1;
                } else {
                    count = right > left ? Math.max(count, right - left) : 0;
                }

                i = right;
                right++;
                sum = 0;
                break;
            }

            sum += a[right];
            if (sum < m) {
                if (right === n - 1) return Math.max(count, right - left + 1);
                right++;
            } else {
                if (sum === m) {
                    count = right > left ? Math.max(count, right - left + 1) : 1;
                } else {
                    count = right > left ? Math.max(count, right - left) : 0;
                }

                if (count === m || right === n - 1) return count;

                sum = count > 1 ? sum - (a[left] + a[left + 1]) : 0;
                right++;
                break;
            }
        }
    }

    return count;
};

function rda(){ return readline().split(" ").map(Number); }
function rdn(){ return Number(readline()); }

var a = rda(), n = a[0], t = a[1];
a = rda();

for(var i = 0, s = 0; i < n; i++){
    s += a[i];
    a[i] = s;
}

var ans = 0;

for(var i = 0, j = 0; j < n; ){
    var x = (i == 0) ? (a[j]) : (a[j]-a[i-1]);
    if(x <= t){
        j++;
        ans++;
    }else{
        i++;
        j++;
    }
}

write(ans);

var l=readline().split(' ');
var n=+l[0];
var t=+l[1];
var a=readline().split(' ')
	.map(function(v){return+v;})
	.sort(function(a,b){return a-b});
var ans=0;
var sum=0;
for(var i=0;i<n;i++){
	sum+=a[i];
	if(sum>t){
		break;
	}else{
		ans++;
	}
}
print(ans);

print(function(n, t) {
	var s = 0;
	var a = readline().split(' ').map(Number);
	var b = new Int32Array(n + 1);
	var ans = 0;
	for (var i = 0; i < n; i++)
		b[i + 1] = b[i] + a[i];

	for (var i = 1; i <= n; i++) {
		var x = find(b[i] - t);
		if (x > -1) {
			ans = Math.max(ans, i - x);
		}
	}

	return ans;

	function find(v) {
		var mid, low = 0,
			high = n;
		if (v <= b[low]) return low;
		if (v > b[high]) return -1;
		if (v == b[high]) return n;
		while (low < high) {
			mid = ~~ ((low + high) / 2);
			if (v >= b[mid]) {
				if (v < b[mid + 1]) return mid + 1;
				low = mid;
			} else {
				if (v >= b[mid - 1]) return mid;
				high = mid;
			}
		}
	}

}.apply(0, readline().split(' ').map(Number)));

print(function(n, t) {
	var s = 0;
	var a = readline().split(' ').map(Number);
	var b = new Int32Array(n + 1);
	var ans = 0;
	for (var i = 0; i < n; i++)
		b[i + 1] = b[i] + a[i];

	for (var i = 1; i <= n; i++) {
		var x = find(b[i] - t);
		if (x > -1) {
			ans = Math.max(ans, i - x);
		}
	}

	return ans;

	function find(v) {
		var mid, low = 0,
			high = n;
		if (v < b[low]) return -1;
		if (v > b[high]) return -1;
		if (v == b[high]) return n;
		while (low < high) {
			mid = ~~ ((low + high) / 2);
			if (v >= b[mid]) {
				if (v < b[mid + 1]) return mid + 1;
				low = mid;
			} else {
				if (v >= b[mid - 1]) return mid;
				high = mid;
			}
		}
	}

}.apply(0, readline().split(' ').map(Number)));

function rda(){ return readline().split(" ").map(Number); }
function rdn(){ return Number(readline()); }

var a = rda(), n = a[0], t = a[1];
a = rda();

for(var i = 0, s = 0; i < n; i++){
    s += a[i];
    a[i] = s;
}

var ans = 0;
if(t >= a[0]) ans++;

for(var i = 0, j = 1; j < n; ){
    var x = (i == 0) ? (a[j]) : (a[j]-a[i-1]);
    if(x <= t){
        j++;
        ans++;
    }else{
        i++;
        j++;
    }
}

write(ans);

function rda(){ return readline().split(" ").map(Number); }
function rdn(){ return Number(readline()); }

var a = rda(), n = a[0], t = a[1];
a = rda().sort(function(x, y){ return x-y; });

for(var i = 0, s = 0; i < n; i++){
    s += a[i];
    a[i] = s;
}

var ans = 0;
if(t >= a[0]) ans++;

for(var i = 0, j = 1; j < n; ){
    if(a[j] <= t){
        j++;
        ans++;
    }else{
        i++;
        j++;
    }
}

write(ans);

function rda(){ return readline().split(" ").map(Number); }
function rdn(){ return Number(readline()); }

var a = rda(), n = a[0], t = a[1];
a = rda();

for(var i = 0, s = 0; i < n; i++){
    s += a[i];
    a[i] = s;
}

var ans = 0;
if(t >= a[0]) ans++;

for(var i = 0, j = 1; j < n; ){
    var x = (i == 0) ? (a[j]) : (a[j]-a[i-1]);
    if(x <= t){
        j++;
        ans++;
    }else{
        i++;
        j++;
    }
    print(i, j, ans);
}

write(ans);

var input = readline().split(" ").map(Number), n = input[0], t = input[1], a = readline().split(" ").map(Number);
var counter = 0, ans;

a = a.filter(function(number){
	return !(number > t);
});
n = a.length;

a.sort(function(x,y){return x-y});

if(n == 0){
	ans = n;
}
else{
	for(var i = 0; i < n; i++){
		counter += a[i];
		if(counter > t){
			ans = i;
			break;
		}
	}

	if(counter <= t){
		ans = n;
	}

}

write(ans);

(function main() {
    var toInt = function(x) {
        return parseInt(x);
    }
    // ar = [2, 10];
    // t = 10;
    var firstline = readline().split(" ").map(toInt);
    var n = firstline[0],
        t = firstline[1];

    var ar = readline().split(" ").map(toInt);
    ar.sort(function(a, b){return a-b});

    ar.reduce(function(sum, next, id, array) {
        var tmp = sum + next;
        array[id] = tmp;
        return tmp;
    });

    print((function() {
        var left = 0,
            right = ar.length-1;
        var mid, old_mid= -1;
        while (left <= right) {
            mid = Math.floor((left + right) / 2);
            if (ar[mid] < t) {
                if (old_mid == mid) {
                    if (ar[old_mid + 1] < t)
                        return old_mid + 1;
                    return mid;
                }
                left = mid;
            } else if (ar[mid] == t) {
                return mid;
            } else {
                right = mid - 1;
            }
            old_mid = mid;
        }
        return -1;
    })()+1);
})();

(function main() {
    var toInt = function(x) {
        return parseInt(x);
    }
    var firstline = readline().split(" ").map(toInt);
    var n = firstline[0],
        t = firstline[1];

    var ar = readline().split(" ").map(toInt);
    ar.sort();

    ar.reduce(function(sum, next, id, array) {
        var tmp = sum + next;
        array[id] = tmp;
        return tmp;
    });

    print((function() {
        var left = 0,
            right = ar.length-1;
        var mid, old_mid= -1;
        while (left <= right) {
            mid = Math.floor((left + right) / 2);
            if (ar[mid] < t) {
                if (old_mid == mid) {
                    if (ar[old_mid + 1] < t)
                        return old_mid + 1;
                    return mid;
                }
                left = mid;
            } else if (ar[mid] == t) {
                return mid;
            } else {
                right = mid - 1;
            }
            old_mid = mid;
        }
        return -1;
    })()+1);
})();

(function main() {
    var toInt = function(x) {
        return parseInt(x);
    }
    var firstline = readline().split(" ").map(toInt);
    var n = firstline[0],
        t = firstline[1];

    var ar = readline().split(" ").map(toInt);

    ar.sort();

    ar.reduce(function(sum, next, id, array) {
        var tmp = sum + next;
        array[id] = tmp;
        return tmp;
    });

    print((function() {
        var left = 0,
            right = ar.length-1;
        var mid, old_mid= -1;
        while (left <= right) {
            mid = (left + right) / 2;
            if (ar[mid] < t) {
                if (old_mid == mid) {
                    if (ar[old_mid + 1] < t)
                        return old_mid + 1;
                    return mid;
                }
                left = mid;
            } else if (ar[mid] == t) {
                return mid;
            } else {
                right = mid - 1;
            }
            old_mid = mid;
        }
    })());
})();

(function main() {
    var toInt = function(x) {
        return parseInt(x);
    }
    var firstline = readline().split(" ").map(toInt);
    var n = firstline[0],
        t = firstline[1];

    var ar = readline().split(" ").map(toInt);

    ar.sort();

    ar.reduce(function(sum, next, id, array) {
        var tmp = sum + next;
        array[id] = tmp;
        return tmp;
    });

    print((function() {
        var left = 0,
            right = ar.length;
        var mid = (left + right) / 2,
            old_mid;
        while (left <= right) {
            if (ar[mid] < t) {
                if (old_mid == mid) {
                    if (ar[old_mid + 1] < t)
                        return ar[old_mid + 1];
                    return ar[mid];
                }
                left = mid;
            } else if (ar[mid] == t) {
                return ar[mid];
            } else {
                right = mid - 1;
            }
            old_mid = mid;
        }
    })());
})();

(function main() {
    var toInt = function(x) {
        return parseInt(x);
    }
    var firstline = readline().split(" ").map(toInt);
    var n = firstline[0],
        t = firstline[1];

    var ar = readline().split(" ").map(toInt);
    ar.sort();

    ar.reduce(function(sum, next, id, array) {
        var tmp = sum + next;
        array[id] = tmp;
        return tmp;
    });

    print((function() {
        var left = 0,
            right = ar.length-1;
        var mid, old_mid= -1;
        while (left <= right) {
            mid = Math.floor((left + right) / 2);
            if (ar[mid] < t) {
                if (old_mid == mid) {
                    if (ar[old_mid + 1] < t)
                        return old_mid + 1;
                    return mid;
                }
                left = mid;
            } else if (ar[mid] == t) {
                return mid;
            } else {
                right = mid - 1;
            }
            old_mid = mid;
        }
        return left;
    })()+1);
})();

(function main() {
    var toInt = function(x) {
        return parseInt(x);
    }
    // ar = [6, 4];
    // t = 10;
    var firstline = readline().split(" ").map(toInt);
    var n = firstline[0],
        t = firstline[1];

    var ar = readline().split(" ").map(toInt);
    ar.sort(function(a, b){return a-b});

    ar.reduce(function(sum, next, id, array) {
        var tmp = sum + next;
        array[id] = tmp;
        return tmp;
    });

    print((function() {
        var left = 0,
            right = ar.length-1;
        var mid, old_mid= -1;
        while (left <= right) {
            mid = Math.floor((left + right) / 2);
            if (ar[mid] < t) {
                if (old_mid == mid) {
                    if (ar[old_mid + 1] <= t)
                        return old_mid + 1;
                    return mid;
                }
                left = mid;
            } else if (ar[mid] == t) {
                return mid;
            } else {
                right = mid - 1;
            }
            old_mid = mid;
        }
        return -1;
    })()+1);
})();

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

var n = parseInt(line[0]);
var t = parseInt(line[1]);

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

var max = 0;
books[-1] = 0;
var j = -1;
var total = 0;
for(var i = 0; i < n; i++ ) {
    if(j == n){
        break;
    }
    if(i == j) {
        i++;
    }
    if(parseInt(books[i]) + total <= t){
        if(i - j  > max){
            max = i - j ;
        }
        total +=parseInt(books[i]);
    } else {
        if(total != 0){
            total -= parseInt(books[j-1]);
        }
        j++;
        i--;
    }
}

print(max);

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

var n = parseInt(line[0]);
var t = parseInt(line[1]);

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

var max = 0;
books[-1] = 0;
var j = -1;
var total = 0;
for(var i = 0; i < n; i++ ) {
    if(j == n){
        break;
    }
    if(i == j) {
        i++;
    }
    if(parseInt(books[i]) + total <= t){
        if(i - j  > max){
            max = i - j ;
        }
        total +=parseInt(books[i]);
    } else {
        total -= parseInt(books[j]);
        j++;
        i--;
    }
}

print(max);

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

var n = parseInt(line[0]);
var t = parseInt(line[1]);

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

var times = {};

times[0] = 0;

for(var i = 0; i < n; i++ ){
    times[i+1] = times[i] + parseInt(books[i]);
}

var max = 0;
for(var i = 0; i < n; i++) {
    for(var j=n-1; j > 0; j--){
        if(times[j]  - times[i] <= t && j - i + 1 > max){
            max = j - i + 1;
        }
    }
}

print(max);

function main() {
    var line = readline().split(' ').map(Number);
    var n = line[0];
    var t = line[1];
    var time = t;
    var data = readline().split(' ').map(Number);
    var start = 0;
    var i=0;
    var max = 0;
    var res = 0;
    while(i < n){
        while(t - data[i] < 0 && data[i] <= time){
            t += data[start];
            res--;
            start++;
        }
        t-=data[i];
        res++;
        if(res>max){
            max = res;
        }
        i++
    }
    print(max)
}

main()

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

// Make a Snippet for the code above this and then write your logic in main()
function main() {
  const input = readline().split(' ').map(Number)
  const [numOfBooks, freeMinutes] = input
  const books = readline().split(' ').map(Number)
  helper(numOfBooks, freeMinutes, books)
}

function helper(numOfBooks, freeMinutes, books) {
  let left = 0
  let right = 0
  let sum = 0
  let max = 0
  while (right < numOfBooks) {
    if (sum + books[right] < freeMinutes) {
      sum += books[right]
      right++
    } else {
      max = Math.max(right - left, max)
      sum -= books[left]
      left++
    }
  }

  console.log(Math.max(right - left, max))
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function printResult(x) {
    process.stdout.write(x);
}

function main() {
    const nm = readLine().split(' ').map(Number);
    const arr = readLine().split(' ').map(Number);

    const n = nm[0];
    const m = nm[1];

    // console.log(nm, requirements, complexities)
    const result = books(n, m, arr);
    printResult(result.toString());
}

const books = (n, m, a) => {
    let left = 0;
    let right = 0;
    let count = 0;
    let sum = 0;
    for (let i = 0; i < n; i++) {
        left = i;
        sum += a[left];

        if (left === right) {
            if (a[left] > m) {
                if (right === n - 1) break;
                right++;
                sum = 0;
                continue;
            } else if (a[left] === m) {
                count = Math.max(count, 1);
                if (right === n - 1) break;
                right++;
                sum = 0;
                continue;
            } else {
                if (right === n - 1) break;
                right++;
            }
        }
        while (right < n) {
            if (a[right] === m) {
                count = right - left > 1 ? Math.max(count, right - left) : 1;
                i = right;
                right++;
                sum = 0;
                break;
            } else if (a[right] > m) {
                count = right > left ? Math.max(count, right - left) : 0;
                i = right;
                right++;
                sum = 0;
                break;
            }
            sum += a[right];
            if (sum < m) {
                if (right === n - 1) return Math.max(count, right - left + 1);
                right++;
            } else if (sum === m) {
                count = right > left ? Math.max(count, right - left + 1) : 1;
                if (count === m || right === n - 1) return count;
                if (count > 1) {
                    sum = sum - (a[left] + a[left + 1]);
                } else if (count === 1) {
                    sum = 0;
                } else {
                    sum = 0;
                }

                right++;
                break;
            } else {
                count = right > left ? Math.max(count, right - left) : 0;
                if (count === m || right === n - 1) return count;
                if (count > 1) {
                    sum = sum - (a[left] + a[left + 1]);
                } else if (count === 1) {
                    sum = 0;
                } else {
                    sum = 0;
                }
                right++
                break;
            }
        }
    }

    return count;
};

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function printResult(x) {
    process.stdout.write(x);
}

function main() {
    const nm = readLine().split(' ').map(Number);
    const arr = readLine().split(' ').map(Number);

    const n = nm[0];
    const m = nm[1];

    const result = books(n, m, arr);
    printResult(result.toString());
}

const books = (n, m, a) => {
    let left = 0;
    let right = 0;
    let count = 0;
    let sum = 0;
    for (let i = 0; i < n; i++) {
        left = i;
        sum += a[left];

        if (left === right) {
            if (a[left] >= m) {
                if (a[left] === m) count = Math.max(count, 1);
                if (right === n - 1) break;
                sum = 0;
                continue;
            } else {
                if (right === n - 1) {
                    count = Math.max(count, 1);
                    break;
                }
                right++;
            }
        }
        while (right < n) {
            if (a[right] >= m) {
                if (a[right] === m) {
                    count = right - left > 1 ? Math.max(count, right - left) : 1;
                } else {
                    count = right > left ? Math.max(count, right - left) : 0;
                }

                i = right;
                right++;
                sum = 0;
                break;
            }

            sum += a[right];
            if (sum < m) {
                if (right === n - 1) return Math.max(count, right - left + 1);
                right++;
            } else if (sum >= m) {
                if (sum === m) {
                    count = right > left ? Math.max(count, right - left + 1) : 1;
                } else {
                    count = right > left ? Math.max(count, right - left) : 0;
                }

                if (count === m || right === n - 1) return count;

                sum = count > 1 ? sum - (a[left] + a[left + 1]) : 0;
                right++;
                break;
            }
        }
    }

    return count;
};

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function printResult(x) {
    process.stdout.write(x);
}

function main() {
    const nm = readLine().split(' ').map(Number);
    const arr = readLine().split(' ').map(Number);

    const n = nm[0];
    const m = nm[1];

    const result = books(n, m, arr);
    printResult(result.toString());
}

const books = (n, m, a) => {
    let left = 0;
    let right = 0;
    let count = 0;
    let sum = 0;
    for (let i = 0; i < n; i++) {
        left = i;
        sum += a[left];

        if (left === right) {
            if (a[left] >= m) {
                if (a[left] === m) count = Math.max(count, 1);
                if (right === n - 1) break;
                sum = 0;
                continue;
            } else {
                if (right === n - 1) {
                    count = Math.max(count, 1);
                    break;
                }
                right++;
            }
        }
        while (right < n) {
            if (a[right] >= m) {
                if (a[right] === m) count = right - left > 1 ? Math.max(count, right - left) : 1;
                else count = right > left ? Math.max(count, right - left) : 0;

                i = right;
                right++;
                sum = 0;
                break;
            }

            sum += a[right];
            if (sum < m) {
                if (right === n - 1) return Math.max(count, right - left + 1);
                right++;
            } else if (sum >= m) {
                if (sum === m) count = right > left ? Math.max(count, right - left + 1) : 1;
                else count = right > left ? Math.max(count, right - left) : 0;

                if (count === m || right === n - 1) return count;

                sum = count > 1 ? sum - (a[left] + a[left + 1]) : 0;
                right++;
                break;
            }
        }
    }

    return count;
};

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function printResult(x) {
    process.stdout.write(x);
}

function main() {
    const nm = readLine().split(' ').map(Number);
    const arr = readLine().split(' ').map(Number);

    const n = nm[0];
    const m = nm[1];

    const result = books(n, m, arr);
    printResult(result.toString());
}

const books = (n, m, a) => {
    let left = 0;
    let right = 0;
    let count = 0;
    let sum = 0;
    for (let i = 0; i < n; i++) {
        left = i;
        sum += a[left];

        if (left === right) {
            if (a[left] >= m) {
                if (a[left] === m) count = Math.max(count, 1);
                if (right === n - 1) break;
                sum = 0;
                continue;
            } else {
                if (right === n - 1) {
                    count = Math.max(count, 1);
                    break;
                }
                right++;
            }
        }
        while (right < n) {
            if (a[right] >= m) {
                if (a[right] === m) right - left > 1 ? Math.max(count, right - left) : 1;
                else count = right > left ? Math.max(count, right - left) : 0;

                i = right;
                right++;
                sum = 0;
                break;
            }

            sum += a[right];
            if (sum < m) {
                if (right === n - 1) return Math.max(count, right - left + 1);
                right++;
            } else if (sum >= m) {
                if (sum === m) count = right > left ? Math.max(count, right - left + 1) : 1;
                else count = right > left ? Math.max(count, right - left) : 0;

                if (count === m || right === n - 1) return count;

                sum = count > 1 ? sum - (a[left] + a[left + 1]) : 0;
                right++;
                break;
            }
        }
    }

    return count;
};

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function printResult(x) {
    process.stdout.write(x);
}

function main() {
    const nm = readLine().split(' ').map(Number);
    const arr = readLine().split(' ').map(Number);

    const n = nm[0];
    const m = nm[1];

    const result = books(n, m, arr);
    printResult(result.toString());
}

const books = (n, m, a) => {
    let left = 0;
    let right = 0;
    let count = 0;
    let sum = 0;
    for (let i = 0; i < n; i++) {
        left = i;
        sum += a[left];
        if (left === right) {
            if (a[left] >= m) {
                if (a[left] === m) count = Math.max(count, 1);
                if (right === n - 1) break;
                sum = 0;
                continue;
            } else if (right === n - 1) {
                count = Math.max(count, 1);
                break;
            }
            right++;
        }
        while (right < n) {
            if (a[right] >= m) {
                if (a[right] === m) right - left > 1 ? Math.max(count, right - left) : 1;
                else count = right > left ? Math.max(count, right - left) : 0;

                i = right;
                right++;
                sum = 0;
                break;
            }

            sum += a[right];
            if (sum < m) {
                if (right === n - 1) return Math.max(count, right - left + 1);
                right++;
            } else if (sum >= m) {
                if (sum === m) count = right > left ? Math.max(count, right - left + 1) : 1;
                else count = right > left ? Math.max(count, right - left) : 0;

                if (count === m || right === n - 1) return count;

                sum = count > 1 ? sum - (a[left] + a[left + 1]) : 0;
                right++;
                break;
            }
        }
    }

    return count;
};


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

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

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

  const t = parseInt(arr.shift())

  for(let j = 0; j < t; j++) {
    const s = arr[j],
          len = s.length,
          len2 = len - 2

    let count = 0
    let str = s.split('')
    let ans = ''

    for(let i = 0; i < len2; i ++) {
      // console.log(str[i], i)
      if(str[i] == 'o' && str[i + 1] == 'n' && str[i + 2] == 'e') {
        count ++
        if(ans == '') ans += (i + 1 + 1).toString()
        else ans += ` ${(i + 1 + 1)}`
        str[i + 1] = '1'
        i += 2
      }
      else if(str[i] == 't' && str[i + 1] == 'w' && str[i + 2] == 'o') {
        if(str[i + 3] == 'n' && str[i + 4] == 'e'){
          count ++
          if(ans == '') ans += (i + 2 + 1).toString()
          else ans += ` ${(i + 2 + 1)}`
          str[i + 2] = '1'
          i += 4
        }
        else {
          count ++
          if(ans == '') ans += (i + 1 + 1).toString()
          else ans += ` ${(i + 1 + 1)}`
          str[i + 1] = '1'
          i += 2
        }
      }
    }

    console.log(count)
    console.log(ans)
  }
})

function myout(t){print(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main() {
  var t = myconv(readline(),1);
  var output = new Array(t);
  for(var i = 0; i < t; i++){
      var s = myconv(readline(),6);
      var pos = [];
      //myout(s);
      for(var j = 0; j < s.length; j++){
         var twone = s[j-1]+s[j]+s[j+1]+s[j+2]+s[j+3];
         if(twone == "twone"){
             pos.push(j+2);
             j += 3;
             continue;
         }
         var onetwo = s[j-1]+s[j]+s[j+1];
         if(onetwo == "one" || onetwo == "two"){
             pos.push(j+1);
             continue;
         }
      }
      output[i] = pos.length + "\n" + pos.join(" ");
  }
  myout(output.join("\n"));
}

Main();