#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 2;
int a[N], n, q;
int readInt() {
  bool minus = false;
  int result = 0;
  char ch;
  ch = getchar();
  while (true) {
    if (ch == '-') break;
    if (ch >= '0' && ch <= '9') break;
    ch = getchar();
  }
  if (ch == '-')
    minus = true;
  else
    result = ch - '0';
  while (true) {
    ch = getchar();
    if (ch < '0' || ch > '9') break;
    result = result * 10 + (ch - '0');
  }
  if (minus)
    return -result;
  else
    return result;
}
long long bit[N];
void upd(int p, int val) {
  for (; p <= n; p += p & -p) {
    bit[p] += val;
  }
}
long long get(int p) {
  long long ans = 0;
  for (; p > 0; p -= p & -p) {
    ans += bit[p];
  }
  return ans;
}
set<int> S[30];
set<int>::iterator it;
void query() {
  int p = readInt();
  int x = readInt();
  upd(p, x - a[p]);
  for (int j = 30; j >= 0; j--) {
    if (a[p] & (1 << j)) {
      S[j].erase(p);
      break;
    }
  }
  for (int j = 30; j >= 0; j--) {
    if (x & (1 << j)) {
      S[j].insert(p);
      break;
    }
  }
  a[p] = x;
  if (a[1] == 0) {
    printf("1\n");
    return;
  }
  for (int i = 0; i < 30; ++i) {
    int j = 0;
    for (it = S[i].begin(); it != S[i].end() && j < 2; ++it, ++j) {
      int pos = *it;
      if (a[pos] == get(pos - 1)) {
        printf("%d\n", pos);
        return;
      }
    }
  }
  printf("-1\n");
}
int main() {
  n = readInt();
  q = readInt();
  for (int i = 1; i <= n; i++) {
    a[i] = readInt();
    for (int j = 30; j >= 0; j--) {
      if (a[i] & (1 << j)) {
        S[j].insert(i);
        break;
      }
    }
    upd(i, a[i]);
  }
  while (q--) {
    query();
  }
}
