You are a paparazzi working in Manhattan.Manhattan has $$$r$$$ south-to-north streets, denoted by numbers $$$1, 2,\ldots, r$$$ in order from west to east, and $$$r$$$ west-to-east streets, denoted by numbers $$$1,2,\ldots,r$$$ in order from south to north. Each of the $$$r$$$ south-to-north streets intersects each of the $$$r$$$ west-to-east streets; the intersection between the $$$x$$$-th south-to-north street and the $$$y$$$-th west-to-east street is denoted by $$$(x, y)$$$. In order to move from the intersection $$$(x,y)$$$ to the intersection $$$(x', y')$$$ you need $$$|x-x'|+|y-y'|$$$ minutes.You know about the presence of $$$n$$$ celebrities in the city and you want to take photos of as many of them as possible. More precisely, for each $$$i=1,\dots, n$$$, you know that the $$$i$$$-th celebrity will be at the intersection $$$(x_i, y_i)$$$ in exactly $$$t_i$$$ minutes from now (and he will stay there for a very short time, so you may take a photo of him only if at the $$$t_i$$$-th minute from now you are at the intersection $$$(x_i, y_i)$$$). You are very good at your job, so you are able to take photos instantaneously. You know that $$$t_i < t_{i+1}$$$ for any $$$i=1,2,\ldots, n-1$$$.Currently you are at your office, which is located at the intersection $$$(1, 1)$$$. If you plan your working day optimally, what is the maximum number of celebrities you can take a photo of?

The first line of the input contains two positive integers $$$r, n$$$ ($$$1\le r\le 500$$$, $$$1\le n\le 100,000$$$) – the number of south-to-north/west-to-east streets and the number of celebrities. Then $$$n$$$ lines follow, each describing the appearance of a celebrity. The $$$i$$$-th of these lines contains $$$3$$$ positive integers $$$t_i, x_i, y_i$$$ ($$$1\le t_i\le 1,000,000$$$, $$$1\le x_i, y_i\le r$$$)  — denoting that the $$$i$$$-th celebrity will appear at the intersection $$$(x_i, y_i)$$$ in $$$t_i$$$ minutes from now. It is guaranteed that $$$t_i<t_{i+1}$$$ for any $$$i=1,2,\ldots, n-1$$$.

Print a single integer, the maximum number of celebrities you can take a photo of.

NoteExplanation of the first testcase: There is only one celebrity in the city, and he will be at intersection $$$(6,8)$$$ exactly $$$11$$$ minutes after the beginning of the working day. Since you are initially at $$$(1,1)$$$ and you need $$$|1-6|+|1-8|=5+7=12$$$ minutes to reach $$$(6,8)$$$ you cannot take a photo of the celebrity. Thus you cannot get any photo and the answer is $$$0$$$.Explanation of the second testcase: One way to take $$$4$$$ photos (which is the maximum possible) is to take photos of celebrities with indexes $$$3, 5, 7, 9$$$ (see the image for a visualization of the strategy):   To move from the office at $$$(1,1)$$$ to the intersection $$$(5,5)$$$ you need $$$|1-5|+|1-5|=4+4=8$$$ minutes, so you arrive at minute $$$8$$$ and you are just in time to take a photo of celebrity $$$3$$$.  Then, just after you have taken a photo of celebrity $$$3$$$, you move toward the intersection $$$(4,4)$$$. You need $$$|5-4|+|5-4|=1+1=2$$$ minutes to go there, so you arrive at minute $$$8+2=10$$$ and you wait until minute $$$12$$$, when celebrity $$$5$$$ appears.  Then, just after you have taken a photo of celebrity $$$5$$$, you go to the intersection $$$(6,6)$$$. You need $$$|4-6|+|4-6|=2+2=4$$$ minutes to go there, so you arrive at minute $$$12+4=16$$$ and you wait until minute $$$17$$$, when celebrity $$$7$$$ appears.  Then, just after you have taken a photo of celebrity $$$7$$$, you go to the intersection $$$(5,4)$$$. You need $$$|6-5|+|6-4|=1+2=3$$$ minutes to go there, so you arrive at minute $$$17+3=20$$$ and you wait until minute $$$21$$$ to take a photo of celebrity $$$9$$$.   Explanation of the third testcase: The only way to take $$$1$$$ photo (which is the maximum possible) is to take a photo of the celebrity with index $$$1$$$ (since $$$|2-1|+|1-1|=1$$$, you can be at intersection $$$(2,1)$$$ after exactly one minute, hence you are just in time to take a photo of celebrity $$$1$$$).Explanation of the fourth testcase: One way to take $$$3$$$ photos (which is the maximum possible) is to take photos of celebrities with indexes $$$3, 8, 10$$$:   To move from the office at $$$(1,1)$$$ to the intersection $$$(101,145)$$$ you need $$$|1-101|+|1-145|=100+144=244$$$ minutes, so you can manage to be there when the celebrity $$$3$$$ appears (at minute $$$341$$$).  Then, just after you have taken a photo of celebrity $$$3$$$, you move toward the intersection $$$(149,379)$$$. You need $$$|101-149|+|145-379|=282$$$ minutes to go there, so you arrive at minute $$$341+282=623$$$ and you wait until minute $$$682$$$, when celebrity $$$8$$$ appears.  Then, just after you have taken a photo of celebrity $$$8$$$, you go to the intersection $$$(157,386)$$$. You need $$$|149-157|+|379-386|=8+7=15$$$ minutes to go there, so you arrive at minute $$$682+15=697$$$ and you wait until minute $$$855$$$ to take a photo of celebrity $$$10$$$.

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

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

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

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
function inv(b, m) {
  for (var a = m, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + m) % m;
}

// let MOD = 1e9 + 7
// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[MOD % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

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

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

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
async function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, { min, max, ceil, floor, sqrt, abs, log2 } = Math, bi = BigInt;
  let [r, n] = $(2), a = Arr(n, i => ({ t: $(), x: $(), y: $(), m: 0, c: -1e5 }));
  let res = 0, kc;
  a.unshift({ t: 0, x: 1, y: 1, m: 0, c: 0 });
  for (let i = 1; i <= n; i++) {
    a[i].m = max(a[i].x - 1, r - a[i].x) + max(a[i].y - 1, r - a[i].y)
  }
  for (let i = 1; i <= n; i++) {
    for (let j = i - 1; j >= max(0,i-2000); j--) {
      kc = abs(a[i].x - a[j].x) + abs(a[i].y - a[j].y);
      // if (a[j].t + a[i].m < a[i].t) break;
      if (a[i].c <= a[j].c && kc + a[j].t <= a[i].t) a[i].c = a[j].c + 1;
      if (a[i].c > res) res = a[i].c;
    }
  }
  // log(a)
  log(res)
}

'use strict';

var readline = require('readline');

function _defineProperty(obj, key, value) {
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }

  return obj;
}

function ownKeys(object, enumerableOnly) {
  var keys = Object.keys(object);

  if (Object.getOwnPropertySymbols) {
    var symbols = Object.getOwnPropertySymbols(object);
    if (enumerableOnly) symbols = symbols.filter(function (sym) {
      return Object.getOwnPropertyDescriptor(object, sym).enumerable;
    });
    keys.push.apply(keys, symbols);
  }

  return keys;
}

function _objectSpread2(target) {
  for (var i = 1; i < arguments.length; i++) {
    var source = arguments[i] != null ? arguments[i] : {};

    if (i % 2) {
      ownKeys(Object(source), true).forEach(function (key) {
        _defineProperty(target, key, source[key]);
      });
    } else if (Object.getOwnPropertyDescriptors) {
      Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
    } else {
      ownKeys(Object(source)).forEach(function (key) {
        Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
      });
    }
  }

  return target;
}

function nInFirstLineArrayStdin(nIndex) {
  return new Promise(resolve => {
    const stdin = readline.createInterface(process.stdin);
    let n;
    let firstLine;
    let output = [];
    stdin.on('line', line => {
      if (typeof n !== 'number') {
        firstLine = line.split(' ').map(Number);
        n = firstLine[nIndex];
      } else {
        output.push(line);

        if (--n === 0) {
          resolve([firstLine, output]);
          stdin.close();
        }
      }
    });
  });
}

