#include <bits/stdc++.h>
template <typename... Args>
void pr(Args... args) {}
using namespace std;
using ll = long long;
int const MM = 1e5 + 5;
int n, q;
int a[MM], b[MM];
struct segment_tree {
  struct node {
    ll sum, lhi, llo, rhi;
  } tree[MM * 4];
  const node DEF = {0, INT_MIN / 2, INT_MAX / 2, INT_MIN / 2};
  node merge(node l, node r) {
    node x;
    x.sum = l.sum + r.sum;
    x.lhi = max(l.lhi, l.sum + r.lhi);
    x.llo = min(l.llo, l.sum + r.llo);
    x.rhi = max(l.rhi + r.sum, r.rhi);
    return x;
  }
  void pull(int rt) { tree[rt] = merge(tree[rt << 1], tree[rt << 1 | 1]); }
  void build(int nl = 0, int nr = n + 2, int rt = 1) {
    if (nl == nr) {
      int v = b[nl] - a[nl];
      tree[rt] = {v, v, v, v};
      return;
    }
    build(nl, ((nl + nr) / 2), rt << 1);
    build(((nl + nr) / 2) + 1, nr, rt << 1 | 1);
    pull(rt);
  }
  node query(int l, int r, int nl = 0, int nr = n + 2, int rt = 1) {
    if (r < nl or nr < l) return DEF;
    if (l <= nl and nr <= r) return tree[rt];
    return merge(query(l, r, nl, ((nl + nr) / 2), rt << 1),
                 query(l, r, ((nl + nr) / 2) + 1, nr, rt << 1 | 1));
  }
} ST;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
  }
  ST.build();
  while (q--) {
    int l, r;
    cin >> l >> r;
    auto res = ST.query(l, r);
    pr(res.sum, res.lhi, res.llo, res.rhi);
    if (res.sum or res.llo < 0 or res.rhi > 0) {
      cout << "-1\n";
    } else {
      cout << res.lhi << '\n';
    }
  }
}
