#include <bits/stdc++.h>
using namespace std;
void canhazfast() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
T extgcd(T a, T b, T &x, T &y) {
  T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
  while (b) {
    T q = a / b;
    a %= b;
    swap(a, b);
    x0 -= q * x1;
    swap(x0, x1);
    y0 -= q * y1;
    swap(y0, y1);
  }
  x = x0;
  y = y0;
  return a;
}
int ctz(unsigned x) { return __builtin_ctz(x); }
int ctzll(unsigned long long x) { return __builtin_ctzll(x); }
int clz(unsigned x) { return __builtin_clz(x); }
int clzll(unsigned long long x) { return __builtin_clzll(x); }
int popcnt(unsigned x) { return __builtin_popcount(x); }
int popcntll(unsigned long long x) { return __builtin_popcountll(x); }
int bsr(unsigned x) { return 31 ^ clz(x); }
int bsrll(unsigned long long x) { return 63 ^ clzll(x); }
int x[100016];
pair<long long, long long> tree[(1 << 18)];
pair<long long, long long> comp(const pair<long long, long long> &lhs,
                                const pair<long long, long long> &rhs) {
  return {lhs.first + rhs.first, min(lhs.second, lhs.first + rhs.second)};
}
void build(int u, int b, int e) {
  if (b + 1 == e) {
    tree[u] = {x[b], x[b]};
    return;
  }
  int m = (b + e) / 2, lc = 2 * u, rc = lc + 1;
  build(lc, b, m);
  build(rc, m, e);
  tree[u] = comp(tree[lc], tree[rc]);
}
pair<long long, long long> get(int u, int b, int e, int l, int r) {
  if (b >= r || l >= e) return {0, 0};
  if (b >= l && r >= e) return tree[u];
  int m = (b + e) / 2, lc = 2 * u, rc = lc + 1;
  return comp(get(lc, b, m, l, r), get(rc, m, e, l, r));
}
int main() {
  canhazfast();
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n; ++i) cin >> x[i];
  for (int i = 0; i < n; ++i) {
    int b;
    cin >> b;
    x[i] -= b;
  }
  build(1, 0, n);
  for (int i = 0; i < q; ++i) {
    int l, r;
    cin >> l >> r;
    --l;
    pair<long long, long long> res = get(1, 0, n, l, r);
    if (res.first != 0 || res.second > 0)
      cout << "-1\n";
    else
      cout << -res.second << '\n';
  }
  return 0;
}