function solve(celebs) {
  const scored = [];

  for (let x = 0; x < celebs.length; x++) {
    const current = celebs[x];
    let insertIndex = scored.length;
    let groupScore = -1;
    let inserted = false;

    for (let y = scored.length - 1; y >= 0; y--) {
      const previous = scored[y];

      if (groupScore !== previous.score) {
        insertIndex = y + 1;
        groupScore = previous.score;
      }

      if (Math.abs(current.x - previous.x) + Math.abs(current.y - previous.y) + previous.t <= current.t) {
        scored.splice(insertIndex, 0, _objectSpread2(_objectSpread2({}, current), {}, {
          score: previous.score + 1
        }));
        inserted = true;
        break;
      }
    }

    if (!inserted && current.t >= current.x - 1 + current.y - 1) {
      scored.splice(0, 0, _objectSpread2(_objectSpread2({}, current), {}, {
        score: 1
      }));
    }
  }

  console.log(scored.length ? scored[scored.length - 1].score : 0);
}

async function main() {
  const input = await nInFirstLineArrayStdin(1);
  solve(input[1].map(line => {
    const [t, x, y] = line.split(' ').map(Number);
    return {
      t,
      x,
      y
    };
  }));
}

main().then();

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

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

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

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
function inv(b, m) {
  for (var a = m, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + m) % m;
}

// let MOD = 1e9 + 7
// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[MOD % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

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

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

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
async function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, { min, max, ceil, floor, sqrt, abs, log2 } = Math, bi = BigInt;
  let [r, n] = $(2), a = Arr(n, i => ({ t: $(), x: $(), y: $(), m: 0, c: -1e5 }));
  let res = 0, kc;
  a.unshift({ t: 0, x: 1, y: 1, m: 0, c: 0 });
  for (let i = 1; i <= n; i++) {
    a[i].m = max(a[i].x - 1, r - a[i].x) + max(a[i].y - 1, r - a[i].y)
  }
  for (let i = 1; i <= n; i++) {
    for (let j = i - 1; j >= 0; j--) {
      kc = abs(a[i].x - a[j].x) + abs(a[i].y - a[j].y);
      if (a[j].t + kc < a[i].t) break;
      if (a[i].c <= a[j].c && kc + a[j].t <= a[i].t) a[i].c = a[j].c + 1;
      if (a[i].c > res) res = a[i].c;
    }
  }
  // log(a)
  log(res)
}

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

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

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

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
function inv(b, m) {
  for (var a = m, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + m) % m;
}

// let MOD = 1e9 + 7
// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[MOD % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

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

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

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
async function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, { min, max, ceil, floor, sqrt, abs, log2 } = Math, bi = BigInt;
  let [r, n] = $(2), a = Arr(n, i => ({ t: $(), x: $(), y: $(), m: 0, c: -1e5 }));
  let res = 0, kc;
  a.unshift({ t: 0, x: 1, y: 1, m: 0, c: 0 });
  for (let i = 1; i <= n; i++) {
    a[i].m = max(a[i].x - 1, r - a[i].x) + max(a[i].y - 1, r - a[i].y)
  }
  for (let i = 1; i <= n; i++) {
    for (let j = i - 1; j >= max(0,i-1000); j--) {
      kc = abs(a[i].x - a[j].x) + abs(a[i].y - a[j].y);
      // if (a[j].t + a[i].m < a[i].t) break;
      if (a[i].c <= a[j].c && kc + a[j].t <= a[i].t) a[i].c = a[j].c + 1;
      if (a[i].c > res) res = a[i].c;
    }
  }
  // log(a)
  log(res)
}

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

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

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

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
function inv(b, m) {
  for (var a = m, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + m) % m;
}

// let MOD = 1e9 + 7
// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[MOD % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

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

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

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
async function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, { min, max, ceil, floor, sqrt, abs, log2 } = Math, bi = BigInt;
  let [r, n] = $(2), a = Arr(n, i => ({ t: $(), x: $(), y: $(), m: 0, c: -1e5 }));
  let res = 0, kc;
  a.unshift({ t: 0, x: 1, y: 1, m: 0, c: 0 });
  for (let i = 1; i <= n; i++) {
    a[i].m = max(a[i].x - 1, r - a[i].x) + max(a[i].y - 1, r - a[i].y)
  }
  for (let i = 1; i <= n; i++) {
    for (let j = i - 1; j >= 0; j--) {
      kc = abs(a[i].x - a[j].x) + abs(a[i].y - a[j].y);
      if (a[j].t + a[i].m < a[i].t) break;
      if (a[i].c <= a[j].c && kc + a[j].t <= a[i].t) a[i].c = a[j].c + 1;
      if (a[i].c > res) res = a[i].c;
    }
  }
  // log(a)
  log(res)
}


It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers a1 + 1 to a1 + a2 and so on. See the example for a better understanding.Mole can't eat all the worms (Marmot brought a lot) and, as we all know, Mole is blind, so Marmot tells him the labels of the best juicy worms. Marmot will only give Mole a worm if Mole says correctly in which pile this worm is contained.Poor Mole asks for your help. For all juicy worms said by Marmot, tell Mole the correct answers.

The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot. The fourth line contains m integers q1, q2, ..., qm (1 ≤ qi ≤ a1 + a2 + ... + an), the labels of the juicy worms.

Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.

NoteFor the sample input:  The worms with labels from [1, 2] are in the first pile.  The worms with labels from [3, 9] are in the second pile.  The worms with labels from [10, 12] are in the third pile.  The worms with labels from [13, 16] are in the fourth pile.  The worms with labels from [17, 25] are in the fifth pile.

function sum(array){
	var result = 0;
	for(var i = 0; i < array.length; i++){
		result += +array[i];
	}
	return result;
}

var n = +readline(), a = readline().split(" ").map(Number), m = +readline(),
q = readline().split(" ").map(Number);
var array = [], all = sum(a), cnt = a[0];

for(var i = 1, j = 1; i <= all; i++){
	if(i <= cnt){
		array[i] = j;
	}
	else{
		cnt += a[j];
		j++;
		array[i] = j;
	}
}

for(i = 0; i < m; i++){
	print(array[q[i]]);
}

var x = parseInt(readline());

var arr= readline().split(' ').map(a => parseInt(a));

for(var i=1; i<arr.length; i++){
  arr[i] += arr[i-1];
}

var input = parseInt(readline());
var find= readline().split(' ').map(a => parseInt(a));

for(var index=0; index<input; index++){
  var left=0, right = x-1, found=0;
  while(left<=right){
    var mid = left+Math.floor((right-left)/2);
    if(find[index] === arr[mid]){
      found=1;
      break;
    }else if(find[index]>arr[mid]){
      left=mid+1;
    }else{
      right=mid-1;
    }
  }
  if(found===1)
    print(mid+1);
  else{
    if(right<0 || find[index]>arr[right])
    print(left+1);
    if(left>x-1 || find[index]<arr[right])
    print(right+1);
  }

}

function Bst(arr, x) {
  var start = 0,
    end = arr.length - 1,
    mid;
  while (start < end) {
    mid = Math.floor((start + end) / 2);
    if (x < arr[mid]) end = mid;
    if (x > arr[mid]) start = mid + 1;
    if (x == arr[mid]) return mid + 1;
  }
  return start + 1;
}
/************************************** */

var n = parseInt(readline());
var prev = 0;
var a = readline()
  .split(" ")
  .map((val) => {
    var x = parseInt(val);
    x += prev;
    prev = x;
    return x;
  });
var m = parseInt(readline());
var q = readline()
  .split(" ")
  .map((val) => parseInt(val));

for (var i = 0; i < m; i++) {
  print(Bst(a, q[i]));
}

(function () {
    var heapsCount = parseInt(readline()),
        heaps = readline().split(" "),
        wormsCount = parseInt(readline()),
        worms = readline().split(" "),
        arrayHeaps = [],
        i = 1,
        wholeWorms = [],
        wholeWormsCount, j;

    arrayHeaps.push(parseInt(heaps[0]));
    for (; i < heapsCount; i++) {
        arrayHeaps.push(arrayHeaps[i - 1] + parseInt(heaps[i]));
    }
    wholeWormsCount = arrayHeaps[i - 1];
    j = 0;
    for (i = 0; i < wholeWormsCount + 1; i++) {
        wholeWorms.push(j + 1);
        if (i === arrayHeaps[j]) {
            j++;
        }
    }
    for (i = 0; i < wormsCount; i++) {
        print(wholeWorms[parseInt(worms[i])]);
    }
})();

