#include <bits/stdc++.h>
long long dx[4] = {0, -1, 0, 1};
long long dy[4] = {1, 0, -1, 0};
using namespace std;
class pa3 {
 public:
  long long x, y, z;
  pa3(long long x = 0, long long y = 0, long long z = 0) : x(x), y(y), z(z) {}
  bool operator<(const pa3 &p) const {
    if (x != p.x) return x < p.x;
    if (y != p.y) return y < p.y;
    return z < p.z;
  }
  bool operator>(const pa3 &p) const {
    if (x != p.x) return x > p.x;
    if (y != p.y) return y > p.y;
    return z > p.z;
  }
  bool operator==(const pa3 &p) const {
    return x == p.x && y == p.y && z == p.z;
  }
  bool operator!=(const pa3 &p) const {
    return !(x == p.x && y == p.y && z == p.z);
  }
};
class pa4 {
 public:
  double x;
  long long y, z, w;
  pa4(double x = 0, long long y = 0, long long z = 0, long long w = 0)
      : x(x), y(y), z(z), w(w) {}
  bool operator<(const pa4 &p) const {
    if (x != p.x) return x < p.x;
    if (y != p.y) return y < p.y;
    if (z != p.z) return z < p.z;
    return w < p.w;
  }
  bool operator>(const pa4 &p) const {
    if (x != p.x) return x > p.x;
    if (y != p.y) return y > p.y;
    if (z != p.z) return z > p.z;
    return w > p.w;
  }
  bool operator==(const pa4 &p) const {
    return x == p.x && y == p.y && z == p.z && w == p.w;
  }
};
class pa2 {
 public:
  long long x, y;
  pa2(long long x = 0, long long y = 0) : x(x), y(y) {}
  pa2 operator+(pa2 p) { return pa2(x + p.x, y + p.y); }
  pa2 operator-(pa2 p) { return pa2(x - p.x, y - p.y); }
  bool operator<(const pa2 &p) const { return y != p.y ? y < p.y : x < p.x; }
  bool operator>(const pa2 &p) const { return x != p.x ? x < p.x : y < p.y; }
  bool operator==(const pa2 &p) const {
    return abs(x - p.x) == 0 && abs(y - p.y) == 0;
  }
  bool operator!=(const pa2 &p) const {
    return !(abs(x - p.x) == 0 && abs(y - p.y) == 0);
  }
};
class Point {
 public:
  double x, y;
  Point(double x = 0, double y = 0) : x(x), y(y) {}
  Point operator+(Point p) { return Point(x + p.x, y + p.y); }
  Point operator-(Point p) { return Point(x - p.x, y - p.y); }
  Point operator*(double a) { return Point(x * a, y * a); }
  Point operator/(double a) { return Point(x / a, y / a); }
  double absv() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  bool operator<(const Point &p) const { return x != p.x ? x < p.x : y < p.y; }
  bool operator==(const Point &p) const {
    return fabs(x - p.x) < (1e-10) && fabs(y - p.y) < (1e-10);
  }
};
struct Segment {
  Point p1, p2;
};
double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; }
bool parareru(Point a, Point b, Point c, Point d) {
  return abs(cross(a - b, d - c)) < (1e-10);
}
double distance_ls_p(Point a, Point b, Point c) {
  if (dot(b - a, c - a) < (1e-10)) return (c - a).absv();
  if (dot(a - b, c - b) < (1e-10)) return (c - b).absv();
  return abs(cross(b - a, c - a)) / (b - a).absv();
}
bool is_intersected_ls(Segment a, Segment b) {
  if (a.p1 == b.p1 || a.p2 == b.p1 || a.p1 == b.p2 || a.p2 == b.p2)
    return false;
  if (parareru((a.p2), (a.p1), (a.p1), (b.p2)) &&
      parareru((a.p2), (a.p1), (a.p1), (b.p1))) {
    if (dot(a.p1 - b.p1, a.p1 - b.p2) < (1e-10)) return true;
    if (dot(a.p2 - b.p1, a.p2 - b.p2) < (1e-10)) return true;
    if (dot(a.p1 - b.p1, a.p2 - b.p1) < (1e-10)) return true;
    if (dot(a.p1 - b.p2, a.p2 - b.p2) < (1e-10)) return true;
    return false;
  } else
    return (cross(a.p2 - a.p1, b.p1 - a.p1) * cross(a.p2 - a.p1, b.p2 - a.p1) <
            (1e-10)) &&
           (cross(b.p2 - b.p1, a.p1 - b.p1) * cross(b.p2 - b.p1, a.p2 - b.p1) <
            (1e-10));
}
double segment_dis(Segment a, Segment b) {
  if (is_intersected_ls(a, b)) return 0;
  double r = distance_ls_p(a.p1, a.p2, b.p1);
  r = min(r, distance_ls_p(a.p1, a.p2, b.p2));
  r = min(r, distance_ls_p(b.p1, b.p2, a.p2));
  r = min(r, distance_ls_p(b.p1, b.p2, a.p1));
  return r;
}
Point intersection_ls(Segment a, Segment b) {
  Point ba = b.p2 - b.p1;
  double d1 = abs(cross(ba, a.p1 - b.p1));
  double d2 = abs(cross(ba, a.p2 - b.p1));
  double t = d1 / (d1 + d2);
  return a.p1 + (a.p2 - a.p1) * t;
}
string itos(long long i) {
  ostringstream s;
  s << i;
  return s.str();
}
long long gcd(long long v, long long b) {
  if (v > b) return gcd(b, v);
  if (v == b) return b;
  if (b % v == 0) return v;
  return gcd(v, b % v);
}
double distans(double x1, double y1, double x2, double y2) {
  double rr = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
  return sqrt(rr);
}
long long mod;
long long pr[2010];
long long inv[2010];
long long beki(long long wa, long long rr, long long warukazu) {
  if (rr == 0) return 1 % warukazu;
  if (rr == 1) return wa % warukazu;
  if (rr % 2 == 1) return (beki(wa, rr - 1, warukazu) * wa) % warukazu;
  long long zx = beki(wa, rr / 2, warukazu);
  return (zx * zx) % warukazu;
}
void gya(long long ert) {
  pr[0] = 1;
  for (long long i = 1; i < ert; i++) {
    pr[i] = (pr[i - 1] * i) % mod;
  }
  for (long long i = 0; i < ert; i++) inv[i] = beki(pr[i], mod - 2, mod);
}
struct Segsum {
 private:
 public:
  long long cor = (1 << 18);
  vector<long long> vec;
  vector<long long> lazy;
  void shoki1() { vec.resize(2 * cor + 3, 0); }
  void shoki2() {
    for (long long i = cor - 1; i > 0; i--)
      vec[i] = vec[2 * i] + vec[2 * i + 1];
  }
  void clear() {
    for (long long i = 0; i < (long long)vec.size(); i++) vec[i] = 0;
  }
  void updadd(long long x, long long w) {
    x += cor;
    vec[x] += w;
    while (1) {
      x /= 2;
      if (x == 0) break;
      vec[x] = vec[2 * x] + vec[2 * x + 1];
    }
  }
  void updchan(long long x, long long w) {
    x += cor;
    vec[x] = w;
    while (1) {
      x /= 2;
      if (x == 0) break;
      vec[x] = vec[2 * x] + vec[2 * x + 1];
    }
  }
  long long sum(long long a, long long b, long long k = 1, long long l = 0,
                long long r = -10) {
    if (r < 0) r = cor;
    if (a <= l && r <= b) {
      return vec[k];
    }
    if (r <= a || b <= l) {
      return 0;
    }
    long long v1 = sum(a, b, k * 2, l, (l + r) / 2),
              v2 = sum(a, b, k * 2 + 1, (l + r) / 2, r);
    return v1 + v2;
  }
};
struct Segmax {
 private:
 public:
  long long cor = (1 << 18);
  vector<pair<long long, long long> > vec;
  void shoki1() {
    vec.resize(2 * cor + 3, make_pair(0, 0));
    for (long long i = cor; i < 2 * cor; i++) vec[i].second = i - cor;
  }
  void shoki2() {
    for (long long i = cor - 1; i > 0; i--) {
      if (vec[2 * i].first >= vec[2 * i + 1].first)
        vec[i] = vec[2 * i];
      else
        vec[i] = vec[2 * i + 1];
    }
  }
  void updadd(long long x, long long w) {
    x += cor;
    vec[x].first += w;
    while (1) {
      x /= 2;
      if (x == 0) break;
      if (vec[2 * x].first >= vec[2 * x + 1].first)
        vec[x] = vec[2 * x];
      else
        vec[x] = vec[2 * x + 1];
    }
  }
  void updchan(long long x, long long w) {
    x += cor;
    vec[x].first = w;
    while (1) {
      x /= 2;
      if (x == 0) break;
      if (vec[2 * x].first >= vec[2 * x + 1].first)
        vec[x] = vec[2 * x];
      else
        vec[x] = vec[2 * x + 1];
    }
  }
  pair<long long, long long> segmax(long long a, long long b, long long k = 1,
                                    long long l = 0, long long r = -10) {
    if (r < 0) r = cor;
    if (a <= l && r <= b) {
      return vec[k];
    }
    if (r <= a || b <= l) {
      return make_pair(-(1ll << 31), -1);
    }
    pair<long long, long long> v1 = segmax(a, b, k * 2, l, (l + r) / 2),
                               v2 = segmax(a, b, k * 2 + 1, (l + r) / 2, r);
    if (v1.first >= v2.first)
      return v1;
    else
      return v2;
  }
  pair<long long, long long> leftmost(long long b, long long k, long long l,
                                      long long r) {
    if (r - l == 1) return vec[k];
    if (vec[2 * k].first >= b)
      return leftmost(b, 2 * k, l, (l + r) / 2);
    else
      return leftmost(b, 2 * k + 1, (l + r) / 2, r);
  }
  pair<long long, long long> bound(long long a, long long b, long long k = -1,
                                   long long l = 0, long long r = 0) {
    if (k < 0) {
      k = cor + a;
      l = a, r = a + 1;
    }
    if (vec[k].first >= b) return leftmost(b, k, l, r);
    if (r == cor) return make_pair(-1, -1);
    if (k % 2 == 0) {
      long long dd = r - l;
      return bound(a, b, k + 1, r, r + dd);
    } else {
      long long dd = r - l;
      return bound(a, b, k / 2 + 1, r, r + 2 * dd);
    }
  }
};
Segmax sm;
Segsum ss;
long long n;
long long solve() {
  if (ss.vec[ss.cor + 1] == 0) return 1;
  long long l = 1;
  while (1) {
    long long gs = ss.sum(1, l + 1);
    pair<long long, long long> z = sm.bound(l + 1, gs);
    if (z.second == -1) return -1;
    if (z.first == ss.sum(1, z.second)) return z.second;
    l = z.second;
  }
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long q;
  cin >> n >> q;
  sm.shoki1();
  ss.shoki1();
  for (long long i = 1; i <= n; i++) {
    long long y;
    cin >> y;
    ss.vec[ss.cor + i] = y;
    sm.vec[sm.cor + i].first = y;
  }
  sm.shoki2();
  ss.shoki2();
  for (long long i = 1; i <= q; i++) {
    long long x, r;
    cin >> x >> r;
    sm.updchan(x, r);
    ss.updchan(x, r);
    cout << solve() << endl;
  }
  return 0;
}

