#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int maxn = 5e6 + 5;
int n, q;
long long a[100005], t[100005];
pair<long long, long long> id[500005];
void up(int k, int l, int r) {
  if (l == r)
    id[k] = {t[l], t[l]};
  else {
    int mid = (l + r) / 2;
    up(k * 2, l, mid);
    up(k * 2 + 1, mid + 1, r);
    id[k].first = max(id[k * 2].first, id[k * 2 + 1].first);
    id[k].second = min(id[k * 2].second, id[k * 2 + 1].second);
  }
}
long long getmax(int k, int l, int r, int u, int v) {
  if (l > r || l > v || r < u) return -1e16;
  if (l >= u && r <= v) return id[k].first;
  int mid = (l + r) / 2;
  return max(getmax(k * 2, l, mid, u, v), getmax(k * 2 + 1, mid + 1, r, u, v));
}
long long getmin(int k, int l, int r, int u, int v) {
  if (l > r || l > v || r < u) return 1e16;
  if (l >= u && r <= v) return id[k].second;
  int mid = (l + r) / 2;
  return min(getmin(k * 2, l, mid, u, v), getmin(k * 2 + 1, mid + 1, r, u, v));
}
int main() {
  ios::sync_with_stdio(0);
  ;
  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    long long u;
    cin >> u;
    t[i] = t[i - 1] + a[i] - u;
  }
  up(1, 1, n);
  for (; q--;) {
    int u, v;
    cin >> u >> v;
    if (t[v] != t[u - 1]) {
      cout << -1 << '\n';
      continue;
    }
    if (getmax(1, 1, n, u, v) > t[u - 1]) {
      cout << -1 << '\n';
      continue;
    }
    cout << t[u - 1] - getmin(1, 1, n, u, v) << '\n';
  }
  return 0;
}