function ProblemSolver() {

    this.solveCase = function() {
        var res , i , j , a , b , c , lo , hi , mi;
        this.cn = 0;
        res = 0;
        for( i = 0 ; i < this.n ; i++ ) {
            a = this.arr[ i ];
            for( j = 0 ; j < a ; j++ ) {
                this.brr[ this.cn++ ] = i + 1;
            }
        }
        for( i = 0 ; i < this.q ; i++ ) {
            a = this.crr[ i ];
            res = this.brr[ a - 1 ] ;
            print( res );
        }
    };

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

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

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        //this.clearArraysPerCase() ;
    };

    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;

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

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

    this.memsetArray1D = function( arrParam , val ) {
        var i;
        if( arrParam == null ) {
            throw new Error( "No array supplied in the parameter!" );
        }
        if( val == null ) {
            throw new Error( "No value for memset has been supplied in the parameter!" );
        }
        arrParam = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            arrParam.push( val );
        }
        return arrParam;
    };

    this.getStringLength = function( stringData ) {
        var len , lengthType;
        len = stringData.length;
        lengthType = typeof len;
        if( lengthType == "function" ) {
            len = stringData.length();
        }
        else {
            len = stringData.length;
        }
        return len;
    };

    this.init();
}

function InputReader() {
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;

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

    this.readAllLinesFromRhinoStdin = function() {
        importPackage( java.io );
        importPackage( java.lang );
        var singleLine , reader;
        reader = new BufferedReader( new InputStreamReader( System[ "in" ] ) );
        this.allLines = [];
        while( true ) {
            singleLine = reader.readLine();
            if( singleLine != null ) {
                this.allLines.push( singleLine );
            }
            else {
                break;
            }
        }
    };

    this.readAllLinesFromNodeStdin = function() {
        var fsObj , size , rawData;
        process.stdin.setEncoding( 'ascii' );
        fsObj = require( 'fs' );
        size = fsObj.fstatSync( process.stdin.fd ).size;
        rawData = fsObj.readSync( process.stdin.fd , size )[ 0 ];
        this.parseRawData( rawData );
    };

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

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

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

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

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

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

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

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

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

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

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

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

    this.runCode = function() {
        var testCases , i , hasMoreTestCases , isLocalMachine , localContext;
        isLocalMachine = false;
        try {
            if( __dirname != null && __dirname.charAt( 1 ) == ':' ) {
                //only on windows
                isLocalMachine = true;
            }
        }
        catch( ex ) {
            isLocalMachine = false;
        }
        if( isLocalMachine == true ) {
            //local machine runs on node and relies on file i/o
            print = console.log;
            if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
                localContext = this.fohObj;
                print = function() {
                    localContext.addNewLine.apply( localContext , arguments );
                }
            }
            this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );
        }
        else {
            //server machine
            try {
                var rlObj = readline;
                //server runs on javasctipt v8 distribution and has readline method on global context
                this.irObj.readAllLines();
            }
            catch( ex ) {
                try {
                    var pObj = process;
                    //server runs on node
                    print = console.log;
                    this.irObj.readAllLinesFromNodeStdin();
                }
                catch( ex ) {
                    try {
                        var ipObj = importPackage;
                        //server runs on rhino
                        this.irObj.readAllLinesFromRhinoStdin();
                    }
                    catch( ex ) {
                        throw new Error( "Unknown javasctipt distribution!" );
                    }
                }
            }
        }
        if( this.psObj.HAS_TEST_CASES == true ) {
            testCases = this.irObj.nextInt();
            for( i = 0 ; i < testCases ; i++ ) {
                this.psObj.clearPerCase();
                this.psObj.getInput( this.irObj );
                this.psObj.solveCase();
            }
        }
        else {
            while( true ) {
                this.psObj.clearPerCase();
                hasMoreTestCases = this.psObj.getInput( this.irObj );
                if( hasMoreTestCases == false ) {
                    break;
                }
                this.psObj.solveCase();
            }
        }
        if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
            //only works for local machine(tested)
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.runCode();
}

new CodeExecutioner();

var n = Number(readline());
var A = readline().split(' ').map(Number)

var m = Number(readline());
var Q = readline().split(' ').map(Number)

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

var lower_bound = function(A, x) {
    var l = 0;
    var r = A.length - 1;

    while (l <= r) {
        var m = Math.floor((l + r) / 2);
        if (A[m] < x) {
            l = m + 1;
        }
        else {
            r = m - 1;
        }
    }
    return l;
}

for (i in Q) {
    print(lower_bound(A, Q[i]) + 1);
}

var piles_number = readline();
var piles = readline().split(' ');
var expected_worm_numbers = readline();
var expected_worms = readline().split(' ');

var getWormsAfterPile = function(piles_number, piles) {
    var worms_after_piles = [];
    for (i = 0; i < piles_number; i++) {
        var last_worm_after_pile = (i == 0) ? 0 : worms_after_piles[i - 1];
        worms_after_piles[i] = last_worm_after_pile + parseInt(piles[i]);
    }
    return worms_after_piles;
}

var getWormPile = function(worms_after_piles, expected_worm, start) {
    if (worms_after_piles[0] >= expected_worm) {
        return 1;
    }
    for (i = start, worms_after_piles_length = worms_after_piles.length; i < worms_after_piles_length; i++ ) {
        if (worms_after_piles[i] >= expected_worm && worms_after_piles[i-1] < expected_worm) {
            return i+1;
        }
    }
}

var result = [];

var worms_after_piles = getWormsAfterPile(piles_number, piles);
var sorted_expected_worms = expected_worms.concat().sort(function(a, b) {return a - b;});
var last_worm_pile = 1;
for (k = 0; k < expected_worm_numbers; k++) {
    if (result[sorted_expected_worms[k]] != void(0)) {
        continue;
    }
    var worm_pile = getWormPile(worms_after_piles, sorted_expected_worms[k], last_worm_pile - 1);
    last_worm_pile = result[sorted_expected_worms[k]] = worm_pile;
}

for (l = 0; l < expected_worm_numbers; l++) {
    print(result[expected_worms[l]]);
}

var n = readline();
var a = readline().split(" ");
for (p in a){a[p]= parseInt(a[p]);}
var m = readline();
var q = readline().split(" ");
for (o in q){q[o]= parseInt(q[o]);}
var z = [];
var r = 0;
for (j = 0;j<a.length;j++){
		a[j]= parseInt(a[j]);
		for (w=1;w<=a[j];w++)
		z[r++] = j+1;
		}
for (i in q){
	print(z[q[i]-1]);
		}

// 474B     Черви

var n = parseInt(readline());

// var input_line = readline().split(' ').map(Number);
var arrA = readline().split(' ').map(Number);

var m = parseInt(readline());

var arrQ = readline().split(' ').map(Number);

var out ='';

var arrQnew = [];

for (var i = 0; i < m; i++) {
    arrQnew[i] = [];
    arrQnew[i][0] = arrQ[i];
    arrQnew[i][1] = i;
}

arrQnew.sort(function(a,b){return a[0]-b[0];});

var sum = arrA[0];
var jsum = 0;
var arrOut = [];

for (var i = 0; i < m; i++) {
    for (var j = jsum; j < n; j++) {
        if (sum >= arrQnew[i][0]) {
            arrOut[arrQnew[i][1]] = j + 1;
            break;
        } else {
            sum += arrA[j+1];
            jsum = j + 1;
        };
    };
};

for (var i = 0; i < m; i++) {
    out += arrOut[i] + '\n';
};

print(out);

readline()
var A=readline().split(' ').map(Number)
readline()
var Q=readline().split(' ').map(Number)

var T=new Array(A.length + 1)
T[0]=0
for (var i=1; i<T.length; ++i)
    T[i]=T[i-1]+A[i-1];

var find = x => {
    var lb=0,ub=T.length-1;
    while (lb+1<ub) {
        var m=(ub+lb)>>1;
        if (x<=T[m])
            ub=m;
        else if (T[m]<x)
            lb=m;
    }
    return lb;
}

print(Q.map(x => find(x) + 1).join('\n'))

var aMap = {}, aCount = 1, result = [];

var n = parseInt(readline()),
	as = readline().split(/\s/).map(function(a, index)	{
		var i = aCount;

		a = parseInt(a);

		for(; i < aCount + a; i++)	aMap[i] = index + 1;

		aCount = i;

		return a;
	}),
	m = parseInt(readline()),
	qs = readline().split(/\s/).map(function(q, index)	{
		var value = aMap[q];

		if(value)	result.push(value);
	});

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

var n = parseInt(readline());
var A = readline().split(' ');
var aa = new Array();
aa[0]=0;
// 0 2 9 12 16 25
for(var i=0;i<A.length;i++)
{
    var t = parseInt(A[i]);
	aa[i+1]=aa[i]+t;
}
var m = parseInt(readline());
var B = readline().split(' ');

for(var i=0;i<B.length;i++)
{
    var val = parseInt(B[i]);
	print(getID(val));
}