### Prompt

Please provide a CPP coded solution to the problem described below:

Nastya likes reading and even spends whole days in a library sometimes. Today she found a chronicle of Byteland in the library, and it stated that there lived shamans long time ago. It is known that at every moment there was exactly one shaman in Byteland, and there were n shamans in total enumerated with integers from 1 to n in the order they lived. Also, each shaman had a magic power which can now be expressed as an integer.

The chronicle includes a list of powers of the n shamans. Also, some shamans can be king-shamans, if they gathered all the power of their predecessors, i.e. their power is exactly the sum of powers of all previous shamans. Nastya is interested in whether there was at least one king-shaman in Byteland.

Unfortunately many of the powers are unreadable in the list, so Nastya is doing the following:

  * Initially she supposes some power for each shaman. 
  * After that she changes the power of some shaman q times (the shamans can differ) and after that wants to check if there is at least one king-shaman in the list. If yes, she wants to know the index of any king-shaman. 



Unfortunately the list is too large and Nastya wants you to help her.

Input

The first line contains two integers n and q (1 ≤ n, q ≤ 2·105).

The second line contains n integers a1, ..., an (0 ≤ ai ≤ 109), where ai is the magic power of the i-th shaman.

After that q lines follow, the i-th of them contains two integers pi and xi (1 ≤ pi ≤ n, 0 ≤ xi ≤ 109) that mean that the new power of the pi-th shaman is xi.

