#include <bits/stdc++.h>   using namespace std;   int N, M;   int d[300010];   int h[300010];   pair<long long, int> L[8 * 300010];   pair<long long, int> R[8 * 300010];   void aggL(int nodo, int left, int right, int pos, long long val) {     if (left == right) {       L[nodo] = pair<long long, int>(val, pos);       return;     }     int mid = (left + right) / 2;     if (pos <= mid)       aggL(nodo * 2, left, mid, pos, val);     else       aggL(nodo * 2 + 1, mid + 1, right, pos, val);     L[nodo] = max(L[nodo * 2], L[nodo * 2 + 1]);   }   void aggR(int nodo, int left, int right, int pos, long long val) {     if (left == right) {       R[nodo] = pair<long long, int>(val, pos);       return;     }     int mid = (left + right) / 2;     if (pos <= mid)       aggR(nodo * 2, left, mid, pos, val);     else       aggR(nodo * 2 + 1, mid + 1, right, pos, val);     R[nodo] = max(R[nodo * 2], R[nodo * 2 + 1]);   }   pair<long long, int> qL(int nodo, int left, int right, int l, int r) {     if (left == l && right == r) return L[nodo];     int mid = (left + right) / 2;     if (r <= mid) return qL(nodo * 2, left, mid, l, r);     if (l >= mid + 1) return qL(nodo * 2 + 1, mid + 1, right, l, r);     if (l <= mid && r >= mid + 1)       return max(qL(nodo * 2, left, mid, l, mid),                  qL(nodo * 2 + 1, mid + 1, right, mid + 1, r));   }   pair<long long, int> qR(int nodo, int left, int right, int l, int r) {     if (left == l && right == r) return R[nodo];     int mid = (left + right) / 2;     if (r <= mid) return qR(nodo * 2, left, mid, l, r);     if (l >= mid + 1) return qR(nodo * 2 + 1, mid + 1, right, l, r);     if (l <= mid && r >= mid + 1)       return max(qR(nodo * 2, left, mid, l, mid),                  qR(nodo * 2 + 1, mid + 1, right, mid + 1, r));   }   int main() {     ifstream in( input.txt );     cin >> N >> M;     for (int i = 0; i < N; i++) cin >> d[i];     for (int i = 0; i < N; i++) cin >> h[i];     for (int i = 0; i < 8 * 300010; i++) L[i].first = R[i].first = LLONG_MIN;     long long temp = 0;     for (int i = 0; i < N; i++) {       aggR(1, 0, 2 * 300010 - 1, i, temp + h[i] * 2);       aggL(1, 0, 2 * 300010 - 1, i, h[i] * 2 - temp);       temp += d[i];     }     for (int i = 0; i < N; i++) {       aggR(1, 0, 2 * 300010 - 1, i + N, temp + h[i] * 2);       aggL(1, 0, 2 * 300010 - 1, i + N, h[i] * 2 - temp);       temp += d[i];     }     for (int i = 0; i < M; i++) {       int a, b;       cin >> a >> b;       a--;       b--;       if (a <= b) {         temp = qR(1, 0, 2 * 300010 - 1, b + 2, N + a - 1).first;         int pos = qR(1, 0, 2 * 300010 - 1, b + 2, N + a - 1).second;         temp += qL(1, 0, 2 * 300010 - 1, b + 1, pos - 1).first;         long long res = temp;         temp = qL(1, 0, 2 * 300010 - 1, b + 1, N + a - 2).first;         pos = qL(1, 0, 2 * 300010 - 1, b + 1, N + a - 2).second;         temp += qR(1, 0, 2 * 300010 - 1, pos + 1, N + a - 1).first;         res = max(res, temp);         cout << res << endl;       } else {         temp = qR(1, 0, 2 * 300010 - 1, b + 2, a - 1).first;         int pos = qR(1, 0, 2 * 300010 - 1, b + 2, a - 1).second;         temp += qL(1, 0, 2 * 300010 - 1, b + 1, pos - 1).first;         long long res = temp;         temp = qL(1, 0, 2 * 300010 - 1, b + 1, a - 2).first;         pos = qL(1, 0, 2 * 300010 - 1, b + 1, a - 2).second;         temp += qR(1, 0, 2 * 300010 - 1, pos + 1, a - 1).first;         res = max(res, temp);         cout << res << endl;       }     }     return 0;   }   