function getID(val)
{
    if(val<=aa[1])
	{
	    return 1;
	}
    var st = 1;
	var ed = A.length;
	while(ed>st+1)
	{
	    var mid = (st+ed)>>1;
		if(aa[mid]<val)
		{
		    st = mid;
		}
		else
		{
		    ed = mid;
		}
	}
	return ed;
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

function main() {
  let piles = readline();
  let worms = readline().split(' ');
  worms = worms.map(n => parseInt(n));
  let juicy = readline();
  let juicyWormsLabels = readline().split(' ');
  juicyWormsLabels = juicyWormsLabels.map(n => parseInt(n));
  getWormPositions(worms, juicyWormsLabels)
}

function getWormPositions(worms, labels) {
  let res = [];
  let total = new Array(worms.length).fill(0);
  total[0] = worms[0];
  for (let i = 1; i < worms.length; i++) {
    total[i] += total[i - 1] + worms[i]
  }
  for (let i = 0; i < labels.length; i++) {
    let cur = labels[i];
    let idx = bs(total, cur);
    res.push(idx + 1);
  }
  res.forEach(n => console.log(n));
  return res;
}

function bs(arr, target) {
  if (!arr.length) return -1;

  let ini = 0;
  let fin = arr.length - 1;

  while(ini < fin){
      let mid = Math.floor((ini + fin) / 2);
      if(arr[mid] < target){
          ini = mid + 1;
      } else {
          fin = mid;
      }

  }
    return fin;

}

var x = parseInt(readline());

var arr= readline().split(' ').map(a => parseInt(a));

for(var i=1; i<arr.length; i++){
  arr[i] += arr[i-1];
}

var input = parseInt(readline());
var find= readline().split(' ').map(a => parseInt(a));

for(var index=0; index<input; index++){
  var left=0, right = x-1;
  while(left<=right){
    var mid = Math.floor((left+right)/2);
    if(find[index] === arr[mid]){
      break;
    }else if(find[index]>arr[mid]){
      left=mid+1;
    }else{
      right=mid-1;
    }
  }
  if(left===right)
    print(mid+1);
  if(right<0 || find[index]>arr[right])
    print(left+1);
  if(left>x-1 || find[index]<arr[right])
    print(right+1);
}

var x = parseInt(readline());

var arr= readline().split(' ').map(a => parseInt(a));

for(var i=1; i<arr.length; i++){
  arr[i] += arr[i-1];
}

var input = parseInt(readline());
var find= readline().split(' ').map(a => parseInt(a));

for(var index=0; index<input; index++){
  var left=0, right = x-1;
  while(left<=right){
    var mid = left+Math.floor((right-left)/2);
    if(find[index] === arr[mid]){
      break;
    }else if(find[index]>arr[mid]){
      left=mid+1;
    }else{
      right=mid-1;
    }
  }
  if(left===right)
    print(mid+1);
  if(right<0 || find[index]>arr[right])
    print(left+1);
  if(left>x-1 || find[index]<arr[right])
    print(right+1);
}

function Bst(arr, x) {
  var start = 0,
    end = arr.length - 1,
    mid;
  while (start < end) {
    mid = Math.floor((start + end) / 2);
    if (x < arr[mid]) end = mid;
    if (x > arr[mid]) start = mid + 1;
    if (x == arr[mid]) return mid;
  }
  return start + 1;
}
/************************************** */

var n = parseInt(readline());
var prev = 0;
var a = readline()
  .split(" ")
  .map((val) => {
    var x = parseInt(val);
    x += prev;
    prev = x;
    return x;
  });
var m = parseInt(readline());
var q = readline()
  .split(" ")
  .map((val) => parseInt(val));

for (var i = 0; i < m; i++) {
  print(Bst(a, q[i]));
}

var piles_number = readline();
var piles = readline().split(' ');
var expected_worm_numbers = readline();
var expected_worms = readline().split(' ');

var getWormsAfterPile = function(piles_number, piles) {
    var worms_after_piles = [];
    for (i = 0; i < piles_number; i++) {
        var last_worm_after_pile = (i == 0) ? 0 : worms_after_piles[i - 1];
        worms_after_piles[i] = last_worm_after_pile + parseInt(piles[i]);
    }
    return worms_after_piles;
}

var getWormPile = function(worms_after_piles, expected_worm, start) {
    if (worms_after_piles[0] >= expected_worm) {
        return 1;
    }
    for (i = start, worms_after_piles_length = worms_after_piles.length; i < worms_after_piles_length; i++ ) {
        if (worms_after_piles[i] >= expected_worm && worms_after_piles[i-1] < expected_worm) {
            return i+1;
        }
    }
}

var result = [];

var worms_after_piles = getWormsAfterPile(piles_number, piles);
var sorted_expected_worms = expected_worms.concat().sort(function(a, b) {return a - b;});
var last_worm_pile = 0;
for (k = 0; k < expected_worm_numbers; k++) {
    if (result[sorted_expected_worms[k]] != void(0)) {
        continue;
    }
    var worm_pile = getWormPile(worms_after_piles, sorted_expected_worms[k], last_worm_pile);
    last_worm_pile = result[sorted_expected_worms[k]] = worm_pile;
}

print(expected_worms);
for (l = 0; l < expected_worm_numbers; l++) {
    print(result[expected_worms[l]]);
}

var piles_number = readline();
var piles = readline().split(' ');
var expected_worm_numbers = readline();
var expected_worms = readline().split(' ');

var getWormsAfterPile = function(piles_number, piles) {
    var worms_after_piles = [];
    for (i = 0; i < piles_number; i++) {
        var last_worm_after_pile = (i == 0) ? 0 : worms_after_piles[i - 1];
        worms_after_piles[i] = last_worm_after_pile + parseInt(piles[i]);
    }
    return worms_after_piles;
}

var getWormPile = function(worms_after_piles, expected_worm, start) {
    if (worms_after_piles[0] >= expected_worm) {
        return 1;
    }
    for (i = start, worms_after_piles_length = worms_after_piles.length; i < worms_after_piles_length; i++ ) {
        if (worms_after_piles[i] >= expected_worm && worms_after_piles[i-1] < expected_worm) {
            return i+1;
        }
    }
}

var result = [];

var worms_after_piles = getWormsAfterPile(piles_number, piles);
var sorted_expected_worms = expected_worms.concat().sort(function(a, b) {return a - b;});
var last_worm_pile = 0;
for (k = 0; k < expected_worm_numbers; k++) {
    if (result[sorted_expected_worms[k]] != void(0)) {
        continue;
    }
    var worm_pile = getWormPile(worms_after_piles, sorted_expected_worms[k], last_worm_pile);
    last_worm_pile = result[sorted_expected_worms[k]] = worm_pile;
}

for (l = 0; l < expected_worm_numbers; l++) {
    print(result[expected_worms[l]]);
}

var n = readline();
var a = readline().split(" ");
var m = readline();
var q = readline().split(" ");
var z = [0];
for (j = 0;j<a.length;j++){
		z[j+1] = z[j] + a[j];
		}
for (i in q){
	se:for (j = 1;j<z.length;j++)
		if (q[i]<=z[j]) {
		print(j);
		break se;
		}
}

var n = readline();
var a = readline().split(" ");
for (p in a){a[p]= parseInt(a[p]);}
var m = readline();
var q = readline().split(" ");
for (o in q){q[o]= parseInt(q[o]);}
var se = 0;
var y =0;
for (i = 0;i<a.length;i++){
	y = 0;
	sr: for (j = 0;j<a.length;j++){
		if (q[i]<=(y + a[j])&&q[i]>y) {se = j+1;
		break sr;}
		y = y + a[j];
		}
		print(se);
	}

// 474B     Черви

var n = parseInt(readline());

// var input_line = readline().split(' ').map(Number);
var arrA = readline().split(' ').map(Number);

var m = parseInt(readline());

var arrQ = readline().split(' ').map(Number);

arrQ.sort(function(a,b){return a-b;});

var sum = arrA[0];
var jsum = 0;
var out ='';

for (var i = 0; i < m; i++) {
    for (var j = jsum; j < n; j++) {
        if (sum >= arrQ[i]) {
            out += (j + 1).toString() + '\n';
            break;
        } else {
            sum += arrA[i+1];
            jsum = j + 1;
        };
    };
};

print(out);

// 474B     Черви

var n = parseInt(readline());

// var input_line = readline().split(' ').map(Number);
var arrA = readline().split(' ').map(Number);

var m = parseInt(readline());

var arrQ = readline().split(' ').map(Number);

var arrQnum = [];
for (var i = 0; i < m; i++) {
    arrQnum[arrQ[i]] = i;
}

arrQ.sort(function(a,b){return a-b;});

var sum = arrA[0];
var jsum = 0;
var out ='';
var arrOut = [];

for (var i = 0; i < m; i++) {
    for (var j = jsum; j < n; j++) {
        if (sum >= arrQ[i]) {
            arrOut[i] = (j + 1).toString() + '\n';
            break;
        } else {
            sum += arrA[j+1];
            jsum = j + 1;
        };
    };
};

for (var i = 0; i < m; i++) {
    out += arrOut[arrQnum[i]] + '\n';
};

print(out);

// 474B     Черви

var n = parseInt(readline());

// var input_line = readline().split(' ').map(Number);
var arrA = readline().split(' ').map(Number);

var m = parseInt(readline());

var arrQ = readline().split(' ').map(Number);

var arrQnum = [];
for (var i = 0; i < m; i++) {
    arrQnum[arrQ[i]] = i;
}

arrQ.sort(function(a,b){return a-b;});

var sum = arrA[0];
var jsum = 0;
var out ='';
var arrOut = [];

arrA.push(0);

for (var i = 0; i < m; i++) {
    for (var j = jsum; j < n; j++) {
        if (sum >= arrQ[i]) {
            arrOut[arrQnum[arrQ[i]]] = j + 1;
            break;
        } else {
            sum += arrA[j+1];
            jsum = j + 1;
        };
    };
};

for (var i = 0; i < m; i++) {
    out += arrOut[i] + '\n';
};

print(out);

// 474B     Черви

var n = parseInt(readline());

// var input_line = readline().split(' ').map(Number);
var arrA = readline().split(' ').map(Number);

var m = parseInt(readline());

var arrQ = readline().split(' ').map(Number);

var arrQnum = [];
for (var i = 0; i < m; i++) {
    arrQnum[arrQ[i]] = i;
}

arrQ.sort(function(a,b){return a-b;});

var sum = arrA[0];
var jsum = 0;
var out ='';
var arrOut = [];

for (var i = 0; i < m; i++) {
    for (var j = jsum; j < n; j++) {
        if (sum >= arrQ[i]) {
            arrOut[arrQnum[arrQ[i]]] = j;
            break;
        } else {
            sum += arrA[j+1];
            jsum = j + 1;
        };
    };
};

for (var i = 0; i < m; i++) {
    out += arrOut[i] + '\n';
};

print(out);

// 474B     Черви

var n = parseInt(readline());

// var input_line = readline().split(' ').map(Number);
var arrA = readline().split(' ').map(Number);

var m = parseInt(readline());

var arrQ = readline().split(' ').map(Number);

var arrQnum = [];
for (var i = 0; i < m; i++) {
    arrQnum[arrQ[i]-1] = i;
}

arrQ.sort(function(a,b){return a-b;});

var sum = arrA[0];
var jsum = 0;
var out ='';
var arrOut = [];

for (var i = 0; i < m; i++) {
    for (var j = jsum; j < n; j++) {
        if (sum >= arrQ[i]) {
            arrOut[i] = j + '\n';
            break;
        } else {
            sum += arrA[j+1];
            jsum = j + 1;
        };
    };
};

for (var i = 0; i < m; i++) {
    out += arrOut[arrQnum[i]] + '\n';
};

print(out);

// 474B     Черви

var n = parseInt(readline());

// var input_line = readline().split(' ').map(Number);
var arrA = readline().split(' ').map(Number);

var m = parseInt(readline());

var arrQ = readline().split(' ').map(Number);

var out ='';

var arrQnum = [];

for (var i = 0; i < m; i++) {
    arrQ[i][0] = arrQ[i];
    arrQ[i][1] = i;
}

arrQ.sort(function(a,b){return a[0]-b[0];});

var sum = arrA[0];
var jsum = 0;
var arrOut = [];

for (var i = 0; i < m; i++) {
    for (var j = jsum; j < n; j++) {
        if (sum >= arrQ[i][0]) {
            arrOut[arrQ[i][1]] = j + 1;
            break;
        } else {
            sum += arrA[j+1];
            jsum = j + 1;
        };
    };
};

for (var i = 0; i < m; i++) {
    out += arrOut[i] + '\n';
};

print(out);

// 474B     Черви

var n = parseInt(readline());

// var input_line = readline().split(' ').map(Number);
var arrA = readline().split(' ').map(Number);

var m = parseInt(readline());

var arrQ = readline().split(' ').map(Number);

var arrQnum = [];
for (var i = 0; i < m; i++) {
    arrQnum[arrQ[i]-1] = i;
}

arrQ.sort(function(a,b){return a-b;});

var sum = arrA[0];
var jsum = 0;
var out ='';
var arrOut = [];

for (var i = 0; i < m; i++) {
    for (var j = jsum; j < n; j++) {
        if (sum >= arrQ[i]) {
            arrOut[i] = j;
            break;
        } else {
            sum += arrA[j+1];
            jsum = j + 1;
        };
    };
};

for (var i = 0; i < m; i++) {
    out += (arrOut[arrQnum[i]] + 1) + '\n';
};

print(out);

// 474B     Черви

var n = parseInt(readline());

// var input_line = readline().split(' ').map(Number);
var arrA = readline().split(' ').map(Number);

var m = parseInt(readline());

var arrQ = readline().split(' ').map(Number);

var out ='';

var arrQnum = [];
for (var i = 0; i < m; i++) {
    if (arrQnum[arrQ[i]] == undefined) {
        arrQnum[arrQ[i]] = i;
    } else {
        out = 'duble';
    }
}

arrQ.sort(function(a,b){return a-b;});

var sum = arrA[0];
var jsum = 0;
var arrOut = [];

for (var i = 0; i < m; i++) {
    for (var j = jsum; j < n; j++) {
        if (sum >= arrQ[i]) {
            arrOut[arrQnum[arrQ[i]]] = j + 1;
            break;
        } else {
            sum += arrA[j+1];
            jsum = j + 1;
        };
    };
};

for (var i = 0; i < m; i++) {
    if (arrOut[i] !== undefined) {
        out += arrOut[i] + '\n';
    };
};

print(out);

// 474B     Черви

var n = parseInt(readline());

// var input_line = readline().split(' ').map(Number);
var arrA = readline().split(' ').map(Number);

var m = parseInt(readline());

var arrQ = readline().split(' ').map(Number);

var arrQnum = [];
for (var i = 0; i < m; i++) {
    arrQnum[arrQ[i]] = i;
}

arrQ.sort(function(a,b){return a-b;});

var sum = arrA[0];
var jsum = 0;
var out ='';
var arrOut = [];

for (var i = 0; i < m; i++) {
    for (var j = jsum; j < n; j++) {
        if (sum >= arrQ[i]) {
            arrOut[arrQnum[arrQ[i]]] = j + 1;
            break;
        } else {
            sum += arrA[j+1];
            jsum = j + 1;
        };
    };
};

for (var i = 0; i < m; i++) {
    out += arrOut[i] + '\n';
};

print(out);

// 474B     Черви

var n = parseInt(readline());

// var input_line = readline().split(' ').map(Number);
var arrA = readline().split(' ').map(Number);

var m = parseInt(readline());

var arrQ = readline().split(' ').map(Number);

var arrQnum = [];
for (var i = 0; i < m; i++) {
    arrQnum[arrQ[i]] = i;
}

arrQ.sort(function(a,b){return a-b;});

var sum = arrA[0];
var jsum = 0;
var out ='';
var arrOut = [];

arrA.push(0);
arrA.push(0);

for (var i = 0; i < m; i++) {
    for (var j = jsum; j < n; j++) {
        if (sum >= arrQ[i]) {
            arrOut[arrQnum[arrQ[i]]] = j + 1;
            break;
        } else {
            sum += arrA[j+1];
            jsum = j + 1;
        };
    };
};

for (var i = 0; i < m; i++) {
    if (arrOut[i] !== undefined) {
        out += arrOut[i] + '\n';
    };
};

print(out);

// 474B     Черви

var n = parseInt(readline());

// var input_line = readline().split(' ').map(Number);
var arrA = readline().split(' ').map(Number);

var m = parseInt(readline());

var arrQ = readline().split(' ').map(Number);

var arrQnum = [];
for (var i = 0; i < m; i++) {
    arrQnum[arrQ[i]] = i;
}

arrQ.sort(function(a,b){return a-b;});

var sum = arrA[0];
var jsum = 0;
var out ='';
var arrOut = [];

arrA.push(0);
arrA.push(0);

for (var i = 0; i < m; i++) {
    for (var j = jsum; j < n; j++) {
        if (sum >= arrQ[i]) {
            arrOut[arrQnum[arrQ[i]]] = j + 1;
            break;
        } else {
            sum += arrA[j+1];
            jsum = j + 1;
        };
    };
};

for (var i = 0; i < m; i++) {
    out += arrOut[i] + '\n';
};

print(out);

// 474B     Черви

var n = parseInt(readline());

// var input_line = readline().split(' ').map(Number);
var arrA = readline().split(' ').map(Number);

var m = parseInt(readline());

var arrQ = readline().split(' ').map(Number);

arrQ.sort(function(a,b){return a-b;});

var sum = arrA[0];
var jsum = 0;
var out ='';

for (var i = 0; i < m; i++) {
    for (var j = jsum; j < n; j++) {
        if (sum >= arrQ[i]) {
            out += (j + 1).toString() + '\n';
            break;
        } else {
            sum += arrA[j+1];
            jsum = j + 1;
        };
    };
};

print(out);

// 474B     Черви

var n = parseInt(readline());

// var input_line = readline().split(' ').map(Number);
var arrA = readline().split(' ').map(Number);

var m = parseInt(readline());

var arrQ = readline().split(' ').map(Number);

var arrQnum = [];
for (var i = 0; i < m; i++) {
    arrQnum[arrQ[i]] = i;
}

arrQ.sort(function(a,b){return a-b;});

var sum = arrA[0];
var jsum = 0;
var out ='';
var arrOut = [];

for (var i = 0; i < m; i++) {
    for (var j = jsum; j < n; j++) {
        if (sum >= arrQ[i]) {
            arrOut[i] = (j + 1) + '\n';
            break;
        } else {
            sum += arrA[j+1];
            jsum = j + 1;
        };
    };
};

for (var i = 0; i < m; i++) {
    out += arrOut[arrQnum[i]] + '\n';
};

print(out);

// 474B     Черви

var n = parseInt(readline());

// var input_line = readline().split(' ').map(Number);
var arrA = readline().split(' ').map(Number);

var m = parseInt(readline());

var arrQ = readline().split(' ').map(Number);

var out ='';

var arrQnum = [];
for (var i = 0; i < m; i++) {
    if (arrQnum[arrQ[i]] == undefined) {
        arrQnum[arrQ[i]] = i;
    } else {
        out += 'duble';
    }
}

arrQ.sort(function(a,b){return a-b;});

var sum = arrA[0];
var jsum = 0;
var arrOut = [];

for (var i = 0; i < m; i++) {
    for (var j = jsum; j < n; j++) {
        if (sum >= arrQ[i]) {
            arrOut[arrQnum[arrQ[i]]] = j + 1;
            break;
        } else {
            sum += arrA[j+1];
            jsum = j + 1;
        };
    };
};

for (var i = 0; i < m; i++) {
    if (arrOut[i] !== undefined) {
        out += arrOut[i] + '\n';
    };
};

print(out);

readline()
var A=readline().split(' ').map(Number)
readline()
var Q=readline().split(' ').map(Number)

var T=new Array(A.length + 1)
T[0]=0
for (var i=1; i<T.length; ++i)
    T[i]=T[i-1]+A[i-1];

var find = x => {
    var lb=0,ub=T.length-1;
    while (1) {
        var m=(ub+lb)>>1;
        if (x<T[m]) {
            ub=m;
        } else if (T[m]<x) {
            lb=m;

        } else return m;
        if (ub===lb+1) return lb;
    }
}

print(Q.map(x => find(x) + 1).join('\n'))

function getWormPositions(worms, labels){
   let total = new Array(worms.length).fill(0);
   total[0] = worms[0];
   for (let i = 1; i < worms.length; i++) {
     total[i] = total[i -1] +  worms[i];
   }

  for (let i = 0; i < labels.length; i++) {
    let cur = labels[i];
    let idx = bs(total, cur);
    console.log(idx + 1)
  }

}

function bs(arr, target){
  if(!arr.length) return -1;

  let mid = Math.floor(arr.length / 2);

  let prev = (mid - 1 ) > -1  ? arr[mid - 1]: -1;

  if(arr[mid] >= target && prev < target){
    return mid;
  } else if(arr[mid] > target){
    return bs(arr.slice(0, mid), target);
  } else if(arr[mid] < target){
    let sub = bs(arr.slice(mid + 1), target);
     return sub >= 0 ? sub + 1 + mid : -1;
  }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

function main() {
  let piles = readline();
  let worms = readline().split(' ');
  worms = worms.map(n => parseInt(n));
  let juicy = readline();
  let juicyWormsLabels = readline().split(' ');
  juicyWormsLabels = juicyWormsLabels.map(n => parseInt(n));
  getWormPositions(worms, juicyWormsLabels)
}

function getWormPositions(worms, labels) {
  let res = [];
  let total = new Array(worms.length).fill(0);
  total[0] = worms[0];
  for (let i = 1; i < worms.length; i++) {
    total[i] += total[i - 1] + worms[i]
  }
  for (let i = 0; i < labels.length; i++) {
    let cur = labels[i];
    let idx = bs(total, cur);
    res.push(idx + 1);
  }
  res.forEach(n => console.log(n));
  return res;
}

function bs(arr, target) {
//   console.log(arr, target)
  if (!arr.length) return -1;

  let mid = Math.floor(arr.length / 2);
  let prev = (mid - 1) > -1 ? arr[mid - 1] : - Infinity;

  if (arr[mid] === target) {
    return mid;
  } else if (arr[mid] > target) {
    return bs(arr.slice(0, mid), target);
  } else {
    let sub = bs(arr.slice(mid + 1), target);
    return sub >= 0 ? sub + 1 + mid : -1;
  }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

function main() {
  let piles = readline();
  let worms = readline().split(' ');
  worms = worms.map(n => parseInt(n));
  let juicy = readline();
  let juicyWormsLabels = readline().split(' ');
  juicyWormsLabels = juicyWormsLabels.map(n => parseInt(n));
  getWormPositions(worms, juicyWormsLabels)
}

function getWormPositions(worms, labels){
  let res = [];
  let total = new Array(worms.length).fill(0);
  total[0] = worms[0];
  for (let i = 1; i < worms.length; i++) {
    total[i] = total[i -1] +  worms[i];
  }

  for (let i = 0; i < labels.length; i++) {
    let cur = labels[i];
    let idx = bs(total, cur);
    res.push(idx + 1);
  }
  res.forEach(n => console.log(n));
  return res;
}

function bs(arr, target){
  if(!arr) return -1;

  let mid = Math.floor(arr.length / 2);
  let prev = mid - 1 >= 0 ? arr[mid - 1] : - Infinity;
  if(arr[mid] >= target && prev < target){
    return mid;
  } else if(arr[mid] > target){
    return bs(arr.slice(0, mid), target);
  } else if(arr[mid] < target){
    let sub = bs(arr.slice(mid + 1), target);
     return sub > 0 ? sub + 1 + mid : -1;
  }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

function main() {
  let piles = readline();
  let worms = readline().split(' ');
  worms = worms.map(n => parseInt(n));
  let juicy = readline();
  let juicyWormsLabels = readline().split(' ');
  juicyWormsLabels = juicyWormsLabels.map(n => parseInt(n));
  getWormPositions(worms, juicyWormsLabels)
}

function getWormPositions(worms, labels) {
  let res = [];
  let total = new Array(worms.length).fill(0);
  total[0] = worms[0];
  for (let i = 1; i < worms.length; i++) {
    total[i] += total[i - 1] + worms[i]
  }
  for (let i = 0; i < labels.length; i++) {
    let cur = labels[i];
    let idx = bs(total, cur);
    res.push(idx + 1);
  }
  res.forEach(n => console.log(n));
  return res;
}

function bs(arr, target) {
//   console.log(arr, target)
  if (!arr.length) return -1;

  let mid = Math.floor(arr.length / 2);
  let prev = (mid - 1) > -1 ? arr[mid - 1] : - Infinity;
  console.log(arr[mid], "current element", prev, "prev", target)

  if (arr[mid] === target) {
    return mid;
  } else if (arr[mid] > target) {
    return bs(arr.slice(0, mid), target);
  } else {
    let sub = bs(arr.slice(mid + 1), target);
    return sub >= 0 ? sub + 1 + mid : -1;
  }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

function main() {
  let piles = readline();
  let worms = readline().split(' ');
  worms = worms.map(n => parseInt(n));
  let juicy = readline();
  let juicyWormsLabels = readline().split(' ');
  juicyWormsLabels = juicyWormsLabels.map(n => parseInt(n));
  getWormPositions(worms, juicyWormsLabels)
}
function getWormPositions(worms, labels){
  let res = [];
  let total = new Array(worms.length).fill(0);
  total[0] = worms[0];
  for (let i = 1; i < worms.length; i++) {
    total[i] = total[i -1] +  worms[i];
  }
  console.log(total, "total")

  for (let i = 0; i < labels.length; i++) {
    let cur = labels[i];
    let idx = bs(total, cur);
    res.push(idx + 1);
  }
  res.forEach(n => console.log(n));
  return res;
}

function bs(arr, target){
  if(!arr) return -1;

  let mid = Math.floor(arr.length / 2);
  let prev = mid - 1 >= 0 ? arr[mid - 1] : - Infinity;
  if(arr[mid] >= target && prev < target){
    return mid;
  } else if(arr[mid] > target){
    return bs(arr.slice(0, mid), target);
  } else if(arr[mid] < target){
    let sub = bs(arr.slice(mid + 1), target);
     return sub > 0 ? sub + 1 + mid : -1;
  }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

function main() {
  let piles = readline();
  let worms = readline().split(' ');
  worms = worms.map(n => parseInt(n));
  let juicy = readline();
  let juicyWormsLabels = readline().split(' ');
  juicyWormsLabels = juicyWormsLabels.map(n => parseInt(n));
  getWormPositions(worms, juicyWormsLabels)
}

function getWormPositions(worms, labels){
  let res = [];
   let total = new Array(worms.length).fill(0);
   total[0] = worms[0];
   for (let i = 1; i < worms.length; i++) {
     total[i] = total[i -1] +  worms[i];
   }

 labels.sort((a,b) => a - b);

  for (let i = 0; i < labels.length; i++) {
    let cur = labels[i];
    let idx = bs(total, cur);
    res.push(idx + 1);
  }
  res.forEach(n => console.log(n));
  return res;
}

function bs(arr, target){
  if(!arr) return -1;

  let mid = Math.floor(arr.length / 2);

  let prev = (mid - 1 ) > -1  ? arr[mid - 1]: -1;

  if(arr[mid] >= target && prev < target){
    return mid;
  } else if(arr[mid] > target){
    return bs(arr.slice(0, mid), target);
  } else if(arr[mid] < target){
    let sub = bs(arr.slice(mid + 1), target);
     return sub >= 0 ? sub + 1 + mid : -1;
  }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

function main() {
  let piles = readline();
  let worms = readline().split(' ');
  worms = worms.map(n => parseInt(n));
  let juicy = readline();
  let juicyWormsLabels = readline().split(' ');
  juicyWormsLabels = juicyWormsLabels.map(n => parseInt(n));
  getWormPositions(worms, juicyWormsLabels)
}

function getWormPositions(worms, labels){
  let res = [];
   let total = new Array(worms.length).fill(0);
   total[0] = worms[0];
   for (let i = 1; i < worms.length; i++) {
     total[i] = total[i -1] +  worms[i];
   }

  for (let i = 0; i < labels.length; i++) {
    let cur = labels[i];
    let idx = bs(total, cur);
    res.push(idx + 1);
  }
  res.forEach(n => console.log(n));
  return res;
}

function bs(arr, target){
  if(!arr) return -1;

  let mid = Math.floor(arr.length / 2);
  // console.log(mid + 1, arr.length)
  let prev = (mid - 1 ) > -1  ? arr[mid - 1]: -1;
//  console.log(`${arr[mid]} <= ${target} < ${next}`)
  if(arr[mid] >= target && prev < target){
    return mid;
  } else if(arr[mid] > target){
    return bs(arr.slice(0, mid), target);
  } else if(arr[mid] < target){
    let sub = bs(arr.slice(mid + 1), target);
     return sub > 0 ? sub + 1 + mid : -1;
  }
}


There are $$$n$$$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.The university team for the Olympiad consists of $$$a$$$ student-programmers and $$$b$$$ student-athletes. Determine the largest number of students from all $$$a+b$$$ students, which you can put in the railway carriage so that:  no student-programmer is sitting next to the student-programmer;  and no student-athlete is sitting next to the student-athlete. In the other words, there should not be two consecutive (adjacent) places where two student-athletes or two student-programmers are sitting.Consider that initially occupied seat places are occupied by jury members (who obviously are not students at all).

The first line contain three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n \le 2\cdot10^{5}$$$, $$$0 \le a, b \le 2\cdot10^{5}$$$, $$$a + b > 0$$$) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes. The second line contains a string with length $$$n$$$, consisting of characters "." and "*". The dot means that the corresponding place is empty. The asterisk means that the corresponding place is occupied by the jury member.

Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete.

NoteIn the first example you can put all student, for example, in the following way: *.AB*In the second example you can put four students, for example, in the following way: *BAB*BIn the third example you can put seven students, for example, in the following way: B*ABAB**A*BThe letter A means a student-programmer, and the letter B — student-athlete.

function main() {
  var nab = readline()
    .split(' ')
    .map(l => Number(l));
  var a = nab[1];
  var b = nab[2];
  var seats = readline().split('');

  var aRem = a;
  var bRem = b;

  for (var i = 0; i < seats.length; i++) {
    if (aRem === 0 && bRem === 0) break;
    if (seats[i] === '*') continue;

    if (aRem >= bRem) {
      if (i === 0 || seats[i - 1] !== 'a') {
        aRem--;
        seats[i] = 'a';
      } else if (bRem > 0 && (i === 0 || seats[i - 1] !== 'b')) {
        bRem--;
        seats[i] = 'b';
      }
    } else {
      if (i === 0 || seats[i - 1] !== 'b') {
        bRem--;
        seats[i] = 'b';
      } else if (aRem > 0 && (i === 0 || seats[i - 1] !== 'a')) {
        aRem--;
        seats[i] = 'a';
      }
    }
  }

  print(a + b - aRem - bRem);
}

main();

function main() {
  var nab = readline()
    .split(' ')
    .map(l => Number(l));
  var a = nab[1];
  var b = nab[2];
  var seats = readline();

  var aRem = a;
  var bRem = b;

  for (var i = 0; i < seats.length; i++) {
    if (aRem === 0 && bRem === 0) break;
    if (seats[i] === '*') continue;

    if (aRem > 0 && aRem >= bRem && (i === 0 || seats[i - 1] !== 'a')) {
      aRem--;
      seats[i] = 'a';
    } else if (bRem > 0 && (i === 0 || seats[i - 1] !== 'b')) {
      bRem--;
      seats[i] = 'b';
    }
  }

  print(aRem + bRem === 0 ? a + b : a + b - aRem - bRem);
}

main();

function main() {
  var nab = readline()
    .split(' ')
    .map(l => Number(l));
  var a = nab[1];
  var b = nab[2];
  var seats = readline();

  var aRem = a;
  var bRem = b;

  for (var i = 0; i < seats.length; i++) {
    if (aRem === 0 && bRem === 0) break;
    if (seats[i] === '*') continue;

    if (aRem > 0 && aRem > bRem && (i === 0 || seats[i - 1] !== 'a')) {
      aRem--;
      seats[i] = 'a';
    } else if (bRem > 0 && (i === 0 || seats[i - 1] !== 'b')) {
      bRem--;
      seats[i] = 'b';
    }
  }

  print(a + b - aRem - bRem);
}

main();


A permutation of length $$$n$$$ is an array $$$p=[p_1,p_2,\dots, p_n]$$$ which contains every integer from $$$1$$$ to $$$n$$$ (inclusive) exactly once. For example, $$$p=[4, 2, 6, 5, 3, 1]$$$ is a permutation of length $$$6$$$.You are given three integers $$$n$$$, $$$a$$$ and $$$b$$$, where $$$n$$$ is an even number. Print any permutation of length $$$n$$$ that the minimum among all its elements of the left half equals $$$a$$$ and the maximum among all its elements of the right half equals $$$b$$$. Print -1 if no such permutation exists.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$), the number of test cases in the test. The following $$$t$$$ lines contain test case descriptions. Each test case description contains three integers $$$n$$$, $$$a$$$, $$$b$$$ ($$$2 \le n \le 100$$$; $$$1 \le a,b \le n$$$; $$$a \ne b$$$), where $$$n$$$ is an even number (i.e. $$$n \bmod 2 = 0$$$).

For each test case, print a single line containing any suitable permutation. Print -1 no such permutation exists. If there are multiple answers, print any of them.

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

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, a, b] = rna();

		let ans = Array.from(Array(n), (_, i) => i+1);
		if (a <= n/2 && b >= n/2+1) {
			ans[a-1] = b;
			ans[b-1] = a;
			ans.reverse();
		} else if (a == n/2+1 && b == n/2) {
			ans.reverse();
		} else {
			ans = false;
		}

		console.log(ans ? ans.join(' ') : -1);
	}
}

process.stdin.setEncoding('utf-8')
const readline = require('readline')

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

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve([n, a, b]) {
    const tmpArr = Array(200)
    let count = 1, flag = false
    tmpArr[0] = a
    for (let i = n; i > Math.floor(n / 2); i--) {
        if (i !== b && i !== a) {
            tmpArr[count] = i
            count++
        }
    }
    tmpArr[count] = b
    count++
    for (let i = Math.floor(n / 2); i > 0; i--) {
        if (i !== b && i !== a) {
            tmpArr[count] = i
            count++
        }
    }
    flag = false
    let mVal = Number.MAX_SAFE_INTEGER
    for (let i = 0; i < Math.floor(n / 2); i++) {
        if (tmpArr[i] < mVal) {
            mVal = tmpArr[i]
        }
    }
    if (mVal === a) {
        let maxVal = Number.MIN_SAFE_INTEGER
        for (let i = Math.floor(n / 2); i < n; i++) {
            if (tmpArr[i] > maxVal) {
                maxVal = tmpArr[i]
            }
        }
        if (maxVal == b) {
            flag = true
        }
    }
    if (flag) {
        console.log(tmpArr.slice(0, n).join(' '))
    } else {
        console.log('-1')
    }
}

function main() {
    for (let i = 0; i < inputArr.length; i++) solve(inputArr[i])
}

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

function solve(n, a, b) {
    const h = n / 2
    const ans = []
    const used = []
    ans[0] = a
    used[a] = 1
    ans[h] = b
    used[b] = 1

    let i = n
    let count = 1
    while (i >= a && count < h) {
        if (!used[i]) {
            used[i] = 1
            ans[count++] = i
        }
        i--
    }
// console.log(ans)
    if (count < h) return -1
    i = 1
    count = 1
    while (i <= b && count < h) {
        if (!used[i]) {
            used[i] = 1
            ans[h + count++] = i
        }
        i++
    }
    if (count < h) return -1
    return ans.join(' ')
}


The year of 2012 is coming...According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven brave heroes have already gathered on the top of a mountain Arreat to protect us mere mortals from the effect of this terrible evil.The seven great heroes are: amazon Anka, barbarian Chapay, sorceress Cleo, druid Troll, necromancer Dracul, paladin Snowy and a professional hit girl Hexadecimal. Heroes already know how much experience will be given for each of the three megabosses: a for Mephisto, b for Diablo and c for Baal.Here's the problem: heroes are as much as seven and megabosses are only three! Then our heroes decided to split into three teams, where each team will go to destroy their own megaboss. Each team member will receive a  of experience, rounded down, where x will be the amount of experience for the killed megaboss and y — the number of people in the team.Heroes do not want to hurt each other's feelings, so they want to split into teams so that the difference between the hero who received the maximum number of experience and the hero who received the minimum number of experience were minimal. Since there can be several divisions into teams, then you need to find the one in which the total amount of liking in teams were maximum.It is known that some heroes like others. But if hero p likes hero q, this does not mean that the hero q likes hero p. No hero likes himself.The total amount of liking in teams is the amount of ordered pairs (p, q), such that heroes p and q are in the same group, and hero p likes hero q (but it is not important if hero q likes hero p). In case of heroes p and q likes each other and they are in the same group, this pair should be counted twice, as (p, q) and (q, p).A team can consist even of a single hero, but it is important that every megaboss was destroyed. All heroes must be involved in the campaign against evil. None of the heroes can be in more than one team.It is guaranteed that every hero is able to destroy any megaboss alone.

The first line contains a single non-negative integer n (0 ≤ n ≤ 42) — amount of liking between the heroes. Next n lines describe liking in the form "p likes q", meaning that the hero p likes the hero q (p  ≠  q). Every liking is described in the input exactly once, no hero likes himself. In the last line are given three integers a, b and c (1 ≤ a, b, c ≤ 2·109), separated by spaces: the experience for Mephisto, the experience for Diablo and experience for Baal. In all the pretests, except for examples from the statement, the following condition is satisfied: a = b = c.

Print two integers — the minimal difference in the experience between two heroes who will receive the maximum and minimum number of experience points, and the maximal total amount of liking in teams (the number of friendships between heroes that end up in one team). When calculating the second answer, the team division should satisfy the difference-minimizing contraint. I.e. primary you should minimize the difference in the experience and secondary you should maximize the total amount of liking.

3
Troll likes Dracul
Dracul likes Anka
Snowy likes Hexadecimal
210 200 180

2
Anka likes Chapay
Chapay likes Anka
10000 50 50

NoteA note to first example: it the first team should be Dracul, Troll and Anka, in the second one Hexadecimal and Snowy, and in the third Cleo и Chapay.

var heroes = ["Anka", "Chapay", "Cleo", "Troll",
		"Dracul", "Snowy", "Hexadecimal" ];
var s = [];
for (var i=0;i<7;i++) s.push([false,false,false,false,false,false,false]);
var ss;
for (var n = +readline(); n > 0; n--) {
    ss = readline().split(' ');
	var s1 = ss[0];
	var s2 = ss[2];
	var k1 = -1, k2 = -1;
	for (var i = 0; i < 7; i++) {
		if (s1 == heroes[i])
			k1 = i;
		if (s2 == heroes[i])
			k2 = i;
	}
	s[k1][k2] = true;
}

ss = readline().split(' ');
var a = [+ss[0], +ss[1], +ss[2]];
var m = [0, 0, 0, 0, 0, 0, 0];
var INF = 2000000000;
var best = INF;
var best_x = 0;
for (var mask1 = 0; mask1 < 1 << 7; mask1++) {
	for (var mask2 = 0; mask2 < 1 << 7; mask2++)
		if ((mask2 & mask1) == 0) {
			for (var i = 0; i < 7; i++) {
				if ((mask1 & (1 << i)) != 0)
					m[i] = 0;
				else if ((mask2 & (1 << i)) != 0)
					m[i] = 1;
				else
					m[i] = 2;
			}
			var x = 0;
			var y = INF, z = -INF;
			var c = [0, 0, 0];
			for (var i = 0; i < 7; i++) {
				c[m[i]]++;
				for (var j = 0; j < 7; j++)
					if (s[i][j] && m[i] == m[j])
						x++;
			}
			if (c[0] == 0 || c[1] == 0 || c[2] == 0)
				continue;
			for (var i = 0; i < 3; i++) {
				var d = a[i]/c[i] | 0;
				if (d < y)
					y = d;
				if (d > z)
					z = d;
			}
			if (z - y < best || z - y == best && x > best_x) {
				best = z - y;
				best_x = x;
			}
		}
}
print(best+" "+ best_x);

var heroes = ["Anka", "Chapay", "Cleo", "Troll",
		"Dracul", "Snowy", "Hexadecimal" ];
var s = [];
for (var i=0;i<7;i++) s.push([false,false,false,false,false,false,false]);
var ss;
for (var n = +readline(); n > 0; n--) {
    ss = readline().split(' ');
	var s1 = ss[0];
	var s2 = ss[2];
	var k1 = -1, k2 = -1;
	for (var i = 0; i < 7; i++) {
		if (s1 == heroes[i])
			k1 = i;
		if (s2 == heroes[i])
			k2 = i;
	}
	s[k1][k2] = true;
}

ss = readline().split(' ');
var a = [+ss[0], +ss[1], +ss[2]];
var m = [0, 0, 0, 0, 0, 0, 0];
var INF = 2000000000;
var best = INF;
var best_x = 0;
for (var mask1 = 0; mask1 < 1 << 7; mask1++) {
	for (var mask2 = 0; mask2 < 1 << 7; mask2++)
		if ((mask2 & mask1) == 0) {
			for (var i = 0; i < 7; i++) {
				if ((mask1 & (1 << i)) != 0)
					m[i] = 0;
				else if ((mask2 & (1 << i)) != 0)
					m[i] = 1;
				else
					m[i] = 2;
			}
			var x = 0;
			var y = INF, z = INF;
			var c = [0, 0, 0];
			for (var i = 0; i < 7; i++) {
				c[m[i]]++;
				for (var j = 0; j < 7; j++)
					if (s[i][j] && m[i] == m[j])
						x++;
			}
			if (c[0] == 0 || c[1] == 0 || c[2] == 0)
				continue;
			for (var i = 0; i < 3; i++) {
				if (a[i] / c[i]|0 < y)
					y = a[i] / c[i]|0;
				if (a[i] / c[i]|0 > z)
					z = a[i] / c[i]|0;
			}
			if (z - y < best || z - y == best && x > best_x) {
				best = z - y;
				best_x = x;
			}
		}
}
print(best+" "+ best_x);