#include <bits/stdc++.h>
using namespace std;
int log2(int x) { return 31 - __builtin_clz(x); }
int main(void) {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  int n, q;
  cin >> n >> q;
  vector<long long> a(n);
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i];
  }
  for (int i = 0; i < (int)(n); i++) {
    int b;
    cin >> b;
    a[i] = b - a[i];
    if (i) {
      a[i] += a[i - 1];
    }
  }
  vector<vector<long long> > mn(20, vector<long long>(n)),
      mx(20, vector<long long>(n));
  copy(a.begin(), a.end(), mn[0].begin());
  copy(a.begin(), a.end(), mx[0].begin());
  for (int k = 1; k < 20; k++) {
    for (int i = 0; i + (1 << (k - 1)) < n; i++) {
      mn[k][i] = min(mn[k - 1][i], mn[k - 1][i + (1 << (k - 1))]);
      mx[k][i] = max(mx[k - 1][i], mx[k - 1][i + (1 << (k - 1))]);
    }
  }
  int l, r;
  while (q--) {
    cin >> l >> r;
    --l;
    int k = log2(r - l);
    long long _min = min(mn[k][l], mn[k][r - (1 << k)]);
    long long _max = max(mx[k][l], mx[k][r - (1 << k)]);
    long long start = l ? a[l - 1] : 0;
    if (start != a[r - 1] || _min < start) {
      cout << "-1\n";
    } else {
      cout << _max - start << "\n";
    }
  }
  return 0;
}
