#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 9;
const long long Log2 = 20;
const long long inf = 1e16 + 7;
long long n, Q, a[N], b[N], pre[N];
struct Node {
  long long sum, mnpre, mxcon, mncon, mxL, mnL, mxR, mnR;
};
Node spare = {0, inf, -inf, inf, -inf, inf, -inf, inf};
Node st[4 * N];
void Init(long long id, long long val) {
  st[id].sum = st[id].mnpre = st[id].mxcon = st[id].mncon = val;
  st[id].mxL = st[id].mnL = st[id].mxR = st[id].mnR = val;
}
Node Combine(Node lf, Node rg) {
  Node kq;
  kq.sum = lf.sum + rg.sum;
  kq.mnpre = min(lf.mnpre, lf.sum + rg.mnpre);
  kq.mxcon = max(lf.mxcon, max(rg.mxcon, lf.mxR + rg.mxL));
  kq.mncon = min(lf.mncon, min(rg.mncon, lf.mnR + rg.mnL));
  kq.mxL = max(lf.mxL, lf.sum + rg.mxL);
  kq.mxR = max(rg.mxR, rg.sum + lf.mxR);
  kq.mnL = min(lf.mnL, lf.sum + rg.mnL);
  kq.mnR = min(rg.mnR, rg.sum + lf.mnR);
  return kq;
}
void upd(long long id, long long l, long long r, long long u, long long val) {
  if (u < l || r < u) return;
  if (l == r) {
    Init(id, val);
    return;
  }
  long long mid = (l + r) / 2;
  upd(id * 2, l, mid, u, val);
  upd(id * 2 + 1, mid + 1, r, u, val);
  st[id] = Combine(st[id * 2], st[id * 2 + 1]);
}
Node Get(long long id, long long l, long long r, long long u, long long v) {
  if (v < l || r < u) return spare;
  if (u <= l && r <= v) return st[id];
  long long mid = (l + r) / 2;
  return Combine(Get(id * 2, l, mid, u, v), Get(id * 2 + 1, mid + 1, r, u, v));
}
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(0);
  cout.tie(0);
  if (fopen("tst"
            ".INP",
            "r")) {
    freopen(
        "tst"
        ".INP",
        "r", stdin);
  }
  cin >> n >> Q;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= n; i++) {
    cin >> b[i], a[i] = b[i] - a[i];
    upd(1, 1, n, i, a[i]);
    pre[i] = pre[i - 1] + a[i];
  }
  while (Q--) {
    long long l, r;
    cin >> l >> r;
    Node now = Get(1, 1, n, l, r);
    if (now.sum != 0 || now.mnpre < 0) {
      cout << -1 << "\n";
      continue;
    }
    long long kq = max(now.mxcon, -now.mncon);
    cout << kq << "\n";
  }
}