Output

Print q lines, the i-th of them should contain  - 1, if after the i-th change there are no shaman-kings, and otherwise a single integer j, where j is an index of some king-shaman after the i-th change.

If there are multiple king-shamans after each change, print the index of any of them.

Examples

Input

2 1
1 3
1 2


Output

-1


Input

3 4
2 2 3
1 1
1 2
2 4
3 6


Output

3
2
-1
3


Input

10 7
0 3 1 4 6 2 7 8 10 1
2 5
1 3
9 36
4 10
4 9
1 2
1 0


Output

1
-1
9
-1
4
-1
1

Note

In the first example powers of shamans after the first change are equal to (2, 3). The answer equals  - 1, because the sum of powers of shamans before the first shaman is equal to 0, and before the second is equal to 2.

In the second example after the first change the powers are equal to (1, 2, 3). The answer is equal to 3, because the power of the third shaman is equal to 3, and the sum of powers of the first and the second shaman is also 1 + 2 = 3. After the second change the powers become equal to (2, 2, 3), where the answer equals 2. After the third change the powers become equal to (2, 4, 3), where the answer equals  - 1. After the fourth change the powers become equal to (2, 4, 6), where the answer equals 3.

### Response

```cpp
#include <bits/stdc++.h>
long long dx[4] = {0, -1, 0, 1};
long long dy[4] = {1, 0, -1, 0};
using namespace std;
class pa3 {
 public:
  long long x, y, z;
  pa3(long long x = 0, long long y = 0, long long z = 0) : x(x), y(y), z(z) {}
  bool operator<(const pa3 &p) const {
    if (x != p.x) return x < p.x;
    if (y != p.y) return y < p.y;
    return z < p.z;
  }
  bool operator>(const pa3 &p) const {
    if (x != p.x) return x > p.x;
    if (y != p.y) return y > p.y;
    return z > p.z;
  }
  bool operator==(const pa3 &p) const {
    return x == p.x && y == p.y && z == p.z;
  }
  bool operator!=(const pa3 &p) const {
    return !(x == p.x && y == p.y && z == p.z);
  }
};
class pa4 {
 public:
  double x;
  long long y, z, w;
  pa4(double x = 0, long long y = 0, long long z = 0, long long w = 0)
      : x(x), y(y), z(z), w(w) {}
  bool operator<(const pa4 &p) const {
    if (x != p.x) return x < p.x;
    if (y != p.y) return y < p.y;
    if (z != p.z) return z < p.z;
    return w < p.w;
  }
  bool operator>(const pa4 &p) const {
    if (x != p.x) return x > p.x;
    if (y != p.y) return y > p.y;
    if (z != p.z) return z > p.z;
    return w > p.w;
  }
  bool operator==(const pa4 &p) const {
    return x == p.x && y == p.y && z == p.z && w == p.w;
  }
};
class pa2 {
 public:
  long long x, y;
  pa2(long long x = 0, long long y = 0) : x(x), y(y) {}
  pa2 operator+(pa2 p) { return pa2(x + p.x, y + p.y); }
  pa2 operator-(pa2 p) { return pa2(x - p.x, y - p.y); }
  bool operator<(const pa2 &p) const { return y != p.y ? y < p.y : x < p.x; }
  bool operator>(const pa2 &p) const { return x != p.x ? x < p.x : y < p.y; }
  bool operator==(const pa2 &p) const {
    return abs(x - p.x) == 0 && abs(y - p.y) == 0;
  }
  bool operator!=(const pa2 &p) const {
    return !(abs(x - p.x) == 0 && abs(y - p.y) == 0);
  }
};
class Point {
 public:
  double x, y;
  Point(double x = 0, double y = 0) : x(x), y(y) {}
  Point operator+(Point p) { return Point(x + p.x, y + p.y); }
  Point operator-(Point p) { return Point(x - p.x, y - p.y); }
  Point operator*(double a) { return Point(x * a, y * a); }
  Point operator/(double a) { return Point(x / a, y / a); }
  double absv() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  bool operator<(const Point &p) const { return x != p.x ? x < p.x : y < p.y; }
  bool operator==(const Point &p) const {
    return fabs(x - p.x) < (1e-10) && fabs(y - p.y) < (1e-10);
  }
};
struct Segment {
  Point p1, p2;
};
double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; }
bool parareru(Point a, Point b, Point c, Point d) {
  return abs(cross(a - b, d - c)) < (1e-10);
}
double distance_ls_p(Point a, Point b, Point c) {
  if (dot(b - a, c - a) < (1e-10)) return (c - a).absv();
  if (dot(a - b, c - b) < (1e-10)) return (c - b).absv();
  return abs(cross(b - a, c - a)) / (b - a).absv();
}
bool is_intersected_ls(Segment a, Segment b) {
  if (a.p1 == b.p1 || a.p2 == b.p1 || a.p1 == b.p2 || a.p2 == b.p2)
    return false;
  if (parareru((a.p2), (a.p1), (a.p1), (b.p2)) &&
      parareru((a.p2), (a.p1), (a.p1), (b.p1))) {
    if (dot(a.p1 - b.p1, a.p1 - b.p2) < (1e-10)) return true;
    if (dot(a.p2 - b.p1, a.p2 - b.p2) < (1e-10)) return true;
    if (dot(a.p1 - b.p1, a.p2 - b.p1) < (1e-10)) return true;
    if (dot(a.p1 - b.p2, a.p2 - b.p2) < (1e-10)) return true;
    return false;
  } else
    return (cross(a.p2 - a.p1, b.p1 - a.p1) * cross(a.p2 - a.p1, b.p2 - a.p1) <
            (1e-10)) &&
           (cross(b.p2 - b.p1, a.p1 - b.p1) * cross(b.p2 - b.p1, a.p2 - b.p1) <
            (1e-10));
}
double segment_dis(Segment a, Segment b) {
  if (is_intersected_ls(a, b)) return 0;
  double r = distance_ls_p(a.p1, a.p2, b.p1);
  r = min(r, distance_ls_p(a.p1, a.p2, b.p2));
  r = min(r, distance_ls_p(b.p1, b.p2, a.p2));
  r = min(r, distance_ls_p(b.p1, b.p2, a.p1));
  return r;
}
Point intersection_ls(Segment a, Segment b) {
  Point ba = b.p2 - b.p1;
  double d1 = abs(cross(ba, a.p1 - b.p1));
  double d2 = abs(cross(ba, a.p2 - b.p1));
  double t = d1 / (d1 + d2);
  return a.p1 + (a.p2 - a.p1) * t;
}
string itos(long long i) {
  ostringstream s;
  s << i;
  return s.str();
}
long long gcd(long long v, long long b) {
  if (v > b) return gcd(b, v);
  if (v == b) return b;
  if (b % v == 0) return v;
  return gcd(v, b % v);
}
double distans(double x1, double y1, double x2, double y2) {
  double rr = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
  return sqrt(rr);
}
long long mod;
long long pr[2010];
long long inv[2010];
long long beki(long long wa, long long rr, long long warukazu) {
  if (rr == 0) return 1 % warukazu;
  if (rr == 1) return wa % warukazu;
  if (rr % 2 == 1) return (beki(wa, rr - 1, warukazu) * wa) % warukazu;
  long long zx = beki(wa, rr / 2, warukazu);
  return (zx * zx) % warukazu;
}
void gya(long long ert) {
  pr[0] = 1;
  for (long long i = 1; i < ert; i++) {
    pr[i] = (pr[i - 1] * i) % mod;
  }
  for (long long i = 0; i < ert; i++) inv[i] = beki(pr[i], mod - 2, mod);
}
struct Segsum {
 private:
 public:
  long long cor = (1 << 18);
  vector<long long> vec;
  vector<long long> lazy;
  void shoki1() { vec.resize(2 * cor + 3, 0); }
  void shoki2() {
    for (long long i = cor - 1; i > 0; i--)
      vec[i] = vec[2 * i] + vec[2 * i + 1];
  }
  void clear() {
    for (long long i = 0; i < (long long)vec.size(); i++) vec[i] = 0;
  }
  void updadd(long long x, long long w) {
    x += cor;
    vec[x] += w;
    while (1) {
      x /= 2;
      if (x == 0) break;
      vec[x] = vec[2 * x] + vec[2 * x + 1];
    }
  }
  void updchan(long long x, long long w) {
    x += cor;
    vec[x] = w;
    while (1) {
      x /= 2;
      if (x == 0) break;
      vec[x] = vec[2 * x] + vec[2 * x + 1];
    }
  }
  long long sum(long long a, long long b, long long k = 1, long long l = 0,
                long long r = -10) {
    if (r < 0) r = cor;
    if (a <= l && r <= b) {
      return vec[k];
    }
    if (r <= a || b <= l) {
      return 0;
    }
    long long v1 = sum(a, b, k * 2, l, (l + r) / 2),
              v2 = sum(a, b, k * 2 + 1, (l + r) / 2, r);
    return v1 + v2;
  }
};
struct Segmax {
 private:
 public:
  long long cor = (1 << 18);
  vector<pair<long long, long long> > vec;
  void shoki1() {
    vec.resize(2 * cor + 3, make_pair(0, 0));
    for (long long i = cor; i < 2 * cor; i++) vec[i].second = i - cor;
  }
  void shoki2() {
    for (long long i = cor - 1; i > 0; i--) {
      if (vec[2 * i].first >= vec[2 * i + 1].first)
        vec[i] = vec[2 * i];
      else
        vec[i] = vec[2 * i + 1];
    }
  }
  void updadd(long long x, long long w) {
    x += cor;
    vec[x].first += w;
    while (1) {
      x /= 2;
      if (x == 0) break;
      if (vec[2 * x].first >= vec[2 * x + 1].first)
        vec[x] = vec[2 * x];
      else
        vec[x] = vec[2 * x + 1];
    }
  }
  void updchan(long long x, long long w) {
    x += cor;
    vec[x].first = w;
    while (1) {
      x /= 2;
      if (x == 0) break;
      if (vec[2 * x].first >= vec[2 * x + 1].first)
        vec[x] = vec[2 * x];
      else
        vec[x] = vec[2 * x + 1];
    }
  }
  pair<long long, long long> segmax(long long a, long long b, long long k = 1,
                                    long long l = 0, long long r = -10) {
    if (r < 0) r = cor;
    if (a <= l && r <= b) {
      return vec[k];
    }
    if (r <= a || b <= l) {
      return make_pair(-(1ll << 31), -1);
    }
    pair<long long, long long> v1 = segmax(a, b, k * 2, l, (l + r) / 2),
                               v2 = segmax(a, b, k * 2 + 1, (l + r) / 2, r);
    if (v1.first >= v2.first)
      return v1;
    else
      return v2;
  }
  pair<long long, long long> leftmost(long long b, long long k, long long l,
                                      long long r) {
    if (r - l == 1) return vec[k];
    if (vec[2 * k].first >= b)
      return leftmost(b, 2 * k, l, (l + r) / 2);
    else
      return leftmost(b, 2 * k + 1, (l + r) / 2, r);
  }
  pair<long long, long long> bound(long long a, long long b, long long k = -1,
                                   long long l = 0, long long r = 0) {
    if (k < 0) {
      k = cor + a;
      l = a, r = a + 1;
    }
    if (vec[k].first >= b) return leftmost(b, k, l, r);
    if (r == cor) return make_pair(-1, -1);
    if (k % 2 == 0) {
      long long dd = r - l;
      return bound(a, b, k + 1, r, r + dd);
    } else {
      long long dd = r - l;
      return bound(a, b, k / 2 + 1, r, r + 2 * dd);
    }
  }
};
Segmax sm;
Segsum ss;
long long n;
long long solve() {
  if (ss.vec[ss.cor + 1] == 0) return 1;
  long long l = 1;
  while (1) {
    long long gs = ss.sum(1, l + 1);
    pair<long long, long long> z = sm.bound(l + 1, gs);
    if (z.second == -1) return -1;
    if (z.first == ss.sum(1, z.second)) return z.second;
    l = z.second;
  }
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long q;
  cin >> n >> q;
  sm.shoki1();
  ss.shoki1();
  for (long long i = 1; i <= n; i++) {
    long long y;
    cin >> y;
    ss.vec[ss.cor + i] = y;
    sm.vec[sm.cor + i].first = y;
  }
  sm.shoki2();
  ss.shoki2();
  for (long long i = 1; i <= q; i++) {
    long long x, r;
    cin >> x >> r;
    sm.updchan(x, r);
    ss.updchan(x, r);
    cout << solve() << endl;
  }
  return 0;
}

```