#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

namespace my {

template<typename T>
struct seti : public tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update> {
	seti(): tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>() {}
	explicit seti(initializer_list<T> o): tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>() {
		for (const T &x : o)
			this->insert(x);
	}
	inline T operator[](int i) {
		return *this->find_by_order(i);
	}
};

template<typename T>
struct vectori : public vector<T> {
	explicit vectori(size_t n, T e = T()): vector<T>(n, e) {}
	template< class InputIt >
	vectori( InputIt first, InputIt last): vector<T>(first, last) {}
	explicit vectori(initializer_list<T> o): vector<T>(o) {}
	inline void operator+=(T o) {
		this->push_back(o);
	}
	inline void operator+=(initializer_list<T> o) {
		this->insert(this->end(), o.begin(), o.end());
	}
	inline void operator+=(vectori<T> o) {
		this->insert(this->end(), o.begin(), o.end());
	}
};

int VERY_RANDOM_NUMBER = (uint64_t)(std::make_unique<char>().get()) ^ (uint64_t)(std::chrono::high_resolution_clock::now().time_since_epoch().count());

struct chash {
	inline int operator()(int x) const {
		return x ^ VERY_RANDOM_NUMBER;
	}
};

template <class A, class B>
using hash_table = gp_hash_table<A, B, chash>;

#ifdef LOCAL
template<typename T>
ostream &operator<<(ostream &out, const vector<T> &arr) {
	out << "[";
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			out << ", ";

		out << x;
		buv = true;
	}

	out << "]";
	return out;
}
template<typename T>
ostream &operator<<(ostream &out, const vectori<T> &arr) {
	out << "[";
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			out << ", ";

		out << x;
		buv = true;
	}

	out << "]";
	return out;
}

template<typename T, typename P>
ostream &operator<<(ostream &out, const map<T, P> &arr) {
	out << "{";
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			out << ", ";

		out << x.first << " => " << x.second;
		buv = true;
	}

	out << "}";
	return out;
}

template<typename T, typename P>
ostream &operator<<(ostream &out, const set<T, P> &arr) {
	out << "{";
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			out << ", ";

		out << x;
		buv = true;
	}

	out << "}";
	return out;
}

template<typename T>
ostream &operator<<(ostream &out, const seti<T> &arr) {
	out << "{";
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			out << ", ";

		out << x;
		buv = true;
	}

	out << "}";
	return out;
}

#define debug(...) __debugg(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __debugg(const char *name, Arg1 &&arg1) {
	cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __debugg(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | ";

	if (*(comma + 1) == ' ')
		comma++;

	__debugg(comma + 1, args...);
}
#else
#define debug(...)
#endif

template<typename X, typename Y>
struct Pair {
	X x;
	Y y;
	template<typename X1, typename Y1>
	Pair(const X1 &x, const Y1 &y): x(x), y(y) {}
	Pair() {}
	template<typename X1>
	explicit Pair(const X1 &x): x(x), y(Y()) {}
	template<typename X1, typename Y1>
	Pair<X, Y> operator+(const Pair<X1, Y1> &o)const {
		return Pair<X1, Y1>(x + o.x, y + o.y);
	}
	template<typename X1, typename Y1>
	Pair<X, Y> operator-(const Pair<X1, Y1> &o)const {
		return Pair<X1, Y1>(x - o.x, y - o.y);
	}
	template<typename X1, typename Y1>
	Pair<X, Y> operator*(const Pair<X1, Y1> &o)const {
		return Pair<X1, Y1>(x * o.x, y * o.y);
	}
	template<typename X1, typename Y1>
	Pair<X, Y> operator/(const Pair<X1, Y1> &o)const {
		return Pair<X1, Y1>(x / o.x, y / o.y);
	}
	template<typename X1, typename Y1>
	void operator+=(const Pair<X1, Y1> &o) {
		x += o.x;
		y += o.y;
	}
	template<typename X1, typename Y1>
	void operator-=(const Pair<X1, Y1> &o) {
		x -= o.x;
		y -= o.y;
	}
	template<typename X1, typename Y1>
	void operator*=(const Pair<X1, Y1> &o) {
		x *= o.x;
		y *= o.y;
	}
	template<typename X1, typename Y1>
	void operator/=(const Pair<X1, Y1> &o) {
		x /= o.x;
		y /= o.y;
	}
	template<typename X1, typename Y1>
	bool operator<(const Pair<X1, Y1> &o)const {
		if (x == o.x)
			return y < o.y;

		return x < o.x;
	}
	template<typename X1, typename Y1>
	bool operator<=(const Pair<X1, Y1> &o)const {
		if (x == o.x)
			return y <= o.y;

		return x <= o.x;
	}
	template<typename X1, typename Y1>
	bool operator>(const Pair<X1, Y1> &o)const {
		if (x == o.x)
			return y > o.y;

		return x > o.x;
	}
	template<typename X1, typename Y1>
	bool operator>=(const Pair<X1, Y1> &o)const {
		if (x == o.x)
			return y >= o.y;

		return x >= o.x;
	}
	template<typename X1, typename Y1>
	bool operator==(const Pair<X1, Y1> &o)const {
		return x == o.x and y == o.y;
	}
	template<typename X1, typename Y1>
	bool operator!=(const Pair<X1, Y1> &o)const {
		return x != o.x or y != o.y;
	}
	template<typename X1, typename Y1>
	void swap(Pair<X1, Y1> &o) {
		swap(x, o.x);
		swap(y, o.y);
	}
};

template<typename X, typename Y>
Pair<X, Y> makep(const X &x, const Y &y) {
	return Pair<X, Y>(x, y);
}

template<typename X, typename Y>
ostream &operator<<(ostream &out, const Pair<X, Y> &p) {
	out << "(" << p.x << ", " << p.y << ")";
	return out;
}

template<typename X, typename Y>
istream &operator>>(istream &in, Pair<X, Y> &p) {
	in >> p.x >> p.y;
	return in;
}

#define make_pair(...) makep(__VA_ARGS__)
#define pair Pair

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef Pair<int, int> pii;
typedef Pair<ll, ll> pll;
typedef vector<pll> vpll;

template<typename T>
istream &operator>>(istream &in, vector<T> &arr) {
	for (auto && x : arr) {
		in >> x;
	}

	return in;
}

template<typename T>
void printi(const T &arr, char skyr = '\n') {
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			cout << skyr;

		cout << x;
		buv = true;
	}
}

template<typename T>
void printi(const T &arr, const string &skyr) {
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			cout << skyr;

		cout << x;
		buv = true;
	}
}

template<typename X, typename Y>
void printp(const Pair<X, Y> &p, char skyr = ' ') {
	cout << p.x << skyr << p.y;
}

template<typename X, typename Y>
void printp(const Pair<X, Y> &p, const string &skyr) {
	cout << p.x << skyr << p.y;
}

template<typename X, typename Y>
inline X mini(X &a, const Y &b) __attribute__((always_inline));
template<typename X, typename Y>
inline X mini(X &a, const Y &b) {
	if (a > b)
		a = b;

	return a;
}
template<typename X, typename Y>
inline X maxi(X &a, const Y &b) __attribute__((always_inline));
template<typename X, typename Y>
inline X maxi(X &a, const Y &b) {
	if (a < b)
		a = b;

	return a;
}

template<ll X, ll Y>
inline bool between(ll v)__attribute__((always_inline));
template<ll X, ll Y>
inline bool between(ll v) {
	return ull(v - X) <= ull(Y - X);
}

inline bool between(ll X, ll v, ll Y) __attribute__((always_inline));
inline bool between(ll X, ll v, ll Y) {
	return ull(v - X) <= ull(Y - X);
}
}
using namespace my;

/*input
3
8 4 1
2
2 3
1 2
*/
/*output
5
12
*/
/*input
6
1 2 4 8 16 32
4
1 6
2 5
3 4
1 2
*/
/*output
60
30
12
3
*/

int main () {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	vi fif[5001];
	fif[1].push_back(1);
	fif[2].push_back(1);
	fif[2].push_back(1);

	for (int i = 3; i <= 5000; i++) {
		fif[i].push_back(1);

		for (int j = 0; j + 1 < i - 1; j++) {
			fif[i].push_back((fif[i - 1][j] + fif[i - 1][j + 1]) % 2);
		}

		fif[i].push_back(1);
	}

	vi fi[5001];

	for (int i = 1; i <= 5000; i++) {
		for (int j = 0; j < i; j++) {
			if (fif[i][j] == 1) {
				fi[i].push_back(j);
			}
		}
	}

	int n;
	cin >> n;
	vll a(n);
	cin >> a;

	auto f = [&](int fr, int to)-> ll {
		ll ats = 0;

		for (auto && i : fi[to - fr + 1]) {
			ats ^= a[i + fr];
		}

		return ats;
	};

	ll ats[n][n] = {};

	for (int i = 0; i < n; i++) {
		ats[i][i] = a[i];

		for (int j = i + 1; j < n; j++) {
			ats[i][j] = max(ats[i][j - 1], f(i, j));
			debug(i, j, f(i, j));
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = i - 1; j >= 0; j--) {
			maxi(ats[j][i], ats[j + 1][i]);
		}
	}

	int q;
	cin >> q;

	for (int i = 0; i < q; i++) {
		int x, y;
		cin >> x >> y;
		cout << ats[x - 1][y - 1] << "\n";
	}
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

namespace my {

template<typename T>
struct seti : public tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update> {
	seti(): tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>() {}
	explicit seti(initializer_list<T> o): tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>() {
		for (const T &x : o)
			this->insert(x);
	}
	inline T operator[](int i) {
		return *this->find_by_order(i);
	}
};

template<typename T>
struct vectori : public vector<T> {
	explicit vectori(size_t n, T e = T()): vector<T>(n, e) {}
	template< class InputIt >
	vectori( InputIt first, InputIt last): vector<T>(first, last) {}
	explicit vectori(initializer_list<T> o): vector<T>(o) {}
	inline void operator+=(T o) {
		this->push_back(o);
	}
	inline void operator+=(initializer_list<T> o) {
		this->insert(this->end(), o.begin(), o.end());
	}
	inline void operator+=(vectori<T> o) {
		this->insert(this->end(), o.begin(), o.end());
	}
};

int VERY_RANDOM_NUMBER = (uint64_t)(std::make_unique<char>().get()) ^ (uint64_t)(std::chrono::high_resolution_clock::now().time_since_epoch().count());

struct chash {
	inline int operator()(int x) const {
		return x ^ VERY_RANDOM_NUMBER;
	}
};

template <class A, class B>
using hash_table = gp_hash_table<A, B, chash>;

#ifdef LOCAL
template<typename T>
ostream &operator<<(ostream &out, const vector<T> &arr) {
	out << "[";
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			out << ", ";

		out << x;
		buv = true;
	}

	out << "]";
	return out;
}
template<typename T>
ostream &operator<<(ostream &out, const vectori<T> &arr) {
	out << "[";
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			out << ", ";

		out << x;
		buv = true;
	}

	out << "]";
	return out;
}

template<typename T, typename P>
ostream &operator<<(ostream &out, const map<T, P> &arr) {
	out << "{";
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			out << ", ";

		out << x.first << " => " << x.second;
		buv = true;
	}

	out << "}";
	return out;
}

template<typename T, typename P>
ostream &operator<<(ostream &out, const set<T, P> &arr) {
	out << "{";
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			out << ", ";

		out << x;
		buv = true;
	}

	out << "}";
	return out;
}

template<typename T>
ostream &operator<<(ostream &out, const seti<T> &arr) {
	out << "{";
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			out << ", ";

		out << x;
		buv = true;
	}

	out << "}";
	return out;
}

#define debug(...) __debugg(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __debugg(const char *name, Arg1 &&arg1) {
	cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __debugg(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | ";

	if (*(comma + 1) == ' ')
		comma++;

	__debugg(comma + 1, args...);
}
#else
#define debug(...)
#endif

template<typename X, typename Y>
struct Pair {
	X x;
	Y y;
	template<typename X1, typename Y1>
	Pair(const X1 &x, const Y1 &y): x(x), y(y) {}
	Pair() {}
	template<typename X1>
	explicit Pair(const X1 &x): x(x), y(Y()) {}
	template<typename X1, typename Y1>
	Pair<X, Y> operator+(const Pair<X1, Y1> &o)const {
		return Pair<X1, Y1>(x + o.x, y + o.y);
	}
	template<typename X1, typename Y1>
	Pair<X, Y> operator-(const Pair<X1, Y1> &o)const {
		return Pair<X1, Y1>(x - o.x, y - o.y);
	}
	template<typename X1, typename Y1>
	Pair<X, Y> operator*(const Pair<X1, Y1> &o)const {
		return Pair<X1, Y1>(x * o.x, y * o.y);
	}
	template<typename X1, typename Y1>
	Pair<X, Y> operator/(const Pair<X1, Y1> &o)const {
		return Pair<X1, Y1>(x / o.x, y / o.y);
	}
	template<typename X1, typename Y1>
	void operator+=(const Pair<X1, Y1> &o) {
		x += o.x;
		y += o.y;
	}
	template<typename X1, typename Y1>
	void operator-=(const Pair<X1, Y1> &o) {
		x -= o.x;
		y -= o.y;
	}
	template<typename X1, typename Y1>
	void operator*=(const Pair<X1, Y1> &o) {
		x *= o.x;
		y *= o.y;
	}
	template<typename X1, typename Y1>
	void operator/=(const Pair<X1, Y1> &o) {
		x /= o.x;
		y /= o.y;
	}
	template<typename X1, typename Y1>
	bool operator<(const Pair<X1, Y1> &o)const {
		if (x == o.x)
			return y < o.y;

		return x < o.x;
	}
	template<typename X1, typename Y1>
	bool operator<=(const Pair<X1, Y1> &o)const {
		if (x == o.x)
			return y <= o.y;

		return x <= o.x;
	}
	template<typename X1, typename Y1>
	bool operator>(const Pair<X1, Y1> &o)const {
		if (x == o.x)
			return y > o.y;

		return x > o.x;
	}
	template<typename X1, typename Y1>
	bool operator>=(const Pair<X1, Y1> &o)const {
		if (x == o.x)
			return y >= o.y;

		return x >= o.x;
	}
	template<typename X1, typename Y1>
	bool operator==(const Pair<X1, Y1> &o)const {
		return x == o.x and y == o.y;
	}
	template<typename X1, typename Y1>
	bool operator!=(const Pair<X1, Y1> &o)const {
		return x != o.x or y != o.y;
	}
	template<typename X1, typename Y1>
	void swap(Pair<X1, Y1> &o) {
		swap(x, o.x);
		swap(y, o.y);
	}
};

template<typename X, typename Y>
Pair<X, Y> makep(const X &x, const Y &y) {
	return Pair<X, Y>(x, y);
}

template<typename X, typename Y>
ostream &operator<<(ostream &out, const Pair<X, Y> &p) {
	out << "(" << p.x << ", " << p.y << ")";
	return out;
}

template<typename X, typename Y>
istream &operator>>(istream &in, Pair<X, Y> &p) {
	in >> p.x >> p.y;
	return in;
}

#define make_pair(...) makep(__VA_ARGS__)
#define pair Pair

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef Pair<int, int> pii;
typedef Pair<ll, ll> pll;
typedef vector<pll> vpll;

template<typename T>
istream &operator>>(istream &in, vector<T> &arr) {
	for (auto && x : arr) {
		in >> x;
	}

	return in;
}

template<typename T>
void printi(const T &arr, char skyr = '\n') {
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			cout << skyr;

		cout << x;
		buv = true;
	}
}

template<typename T>
void printi(const T &arr, const string &skyr) {
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			cout << skyr;

		cout << x;
		buv = true;
	}
}

template<typename X, typename Y>
void printp(const Pair<X, Y> &p, char skyr = ' ') {
	cout << p.x << skyr << p.y;
}

template<typename X, typename Y>
void printp(const Pair<X, Y> &p, const string &skyr) {
	cout << p.x << skyr << p.y;
}

template<typename X, typename Y>
inline X mini(X &a, const Y &b) __attribute__((always_inline));
template<typename X, typename Y>
inline X mini(X &a, const Y &b) {
	if (a > b)
		a = b;

	return a;
}
template<typename X, typename Y>
inline X maxi(X &a, const Y &b) __attribute__((always_inline));
template<typename X, typename Y>
inline X maxi(X &a, const Y &b) {
	if (a < b)
		a = b;

	return a;
}

template<ll X, ll Y>
inline bool between(ll v)__attribute__((always_inline));
template<ll X, ll Y>
inline bool between(ll v) {
	return ull(v - X) <= ull(Y - X);
}

inline bool between(ll X, ll v, ll Y) __attribute__((always_inline));
inline bool between(ll X, ll v, ll Y) {
	return ull(v - X) <= ull(Y - X);
}
}
using namespace my;

/*input
3
8 4 1
2
2 3
1 2
*/
/*output
5
12
*/
/*input
6
1 2 4 8 16 32
4
1 6
2 5
3 4
1 2
*/
/*output
60
30
12
3
*/

int main () {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	vll a(n);
	cin >> a;

	ll f[n][n];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j + i < n; j++) {
			if (i == 0) {
				f[j][j] = a[j];
			}
			else {
				f[j][j + i] = f[j][j + i - 1] ^ f[j + 1][j + i];
			}
		}
	}

	ll ats[n][n] = {};

	for (int i = 0; i < n; i++) {
		ats[i][i] = a[i];

		for (int j = i + 1; j < n; j++) {
			ats[i][j] = max(ats[i][j - 1], f[i][j]);
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = i - 1; j >= 0; j--) {
			maxi(ats[j][i], ats[j + 1][i]);
		}
	}

	int q;
	cin >> q;

	for (int i = 0; i < q; i++) {
		int x, y;
		cin >> x >> y;
		cout << ats[x - 1][y - 1] << "\n";
	}
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

namespace my {

template<typename T>
struct seti : public tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update> {
	seti(): tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>() {}
	explicit seti(initializer_list<T> o): tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>() {
		for (const T &x : o)
			this->insert(x);
	}
	inline T operator[](int i) {
		return *this->find_by_order(i);
	}
};

template<typename T>
struct vectori : public vector<T> {
	explicit vectori(size_t n, T e = T()): vector<T>(n, e) {}
	template< class InputIt >
	vectori( InputIt first, InputIt last): vector<T>(first, last) {}
	explicit vectori(initializer_list<T> o): vector<T>(o) {}
	inline void operator+=(T o) {
		this->push_back(o);
	}
	inline void operator+=(initializer_list<T> o) {
		this->insert(this->end(), o.begin(), o.end());
	}
	inline void operator+=(vectori<T> o) {
		this->insert(this->end(), o.begin(), o.end());
	}
};

int VERY_RANDOM_NUMBER = (uint64_t)(std::make_unique<char>().get()) ^ (uint64_t)(std::chrono::high_resolution_clock::now().time_since_epoch().count());

struct chash {
	inline int operator()(int x) const {
		return x ^ VERY_RANDOM_NUMBER;
	}
};

template <class A, class B>
using hash_table = gp_hash_table<A, B, chash>;

#ifdef LOCAL
template<typename T>
ostream &operator<<(ostream &out, const vector<T> &arr) {
	out << "[";
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			out << ", ";

		out << x;
		buv = true;
	}

	out << "]";
	return out;
}
template<typename T>
ostream &operator<<(ostream &out, const vectori<T> &arr) {
	out << "[";
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			out << ", ";

		out << x;
		buv = true;
	}

	out << "]";
	return out;
}

template<typename T, typename P>
ostream &operator<<(ostream &out, const map<T, P> &arr) {
	out << "{";
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			out << ", ";

		out << x.first << " => " << x.second;
		buv = true;
	}

	out << "}";
	return out;
}

template<typename T, typename P>
ostream &operator<<(ostream &out, const set<T, P> &arr) {
	out << "{";
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			out << ", ";

		out << x;
		buv = true;
	}

	out << "}";
	return out;
}

template<typename T>
ostream &operator<<(ostream &out, const seti<T> &arr) {
	out << "{";
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			out << ", ";

		out << x;
		buv = true;
	}

	out << "}";
	return out;
}

#define debug(...) __debugg(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __debugg(const char *name, Arg1 &&arg1) {
	cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __debugg(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | ";

	if (*(comma + 1) == ' ')
		comma++;

	__debugg(comma + 1, args...);
}
#else
#define debug(...)
#endif

template<typename X, typename Y>
struct Pair {
	X x;
	Y y;
	template<typename X1, typename Y1>
	Pair(const X1 &x, const Y1 &y): x(x), y(y) {}
	Pair() {}
	template<typename X1>
	explicit Pair(const X1 &x): x(x), y(Y()) {}
	template<typename X1, typename Y1>
	Pair<X, Y> operator+(const Pair<X1, Y1> &o)const {
		return Pair<X1, Y1>(x + o.x, y + o.y);
	}
	template<typename X1, typename Y1>
	Pair<X, Y> operator-(const Pair<X1, Y1> &o)const {
		return Pair<X1, Y1>(x - o.x, y - o.y);
	}
	template<typename X1, typename Y1>
	Pair<X, Y> operator*(const Pair<X1, Y1> &o)const {
		return Pair<X1, Y1>(x * o.x, y * o.y);
	}
	template<typename X1, typename Y1>
	Pair<X, Y> operator/(const Pair<X1, Y1> &o)const {
		return Pair<X1, Y1>(x / o.x, y / o.y);
	}
	template<typename X1, typename Y1>
	void operator+=(const Pair<X1, Y1> &o) {
		x += o.x;
		y += o.y;
	}
	template<typename X1, typename Y1>
	void operator-=(const Pair<X1, Y1> &o) {
		x -= o.x;
		y -= o.y;
	}
	template<typename X1, typename Y1>
	void operator*=(const Pair<X1, Y1> &o) {
		x *= o.x;
		y *= o.y;
	}
	template<typename X1, typename Y1>
	void operator/=(const Pair<X1, Y1> &o) {
		x /= o.x;
		y /= o.y;
	}
	template<typename X1, typename Y1>
	bool operator<(const Pair<X1, Y1> &o)const {
		if (x == o.x)
			return y < o.y;

		return x < o.x;
	}
	template<typename X1, typename Y1>
	bool operator<=(const Pair<X1, Y1> &o)const {
		if (x == o.x)
			return y <= o.y;

		return x <= o.x;
	}
	template<typename X1, typename Y1>
	bool operator>(const Pair<X1, Y1> &o)const {
		if (x == o.x)
			return y > o.y;

		return x > o.x;
	}
	template<typename X1, typename Y1>
	bool operator>=(const Pair<X1, Y1> &o)const {
		if (x == o.x)
			return y >= o.y;

		return x >= o.x;
	}
	template<typename X1, typename Y1>
	bool operator==(const Pair<X1, Y1> &o)const {
		return x == o.x and y == o.y;
	}
	template<typename X1, typename Y1>
	bool operator!=(const Pair<X1, Y1> &o)const {
		return x != o.x or y != o.y;
	}
	template<typename X1, typename Y1>
	void swap(Pair<X1, Y1> &o) {
		swap(x, o.x);
		swap(y, o.y);
	}
};

template<typename X, typename Y>
Pair<X, Y> makep(const X &x, const Y &y) {
	return Pair<X, Y>(x, y);
}

template<typename X, typename Y>
ostream &operator<<(ostream &out, const Pair<X, Y> &p) {
	out << "(" << p.x << ", " << p.y << ")";
	return out;
}

template<typename X, typename Y>
istream &operator>>(istream &in, Pair<X, Y> &p) {
	in >> p.x >> p.y;
	return in;
}

#define make_pair(...) makep(__VA_ARGS__)
#define pair Pair

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef Pair<int, int> pii;
typedef Pair<ll, ll> pll;
typedef vector<pll> vpll;

template<typename T>
istream &operator>>(istream &in, vector<T> &arr) {
	for (auto && x : arr) {
		in >> x;
	}

	return in;
}

template<typename T>
void printi(const T &arr, char skyr = '\n') {
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			cout << skyr;

		cout << x;
		buv = true;
	}
}

template<typename T>
void printi(const T &arr, const string &skyr) {
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			cout << skyr;

		cout << x;
		buv = true;
	}
}

template<typename X, typename Y>
void printp(const Pair<X, Y> &p, char skyr = ' ') {
	cout << p.x << skyr << p.y;
}

template<typename X, typename Y>
void printp(const Pair<X, Y> &p, const string &skyr) {
	cout << p.x << skyr << p.y;
}

template<typename X, typename Y>
inline X mini(X &a, const Y &b) __attribute__((always_inline));
template<typename X, typename Y>
inline X mini(X &a, const Y &b) {
	if (a > b)
		a = b;

	return a;
}
template<typename X, typename Y>
inline X maxi(X &a, const Y &b) __attribute__((always_inline));
template<typename X, typename Y>
inline X maxi(X &a, const Y &b) {
	if (a < b)
		a = b;

	return a;
}

template<ll X, ll Y>
inline bool between(ll v)__attribute__((always_inline));
template<ll X, ll Y>
inline bool between(ll v) {
	return ull(v - X) <= ull(Y - X);
}

inline bool between(ll X, ll v, ll Y) __attribute__((always_inline));
inline bool between(ll X, ll v, ll Y) {
	return ull(v - X) <= ull(Y - X);
}
}
using namespace my;

/*input
3
8 4 1
2
2 3
1 2
*/
/*output
5
12
*/
/*input
6
1 2 4 8 16 32
4
1 6
2 5
3 4
1 2
*/
/*output
60
30
12
3
*/

int main () {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	vll a(n);
	cin >> a;
	vll b(n + 1, 0);

	for (int i = 0; i < n; i++) {
		b[i + 1] = b[i] ^ a[i];
	}

	auto f = [&](int fr, int to)-> ll {
		if ((to - fr + 1) % 2 == 0) {
			return b[to + 1] ^ b[fr];
		}
		else{
			return a[to] ^ a[fr];
		}
	};

	ll ats[n][n] = {};

	for (int i = 0; i < n; i++) {
		ats[i][i] = a[i];

		for (int j = i + 1; j < n; j++) {
			ats[i][j] = max(ats[i][j - 1], f(i, j));
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = i - 1; j >= 0; j--) {
			maxi(ats[i][j], ats[i][j + 1]);
		}
	}

	int q;
	cin >> q;

	for (int i = 0; i < q; i++) {
		int x, y;
		cin >> x >> y;
		cout << ats[x - 1][y - 1] << "\n";
	}
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

namespace my {

template<typename T>
struct seti : public tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update> {
	seti(): tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>() {}
	explicit seti(initializer_list<T> o): tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>() {
		for (const T &x : o)
			this->insert(x);
	}
	inline T operator[](int i) {
		return *this->find_by_order(i);
	}
};

template<typename T>
struct vectori : public vector<T> {
	explicit vectori(size_t n, T e = T()): vector<T>(n, e) {}
	template< class InputIt >
	vectori( InputIt first, InputIt last): vector<T>(first, last) {}
	explicit vectori(initializer_list<T> o): vector<T>(o) {}
	inline void operator+=(T o) {
		this->push_back(o);
	}
	inline void operator+=(initializer_list<T> o) {
		this->insert(this->end(), o.begin(), o.end());
	}
	inline void operator+=(vectori<T> o) {
		this->insert(this->end(), o.begin(), o.end());
	}
};

int VERY_RANDOM_NUMBER = (uint64_t)(std::make_unique<char>().get()) ^ (uint64_t)(std::chrono::high_resolution_clock::now().time_since_epoch().count());

struct chash {
	inline int operator()(int x) const {
		return x ^ VERY_RANDOM_NUMBER;
	}
};

template <class A, class B>
using hash_table = gp_hash_table<A, B, chash>;

#ifdef LOCAL
template<typename T>
ostream &operator<<(ostream &out, const vector<T> &arr) {
	out << "[";
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			out << ", ";

		out << x;
		buv = true;
	}

	out << "]";
	return out;
}
template<typename T>
ostream &operator<<(ostream &out, const vectori<T> &arr) {
	out << "[";
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			out << ", ";

		out << x;
		buv = true;
	}

	out << "]";
	return out;
}

template<typename T, typename P>
ostream &operator<<(ostream &out, const map<T, P> &arr) {
	out << "{";
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			out << ", ";

		out << x.first << " => " << x.second;
		buv = true;
	}

	out << "}";
	return out;
}

template<typename T, typename P>
ostream &operator<<(ostream &out, const set<T, P> &arr) {
	out << "{";
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			out << ", ";

		out << x;
		buv = true;
	}

	out << "}";
	return out;
}

template<typename T>
ostream &operator<<(ostream &out, const seti<T> &arr) {
	out << "{";
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			out << ", ";

		out << x;
		buv = true;
	}

	out << "}";
	return out;
}

#define debug(...) __debugg(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __debugg(const char *name, Arg1 &&arg1) {
	cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __debugg(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | ";

	if (*(comma + 1) == ' ')
		comma++;

	__debugg(comma + 1, args...);
}
#else
#define debug(...)
#endif

template<typename X, typename Y>
struct Pair {
	X x;
	Y y;
	template<typename X1, typename Y1>
	Pair(const X1 &x, const Y1 &y): x(x), y(y) {}
	Pair() {}
	template<typename X1>
	explicit Pair(const X1 &x): x(x), y(Y()) {}
	template<typename X1, typename Y1>
	Pair<X, Y> operator+(const Pair<X1, Y1> &o)const {
		return Pair<X1, Y1>(x + o.x, y + o.y);
	}
	template<typename X1, typename Y1>
	Pair<X, Y> operator-(const Pair<X1, Y1> &o)const {
		return Pair<X1, Y1>(x - o.x, y - o.y);
	}
	template<typename X1, typename Y1>
	Pair<X, Y> operator*(const Pair<X1, Y1> &o)const {
		return Pair<X1, Y1>(x * o.x, y * o.y);
	}
	template<typename X1, typename Y1>
	Pair<X, Y> operator/(const Pair<X1, Y1> &o)const {
		return Pair<X1, Y1>(x / o.x, y / o.y);
	}
	template<typename X1, typename Y1>
	void operator+=(const Pair<X1, Y1> &o) {
		x += o.x;
		y += o.y;
	}
	template<typename X1, typename Y1>
	void operator-=(const Pair<X1, Y1> &o) {
		x -= o.x;
		y -= o.y;
	}
	template<typename X1, typename Y1>
	void operator*=(const Pair<X1, Y1> &o) {
		x *= o.x;
		y *= o.y;
	}
	template<typename X1, typename Y1>
	void operator/=(const Pair<X1, Y1> &o) {
		x /= o.x;
		y /= o.y;
	}
	template<typename X1, typename Y1>
	bool operator<(const Pair<X1, Y1> &o)const {
		if (x == o.x)
			return y < o.y;

		return x < o.x;
	}
	template<typename X1, typename Y1>
	bool operator<=(const Pair<X1, Y1> &o)const {
		if (x == o.x)
			return y <= o.y;

		return x <= o.x;
	}
	template<typename X1, typename Y1>
	bool operator>(const Pair<X1, Y1> &o)const {
		if (x == o.x)
			return y > o.y;

		return x > o.x;
	}
	template<typename X1, typename Y1>
	bool operator>=(const Pair<X1, Y1> &o)const {
		if (x == o.x)
			return y >= o.y;

		return x >= o.x;
	}
	template<typename X1, typename Y1>
	bool operator==(const Pair<X1, Y1> &o)const {
		return x == o.x and y == o.y;
	}
	template<typename X1, typename Y1>
	bool operator!=(const Pair<X1, Y1> &o)const {
		return x != o.x or y != o.y;
	}
	template<typename X1, typename Y1>
	void swap(Pair<X1, Y1> &o) {
		swap(x, o.x);
		swap(y, o.y);
	}
};

template<typename X, typename Y>
Pair<X, Y> makep(const X &x, const Y &y) {
	return Pair<X, Y>(x, y);
}

template<typename X, typename Y>
ostream &operator<<(ostream &out, const Pair<X, Y> &p) {
	out << "(" << p.x << ", " << p.y << ")";
	return out;
}

template<typename X, typename Y>
istream &operator>>(istream &in, Pair<X, Y> &p) {
	in >> p.x >> p.y;
	return in;
}

#define make_pair(...) makep(__VA_ARGS__)
#define pair Pair

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef Pair<int, int> pii;
typedef Pair<ll, ll> pll;
typedef vector<pll> vpll;

template<typename T>
istream &operator>>(istream &in, vector<T> &arr) {
	for (auto && x : arr) {
		in >> x;
	}

	return in;
}

template<typename T>
void printi(const T &arr, char skyr = '\n') {
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			cout << skyr;

		cout << x;
		buv = true;
	}
}

template<typename T>
void printi(const T &arr, const string &skyr) {
	bool buv = false;

	for (auto && x : arr) {
		if (buv)
			cout << skyr;

		cout << x;
		buv = true;
	}
}

template<typename X, typename Y>
void printp(const Pair<X, Y> &p, char skyr = ' ') {
	cout << p.x << skyr << p.y;
}

template<typename X, typename Y>
void printp(const Pair<X, Y> &p, const string &skyr) {
	cout << p.x << skyr << p.y;
}

template<typename X, typename Y>
inline X mini(X &a, const Y &b) __attribute__((always_inline));
template<typename X, typename Y>
inline X mini(X &a, const Y &b) {
	if (a > b)
		a = b;

	return a;
}
template<typename X, typename Y>
inline X maxi(X &a, const Y &b) __attribute__((always_inline));
template<typename X, typename Y>
inline X maxi(X &a, const Y &b) {
	if (a < b)
		a = b;

	return a;
}

template<ll X, ll Y>
inline bool between(ll v)__attribute__((always_inline));
template<ll X, ll Y>
inline bool between(ll v) {
	return ull(v - X) <= ull(Y - X);
}

inline bool between(ll X, ll v, ll Y) __attribute__((always_inline));
inline bool between(ll X, ll v, ll Y) {
	return ull(v - X) <= ull(Y - X);
}
}
using namespace my;

/*input
3
8 4 1
2
2 3
1 2
*/
/*output
5
12
*/
/*input
6
1 2 4 8 16 32
4
1 6
2 5
3 4
1 2
*/
/*output
60
30
12
3
*/

int main () {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	vll a(n);
	cin >> a;

	ll ats[n][n];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j + i < n; j++) {
			if (i == 0) {
				ats[j][j] = a[j];
			}
			else {
				ats[j][j + i] = ats[j][j + i - 1] ^ ats[j + 1][j + i];
			}
		}
	}

	for (int i = 0; i < n; i++) {
		ats[i][i] = a[i];

		for (int j = i + 1; j < n; j++) {
			maxi(ats[i][j], ats[i][j - 1]);
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = i - 1; j >= 0; j--) {
			maxi(ats[j][i], ats[j + 1][i]);
		}
	}

	int q;
	cin >> q;

	for (int i = 0; i < q; i++) {
		int x, y;
		cin >> x >> y;
		cout << ats[x - 1][y - 1] << "\n";
	}
}


#pragma GCC optimize("Ofast,fast-math,unroll-loops")

#include <bits/stdc++.h>

#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
//#define PI 3.141592653589

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;

/*
const ll MAX_MEM = 7e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/

template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}

template <class T>
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}

template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}

template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}

inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
}

signed main()
{
    Start();
    int n;
    cin >> n;
    vector <int> b(n);
    cin >> b;
    vector <int> a(n);
    for (int i = 0; i < n; ++i)
        a[i] = b[i] ^ (i ? a[i - 1] : 0);
    vector <vector <int>> dp(n, vector <int> (n, 0));
    for (int le = 0; le < n; ++le)
    {
        for (int l = 0; l + le < n; ++l)
        {
            int r = l + le;
            int len = (r - l + 1) & -(r - l + 1);
            if (r > l)
                dp[l][r] = max(dp[l][r - 1], dp[l + 1][r]);
            dp[l][r] = max(dp[l][r], a[l + len - 1] ^ (l ? a[l - 1] : 0) ^ a[r] ^ a[max(r - len + 1, l + len - 1)]);
        }
    }
    int q;
    cin >> q;
    while (q--)
    {
        int l, r;
        cin >> l >> r;
        cout << dp[l - 1][r - 1] << endl;
    }
    return 0;
}


#pragma GCC optimize("Ofast,fast-math,unroll-loops")

#include <bits/stdc++.h>

#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
//#define PI 3.141592653589

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;

/*
const ll MAX_MEM = 7e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/

template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}

template <class T>
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}

template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}

template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}

inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
}

signed main()
{
    Start();
    int n;
    cin >> n;
    vector <int> b(n);
    cin >> b;
    vector <vector <int>> dp(n, vector <int> (n));
    dp[n - 1] = b;
    for (int i = n - 2; i >= 0; --i)
        for (int j = 0; j <= i; ++j)
            dp[i][j] = dp[i + 1][j] ^ dp[i + 1][j + 1];
    vector <vector <int>> fun(n, vector <int> (n));
    for (int le = 0; le < n; ++le)
    {
        for (int l = 0; l + le < n; ++l)
        {
            int r = l + le;
            if (r > l)
                fun[l][r] = max(fun[l][r - 1], fun[l + 1][r]);
            fun[l][r] = max(fun[l][r], dp[n - (r - l + 1)][l]);
        }
    }
    int q;
    cin >> q;
    while (q--)
    {
        int l, r;
        cin >> l >> r, --l, --r;
        cout << fun[l][r] << endl;
    }
    return 0;
}


#pragma GCC optimize("Ofast,fast-math,unroll-loops")

#include <bits/stdc++.h>

#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
//#define PI 3.141592653589

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;

/*
const ll MAX_MEM = 7e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/

template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}

template <class T>
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}

template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}

template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}

inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
}

signed main()
{
    Start();
    int n;
    cin >> n;
    vector <int> b(n);
    cin >> b;
    vector <vector <int>> dp(n, vector <int> (n, 0));
    for (int l = 0; l < n; ++l)
    {
        for (int r = l; r < n; ++r)
        {
            if (r > l)
                dp[l][r] = dp[l][r - 1];
            dp[l][r] = max(dp[l][r], b[l] ^ b[r]);
        }
    }
    int q;
    cin >> q;
    while (q--)
    {
        int l, r;
        cin >> l >> r;
        cout << dp[l - 1][r - 1] << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(z) for(int i=1;i<=z;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<int>
#define pb push_back
#define si set<int>
#define mod  1000000007
#define cl(n,m) (n-1)/m  + 1 ;
#define T() int TT; cin>>TT; while(TT--)
#define P pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const int  N = 10e5 + 5;
int dp[5001][5001]  , ans[5001][5001] ,a[5001];
int fuc(int l , int r) {
	if( l>r) return 0;
	if( l==r ) return a[l] ;
	if( dp[l][r] !=-1 ) return dp[l][r] ;
	dp[l][r] = fuc( l , r-1) ^ fuc( l+1 , r) ;
	ans[l][r] =  max( dp[l][r] , max( ans[l][r-1] , ans[l+1][r]) );
	return dp[l][r] ;
}
signed main(){
	int n ,q;
	cin >> n;
	f(n) cin >> a[i] ;
	cin >> q ;
	memset( dp, -1 , sizeof(dp)) ;
	for( int i = 1 ;i<=n ;i++){
		for( int j =1 ;j<=n ;j++){
			fuc(i , j) ;
		}
	}
	int l ,r ;
	while( q--){
		cin >> l>> r ;
		cout << ans[l][r] << endl ;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(z) for(int i=1;i<=z;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<int>
#define pb push_back
#define si set<int>
#define mod  1000000007
#define cl(n,m) (n-1)/m  + 1 ;
#define T() int TT; cin>>TT; while(TT--)
#define P pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const int  N = 10e5 + 5;
int dp[5001][5001]  , ans[5001][5001] ,a[5001];

signed main(){
	int n ,q;
	cin >> n;
	f(n) cin >> dp[1][i] , ans[1][i] = dp[1][i];
	cin >> q ;

	for( int i = 2 ;i<=n ;i++){
		for(int j = 1 ;j+i-1 <=n ; j++){
			dp[i][j] =  dp[i-1][j] ^ dp[i-1][j+1]  ;
			ans[i][j] = max( dp[i][j] , max( ans[i-1][j] , ans[i-1][j+1])) ;
		}
	}
	int l ,r ;
	while( q--){
		cin >> l>> r ;
		cout << ans[r-l+1][l] << endl ;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(z) for(int i=1;i<=z;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<int>
#define pb push_back
#define si set<int>
#define mod  1000000007
#define cl(n,m) (n-1)/m  + 1 ;
#define T() int TT; cin>>TT; while(TT--)
#define P pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const int  N = 10e5 + 5;
int dp[5001][5001]  , ans[5001][5001] ,a[5001];
int fuc(int l , int r) {
	if( l>r) return 0;
	if( l==r ) return a[l] ;
	if( dp[l][r] !=-1 ) return dp[l][r] ;
	dp[l][r] = fuc( l , r-1) ^ fuc( l+1 , r) ;
	ans[l][r] =  max( dp[l][r] , max( ans[l][r-1] , ans[l+1][r]) );
	return dp[l][r] ;
}
signed main(){
	int n ,q;
	cin >> n;
	f(n) cin >> a[i] ;
	cin >> q ;
	memset( dp, -1 , sizeof(dp)) ;
	for( int i = 1 ;i<=n ;i++){
		for( int j =i ;j<=n ;j++){
			fuc(i , j) ;
		}
	}
	int l ,r ;
	while( q--){
		cin >> l>> r ;
		cout << ans[l][r] << endl ;
	}
}


#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll >
#define mll map<ll, ll>
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define pi pair<int, int>
#define ppi pair<pair<int, int>, int>
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
#define INF (ll)1e18
#define s(v) v.size()
#define e(v) v.empty()

using namespace std;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);}
// bool sortbysec(const pll &a, const pll &b){return (a.second < b.second);}
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("../input.txt", "r", stdin);
        freopen("../output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        ll n;
        cin>>n;
        vl arr(n);
        rep(i, n)   cin>>arr[i];
        vl keys(n+1);
        ll k = 0;
        ll mat[n+1][n+1], func[n+1][n+1];
        rep(i, n+1) rep(j, n+1) mat[i][j] = 0, func[i][j] = 0;
        keys[0] = 0;
        rep1(i, n+1){
            for(ll j = 0 ; j <= n-i ; j++){
                if(i == 1)  func[j+1][j+1] = arr[j];
                else{
                    func[j+1][j+i] = func[j+2][j+i] ^ func[j+1][j+i-1];
                }
            }
        }
        rep(i, n){
            for(ll j = i ; j < n ; j++){
                func[i+1][j+1] = max(func[i+1][j+1], func[i+1][j]);
            }
            keys[i+1] = ((i+1)*(i+2))/2;
        }
        for(ll j = 1 ; j <= n ; j++){
            for(ll i = j-1 ; i >= 1 ; i--){
                if(i < 1)   break;
                func[i][j] = max(func[i][j], func[i+1][j]);
            }
        }
        ll q, x, y;
        cin>>q;
        rep(i, q){
            cin>>x>>y;
            cout<<func[x][y]<<endl;
        }
    }
}


#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll >
#define mll map<ll, ll>
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define pi pair<int, int>
#define ppi pair<pair<int, int>, int>
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
#define INF (ll)1e18
#define s(v) v.size()
#define e(v) v.empty()

using namespace std;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);}
// bool sortbysec(const pll &a, const pll &b){return (a.second < b.second);}
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}

vl vec;

struct node{
    ll mn, mx;
    ll add = 0;
};

typedef struct node node;

void build_tree(node tree[], ll cur, ll l, ll r){
    if(l == r){
        tree[cur].mn = vec[l];
        tree[cur].mx = vec[l];
        return;
    }
    ll mid = l + (r-l)/2;
    build_tree(tree, 2*cur+1, l, mid);
    build_tree(tree, 2*cur+2, mid+1, r);
    tree[cur].mn = min(tree[2*cur+1].mn, tree[2*cur+2].mn);
    tree[cur].mx = max(tree[2*cur+1].mx, tree[2*cur+2].mx);
}

void upd(node tree[], ll cur, ll l, ll r, ll x, ll y, ll k){
    if(r < x || y < l)  return ;
    if(x <= l && r <= y){
        tree[cur].add += k;
        tree[cur].mn += k;
        tree[cur].mx += k;
        return;
    }
    ll mid = l+(r-l)/2;
    upd(tree, 2*cur+1, l, mid, x, y, k);
    upd(tree, 2*cur+2, mid+1, r, x, y, k);
    tree[cur].mn = min(tree[2*cur+1].mn, tree[2*cur+2].mn) + tree[cur].add;
    tree[cur].mx = max(tree[2*cur+1].mx, tree[2*cur+2].mx) + tree[cur].add;
}

pll query(node tree[], ll cur, ll l, ll r, ll x, ll y, ll carry){
    if(r < x || y < l)  return mp(INF, -INF);
    if(x <= l && r <= y){
        return mp(tree[cur].mn + carry, tree[cur].mx + carry);
    }
    ll mid = l + (r-l)/2;
    pll a = query(tree, 2*cur+1, l, mid, x, y, carry+tree[cur].add);
    pll b = query(tree, 2*cur+2, mid+1, r, x, y, carry+tree[cur].add);
    return mp(min(a.first,b.first), max(a.sec, b.sec));
}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("../input.txt", "r", stdin);
        freopen("../output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        ll n;
        cin>>n;
        vl arr(n);
        rep(i, n)   cin>>arr[i];
        vl keys(n+1);
        ll k = 0;
        ll mat[n+1][n+1], func[n+1][n+1];
        rep(i, n+1) rep(j, n+1) mat[i][j] = 0, func[i][j] = 0;
        keys[0] = 0;
        // ll func[n+1][n+1];
        rep1(i, n+1){
            for(ll j = 0 ; j <= n-i ; j++){
                if(i == 1)  func[j+1][j+1] = arr[j];
                else{
                    func[j+1][j+i] = func[j+2][j+i] ^ func[j+1][j+i-1];
                }
            }
        }
        // rep(i, n+1){
        //     rep(j, n+1){
        //         cout<<func[i][j]<<" ";
        //     }
        //     cout<<endl;
        // }
        rep(i, n){
            for(ll j = i ; j < n ; j++){
                func[i+1][j+1] = max(func[i+1][j+1], func[i+1][j]);
                // vec.pb(func[i+1][j+1]);
            }
            // keys[i+1] = s(vec) - 1;
            keys[i+1] = ((i+1)*(i+2))/2;
        }
        // cout<<endl;
        // rep(i, n+1){
        //     rep(j, n+1) cout<<func[i][j]<<" ";
        //     cout<<endl;
        // }
        rep(j, n+1){
            rep1(i, j+1)  vec.pb(func[i][j]);
        }
        ll q, x, y;
        cin>>q;
        ll m = s(vec);
        // rep(i, m)   cout<<vec[i]<<" ";
        // rep(i, n)   cout<<keys[i]<<" ";
        // cout<<endl;
        node tree[4*m];
        build_tree(tree, 0, 0, m-1);
        // rep(i, s(vec))  cout<<vec[i]<<" ";
        // cout<<endl;
        rep(i, q){
            cin>>x>>y;
            ll u, v;
            if(y == 1)  u = 0;
            else u = keys[y-1] + x-1;
            v = keys[y]-1;
            // cout<<u<<" "<<v<<endl;
            pll ans = query(tree, 0, 0, m-1, u, v, 0);
            cout<<ans.sec<<endl;
        }
    }
}


#include <bits/stdc++.h>
#define ll int
#define ld long double
#define pb push_back
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll >
#define mll map<ll, ll>
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define pi pair<int, int>
#define ppi pair<pair<int, int>, int>
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
#define INF (ll)1e18
#define s(v) v.size()
#define e(v) v.empty()

using namespace std;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);}
// bool sortbysec(const pll &a, const pll &b){return (a.second < b.second);}
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}

int func[5004][5004];

int main(){
    #ifndef ONLINE_JUDGE
        freopen("../input.txt", "r", stdin);
        freopen("../output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        ll n;
        cin>>n;
        vl arr(n);
        rep(i, n)   cin>>arr[i];
        vl keys(n+1);
        ll k = 0;
        rep(i, n+1) rep(j, n+1) func[i][j] = 0;
        rep1(i, n+1){
            for(ll j = 0 ; j <= n-i ; j++){
                if(i == 1)  func[j+1][j+1] = arr[j];
                else{
                    func[j+1][j+i] = func[j+2][j+i] ^ func[j+1][j+i-1];
                }
            }
        }
        rep(i, n){
            for(ll j = i ; j < n ; j++){
                func[i+1][j+1] = max(func[i+1][j+1], func[i+1][j]);
            }
        }
        for(ll j = 1 ; j <= n ; j++){
            for(ll i = j-1 ; i >= 1 ; i--){
                if(i < 1)   break;
                func[i][j] = max(func[i][j], func[i+1][j]);
            }
        }
        ll q, x, y;
        cin>>q;
        rep(i, q){
            cin>>x>>y;
            cout<<func[x][y]<<endl;
        }
    }
}


/*
___ is a raging sadist.
*/

//Destroy all WA at test 2

#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define PI 3.14159265
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MOD1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
using namespace std;

ll power(ll x, ll y)
{
   ll res = 1;

    while (y > 0)
    {

        if (y & 1)
            res = (long long)(res*x);

        y = y>>1;

        if (x<=100000000)
        x = (long long)(x*x);

        //cout<<x<<'\n';
    }
    return res;
}

ll val[5001][5001];

int main()
{

#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif

fastio();

ll n;
cin>>n;

ll a[n+1];

For(i,1,n+1){
cin>>a[i];

val[i][i]=a[i];
}

for(int i=2;i<=n;i++){
for(int j=1;j<=n-i+1;j++){
val[j][j+i-1]=val[j][j+i-2]^val[j+1][j+i-1];
}
}

/*for(int i=1;i<=n;i++){
for(int j=i;j<=n;j++){
cout<<val[i][j]<<endl;
}
}*/

for(int i=2;i<=n;i++){
for(int j=1;j<=n-i+1;j++){
val[j][j+i-1]=max(val[j][j+i-1],max(val[j][j+i-2],val[j+1][j+i-1]));
}
}

/*cout<<endl;

for(int i=1;i<=n;i++){
for(int j=i;j<=n;j++){
cout<<val[i][j]<<endl;
}
}*/

ll q;
cin>>q;
while(q--){
ll x,y;
cin>>x>>y;

cout<<val[x][y]<<endl;

}

return 0;
}


/*
___ is a raging sadist.
*/

//Destroy all WA at test 2

#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define PI 3.14159265
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MOD1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
using namespace std;

ll power(ll x, ll y)
{
   ll res = 1;

    while (y > 0)
    {

        if (y & 1)
            res = (long long)(res*x);

        y = y>>1;

        if (x<=100000000)
        x = (long long)(x*x);

        //cout<<x<<'\n';
    }
    return res;
}

ll val[5001][5001];

int main()
{

#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif

fastio();

ll n;
cin>>n;

ll a[n+1];

For(i,1,n+1)
cin>>a[i];

for(int i=1;i<=n;i++){
val[i][i]=a[i];
if (i+1<=n)
val[i][i+1]=a[i]^a[i+1];
for(int j=i+2;j<=n;j++){
val[i][j]=a[i]^a[j-1]^a[j]^a[i+1];
}
}

/*for(int i=1;i<=n;i++){
for(int j=i;j<=n;j++){
cout<<val[i][j]<<endl;
}
}*/

for(int i=2;i<=n;i++){
for(int j=1;j<=n-i+1;j++){
val[j][j+i-1]=max(val[j][j+i-1],max(val[j][j+i-2],val[j+1][j+i-1]));
}
}

/*cout<<endl;

for(int i=1;i<=n;i++){
for(int j=i;j<=n;j++){
cout<<val[i][j]<<endl;
}
}*/

ll q;
cin>>q;
while(q--){
ll x,y;
cin>>x>>y;

cout<<val[x][y]<<endl;

}

return 0;
}


/*
___ is a raging sadist.
*/

//Destroy all WA at test 2

#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define PI 3.14159265
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MOD1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
using namespace std;

ll power(ll x, ll y)
{
   ll res = 1;

    while (y > 0)
    {

        if (y & 1)
            res = (long long)(res*x);

        y = y>>1;

        if (x<=100000000)
        x = (long long)(x*x);

        //cout<<x<<'\n';
    }
    return res;
}

ll val[5001][5001];

int main()
{

#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif

fastio();

ll n;
cin>>n;

ll a[n+1];

For(i,1,n+1)
cin>>a[i];

for(int i=1;i<=n;i++){
val[i][i]=a[i];
if (i+1<=n)
val[i][i+1]=a[i]^a[i+1];
for(int j=i+2;j<=n;j++){
val[i][j]=a[i]^a[j-1]^a[j]^a[i+1];
}
}

for(int i=1;i<=n-1;i++){
val[i][i+1]=max(val[i][i+1],max(val[i][i],val[i+1][i+1]));
}

for(int i=3;i<=n;i++){
for(int j=1;j<=n-i+1;j++){
val[j][j+i-1]=max(val[j][j+i-1],max(val[j][j+i-2],val[j+1][j+i-1]));
}
}

ll q;
cin>>q;
while(q--){
ll x,y;
cin>>x>>y;

cout<<val[x][y]<<endl;

}

return 0;
}


#include <bits/stdc++.h>
#define F first
#define S second
#define int long long
#define pii pair<int, int>
using namespace std;
const int MX = 5e3 + 100;
int v[MX];
vector<pii> T[MX * 4];
void insert(int n, int l, int r, int p, pii v) {
	if(T[n].back().F == v.F and T[n].back().S < v.S) T[n].pop_back();
	if(T[n].back().S < v.S) T[n].push_back(v);
	if(l == r) return;
	int m = l + r >> 1;
	if(p <= m) insert(n * 2 + 1, l, m, p, v);
	else       insert(n * 2 + 2, m + 1, r, p, v);
}
int query(int n, int l, int r, int s, int d, int p) {
	if(l == s and r == d) {
		auto it = --upper_bound(T[n].begin(), T[n].end(), make_pair(p, 1ll << 60));
		return it -> S;
	}
	int m = l + r >> 1;
	if(d <= m) return query(n * 2 + 1, l, m, s, d, p);
	if(s >  m) return query(n * 2 + 2, m + 1, r, s, d, p);
	return max(
		query(n * 2 + 1, l, m, s, m, p),
		query(n * 2 + 2, m + 1, r, m + 1, d, p)
	);
}
main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	#define endl '\n'
	for(int i = 0; i < MX * 4; i ++) T[i].push_back({0, 0});
	int n; cin >> n;
	for(int i = 1; i <= n; i ++) cin >> v[i];
	int sum = 0;
	for(int i = 1; i <= n; i ++) {
		int s = 0;
		for(int j = i; j >= 1; j --) {
			s ^= v[j];
			insert(0, 0, MX - 1, j, {i, s});
		}
	}
	int q; cin >> q;
	while(q--) {
		int l, r; cin >> l >> r;
		cout << query(0, 0, MX - 1, l, r, r) << endl;
	}
}


#include <bits/stdc++.h>
#define F first
#define S second
#define int long long
#define pii pair<int, int>
using namespace std;
const int MX = 5e3 + 100;
int v[MX];
vector<pii> T[MX * 4];
void insert(int n, int l, int r, int p, pii v) {
	if(T[n].back().F == v.F and T[n].back().S < v.S) T[n].pop_back();
	if(T[n].back().S < v.S) T[n].push_back(v);
	if(l == r) return;
	int m = l + r >> 1;
	if(p <= m) insert(n * 2 + 1, l, m, p, v);
	else       insert(n * 2 + 2, m + 1, r, p, v);
}
int query(int n, int l, int r, int s, int d, int p) {
	if(l == s and r == d) {
		auto it = --upper_bound(T[n].begin(), T[n].end(), make_pair(p, 1ll << 60));
		return it -> S;
	}
	int m = l + r >> 1;
	if(d <= m) return query(n * 2 + 1, l, m, s, d, p);
	if(s >  m) return query(n * 2 + 2, m + 1, r, s, d, p);
	return max(
		query(n * 2 + 1, l, m, s, m, p),
		query(n * 2 + 2, m + 1, r, m + 1, d, p)
	);
}
int cnt[MX][MX];
main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	#define endl '\n'
	for(int i = 0; i < MX * 4; i ++) T[i].push_back({0, 0});
	int n; cin >> n;
	for(int i = 1; i <= n; i ++) cin >> v[i];
	for(int i = 1; i <= n; i ++) cnt[i][i] = v[i];
	for(int i = 1; i <= n; i ++) {
		for(int j = 1; j + i <= n; j ++) {
			cnt[j][j + i] = cnt[j][j + i - 1] ^ cnt[j + 1][j + i];
		}
	}
	for(int i = 1; i <= n; i ++) {
		for(int j = i; j >= 1; j --) {
			insert(0, 0, MX - 1, j, {i, cnt[j][i]});
		}
	}
	int q; cin >> q;
	while(q--) {
		int l, r; cin >> l >> r;
		cout << query(0, 0, MX - 1, l, r, r) << endl;
	}
}


#include <bits/stdc++.h>
const int MX = 5000 + 1;
using namespace std;
int cnt[MX][MX], ans[MX][MX], mx[MX][MX], v[MX];
main () {
	int n; cin >> n;
	for(int i = 1; i <= n; i ++) scanf("%d%d", &cnt[i][i]);
	for(int i = 1; i <= n; i ++)
		for(int j = 1; j + i <= n; j ++)
			cnt[j][j + i] = cnt[j][j + i - 1] ^ cnt[j + 1][j + i];
	for(int i = 1; i <= n; i ++)
		for(int j = i; j <= n; j ++)
			mx[i][j] = max(mx[i][j - 1], cnt[i][j]);
	for(int r = 1; r <= n; r ++)
		for(int l = r; l >= 1; l --)
			ans[l][r] = max(ans[l + 1][r], mx[l][r]);
	int q; cin >> q;
	while(q--) {
		int l, r; scanf("%d%d", &l, &r);
		printf("%d\n", ans[l][r]);
	}
}


#include <bits/stdc++.h>
const int MX = 5000 + 1;
using namespace std;
int cnt[MX][MX], ans[MX][MX], mx[MX][MX], v[MX];
main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	#define endl '\n'
	int n; cin >> n;
	for(int i = 1; i <= n; i ++) cin >> v[i];
	for(int i = 1; i <= n; i ++) cnt[i][i] = v[i];
	for(int i = 1; i <= n; i ++) {
		for(int j = 1; j + i <= n; j ++) {
			cnt[j][j + i] = cnt[j][j + i - 1] ^ cnt[j + 1][j + i];
		}
	}
	for(int i = 1; i <= n; i ++) {
		for(int j = i; j <= n; j ++) {
			mx[i][j] = max(mx[i][j - 1], cnt[i][j]);
		}
	}
	for(int r = 1; r <= n; r ++) {
		for(int l = r; l >= 1; l --) {
			ans[l][r] = max(ans[l + 1][r], mx[l][r]);
		}
	}
	int q; cin >> q;
	while(q--) {
		int l, r; cin >> l >> r;
		cout << ans[l][r] << endl;
	}
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author majk
 */

#ifndef MAJK_LIB
#define MAJK_LIB

#include <vector>
#include <stack>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
#include <queue>
#include <bitset>
using namespace std;

#define x first
#define y second
typedef std::pair<int,int> pii; typedef long long ll; typedef unsigned long long ull; typedef unsigned int ui; typedef pair<ui,ui> puu;

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template <typename T> bool in(T a, T b, T c) { return a <= b && b < c; }
ui logceil(int x) { return 8*sizeof(int)-__builtin_clz(x); }

namespace std { template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}}; }
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename F> double bshd(double l,double h,const F&f,double p=1e-9){ui r=3+(ui)log2((h-l)/p);while(r--){double m=(l+h)/2;if(f(m)){l=m;}else{h=m;}}return (l+h)/2;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename F> double bsld(double l,double h,const F&f,double p=1e-9){ui r=3+(ui)log2((h-l)/p);while(r--){double m=(l+h)/2;if(f(m)){h=m;}else{l=m;}}return (l+h)/2;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

template<typename T>class vector2:public vector<vector<T>>{public:vector2(){} vector2(size_t a,size_t b,T t=T()):vector<vector<T>>(a,vector<T>(b,t)){}};
template<typename T>class vector3:public vector<vector2<T>>{public:vector3(){} vector3(size_t a,size_t b,size_t c,T t=T()):vector<vector2<T>>(a,vector2<T>(b,c,t)){}};
template<typename T>class vector4:public vector<vector3<T>>{public:vector4(){} vector4(size_t a,size_t b,size_t c,size_t d,T t=T()):vector<vector3<T>>(a,vector3<T>(b,c,d,t)){}};
template<typename T>class vector5:public vector<vector4<T>>{public:vector5(){} vector5(size_t a,size_t b,size_t c,size_t d,size_t e,T t=T()):vector<vector4<T>>(a,vector4<T>(b,c,d,e,t)){}};

#endif
// #include "../l/mod.h"

class TaskB {
public:
    void solve(istream& cin, ostream& cout) {
        int N; cin >> N;
        vector<int> A(N); cin >> A;
        vector2<int> X(N+1,N,0);
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j+i < N; ++j) {
                X[j+1][i] = X[j][i] ^ A[j+i];
            }
        }

        vector2<int> B(N,N+1,0);

        for (int i = 0; i < N; ++i) {
            B[i][i+1] = A[i];
        }

        for (int k = 1; k <= N; k*=2) {
            for (int i = 0; i < N; ++i) {
                for (int j = i+k; j+k <= N && j < i+3*k ; ++j) {
                    B[i][j+k] = max(B[i][j+k], X[k][i] ^ X[k][j]);
                }
            }
        }

        for (int i = N-1; i >= 0; --i) {
            for (int j = i+1; j <= N; ++j) {
                if (i != 0) {
                    B[i-1][j] = max(B[i-1][j], B[i][j]);
                }
                if (j != N) {
                    B[i][j+1] = max(B[i][j+1], B[i][j]);
                }
            }
        }

        int Q; cin >> Q;
        for (int q = 0; q < Q; ++q) {
            int l,r; cin >> l >> r;
            cout << B[l-1][r] << '\n';
        }
    }
};

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	TaskB solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
    return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author majk
 */

#ifndef MAJK_LIB
#define MAJK_LIB

#include <vector>
#include <stack>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
#include <queue>
#include <bitset>
using namespace std;

#define x first
#define y second
typedef std::pair<int,int> pii; typedef long long ll; typedef unsigned long long ull; typedef unsigned int ui; typedef pair<ui,ui> puu;

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template <typename T> bool in(T a, T b, T c) { return a <= b && b < c; }
ui logceil(int x) { return 8*sizeof(int)-__builtin_clz(x); }

namespace std { template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}}; }
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename F> double bshd(double l,double h,const F&f,double p=1e-9){ui r=3+(ui)log2((h-l)/p);while(r--){double m=(l+h)/2;if(f(m)){l=m;}else{h=m;}}return (l+h)/2;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename F> double bsld(double l,double h,const F&f,double p=1e-9){ui r=3+(ui)log2((h-l)/p);while(r--){double m=(l+h)/2;if(f(m)){h=m;}else{l=m;}}return (l+h)/2;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

template<typename T>class vector2:public vector<vector<T>>{public:vector2(){} vector2(size_t a,size_t b,T t=T()):vector<vector<T>>(a,vector<T>(b,t)){}};
template<typename T>class vector3:public vector<vector2<T>>{public:vector3(){} vector3(size_t a,size_t b,size_t c,T t=T()):vector<vector2<T>>(a,vector2<T>(b,c,t)){}};
template<typename T>class vector4:public vector<vector3<T>>{public:vector4(){} vector4(size_t a,size_t b,size_t c,size_t d,T t=T()):vector<vector3<T>>(a,vector3<T>(b,c,d,t)){}};
template<typename T>class vector5:public vector<vector4<T>>{public:vector5(){} vector5(size_t a,size_t b,size_t c,size_t d,size_t e,T t=T()):vector<vector4<T>>(a,vector4<T>(b,c,d,e,t)){}};

#endif
// #include "../l/mod.h"

class TaskB {
public:
    void solve(istream& cin, ostream& cout) {
        int N; cin >> N;
        vector<int> A(N); cin >> A;
        vector2<int> X(N+1,N,0);
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j+i < N; ++j) {
                X[j+1][i] = X[j][i] ^ A[j+i];
            }
        }

        vector2<int> B(N,N+1,0);
        for (int k = 1; k <= N; k*=2) {
            for (int i = 0; i < N; ++i) {
                for (int j = i+k; j+k <= N && j < i+3*k ; ++j) {
                    B[i][j+k] = max(B[i][j+k], X[k][i] ^ X[k][j]);
                }
            }
        }

        for (int i = N-1; i >= 0; --i) {
            for (int j = i+1; j <= N; ++j) {
                if (i != 0) {
                    B[i-1][j] = max(B[i-1][j], B[i][j]);
                }
                if (j != N) {
                    B[i][j+1] = max(B[i][j+1], B[i][j]);
                }
            }
        }

        int Q; cin >> Q;
        for (int q = 0; q < Q; ++q) {
            int l,r; cin >> l >> r;
            cout << B[l-1][r] << '\n';
        }
    }
};

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	TaskB solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
    return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author majk
 */

#ifndef MAJK_LIB
#define MAJK_LIB

#include <vector>
#include <stack>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
#include <queue>
#include <bitset>
using namespace std;

#define x first
#define y second
typedef std::pair<int,int> pii; typedef long long ll; typedef unsigned long long ull; typedef unsigned int ui; typedef pair<ui,ui> puu;

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template <typename T> bool in(T a, T b, T c) { return a <= b && b < c; }
ui logceil(int x) { return 8*sizeof(int)-__builtin_clz(x); }

namespace std { template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}}; }
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename F> double bshd(double l,double h,const F&f,double p=1e-9){ui r=3+(ui)log2((h-l)/p);while(r--){double m=(l+h)/2;if(f(m)){l=m;}else{h=m;}}return (l+h)/2;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename F> double bsld(double l,double h,const F&f,double p=1e-9){ui r=3+(ui)log2((h-l)/p);while(r--){double m=(l+h)/2;if(f(m)){h=m;}else{l=m;}}return (l+h)/2;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

template<typename T>class vector2:public vector<vector<T>>{public:vector2(){} vector2(size_t a,size_t b,T t=T()):vector<vector<T>>(a,vector<T>(b,t)){}};
template<typename T>class vector3:public vector<vector2<T>>{public:vector3(){} vector3(size_t a,size_t b,size_t c,T t=T()):vector<vector2<T>>(a,vector2<T>(b,c,t)){}};
template<typename T>class vector4:public vector<vector3<T>>{public:vector4(){} vector4(size_t a,size_t b,size_t c,size_t d,T t=T()):vector<vector3<T>>(a,vector3<T>(b,c,d,t)){}};
template<typename T>class vector5:public vector<vector4<T>>{public:vector5(){} vector5(size_t a,size_t b,size_t c,size_t d,size_t e,T t=T()):vector<vector4<T>>(a,vector4<T>(b,c,d,e,t)){}};

#endif
// #include "../l/mod.h"

class TaskB {
public:
    void solve(istream& cin, ostream& cout) {
        int N; cin >> N;
        vector<int> A(N); cin >> A;
        vector2<int> B(N,N+1,0);
        for (int i = 0; i < N; ++i) {
            B[i][i+1] = A[i];
        }

        for (int i = N-1; i >= 0; --i) {
            for (int j = i+2; j <= N; ++j) {
                B[i][j] = B[i][j-1] ^ B[i+1][j];
            }
        }

        for (int i = N-1; i >= 0; --i) {
            for (int j = i+1; j <= N; ++j) {
                if (i != 0) {
                    B[i-1][j] = max(B[i-1][j], B[i][j]);
                }
                if (j != N) {
                    B[i][j+1] = max(B[i][j+1], B[i][j]);
                }
            }
        }

        int Q; cin >> Q;
        for (int q = 0; q < Q; ++q) {
            int l,r; cin >> l >> r;
            cout << B[l-1][r] << '\n';
        }
    }
};

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	TaskB solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
    return 0;
}


/**
	Template by Akikaze (秋風) - formerly proptit_4t41.
	Code written by a random fan of momocashew and Chiho.

	H△G x Mili - November 27th, 2013
	Mag Mell (Mili) - Sep 17th, 2014
	H△G x Mili Vol.2 - May 9th, 2015
	Miracle Milk (Mili) - Oct 12th, 2016
	青色フィルム (H△G) - February 14th, 2018
	Millennium Mother (Mili) - April 25th, 2018
**/

/** -----PRAGMA----- **/
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

/** -----BASIC MACROES----- **/
#define endl '\n'
#define i64 int
#define ld long double
#define rsz resize
#define pub push_back
#define mp make_pair
#define fi first
#define se second
const long long MOD = 1000000007LL, INF = 1e9, LINF = 1e18;
const long double PI = 3.141592653589793116, EPS = 1e-9, GOLD = ((1+sqrt(5))/2);
typedef vector<i64> vi;
typedef vector<ld> vd;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<i64, i64> pii;
typedef pair<i64, pii> pip;
typedef pair<pii, i64> ppi;
vi HashMod = {1000000007LL, 1000000009LL, 1000000021LL, 1000000033LL};

/** -----BIT CONTROLS----- **/
template<class T> int getbit(T s, int i) { return (s >> 1) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s); }

/** -----IDEAS/ALGORITHMS-----

    -------------------------- **/

/** -----CUSTOM TYPEDEFS/DEFINES----- **/

/** -----GLOBAL VARIABLES----- **/
i64 n, q, l, r; vi tree;
vector<vi> a, ans, mx;

/** -----EXTENSIVE FUNCTIONS----- **/

/** -----COMPULSORY FUNCTIONS----- **/
void VarInput() {
	ios_base::sync_with_stdio(0); cin.tie(NULL);
	cin >> n; a.rsz(n); ans.rsz(n, vi(n, 0)); a[0].rsz(n);
	for (i64 i=0; i<n; i++) cin >> a[0][i];
}

void ProSolve() {
	for (i64 i=1; i<n; i++) {
		a[i].rsz(a[i-1].size()-1);
		for (i64 j=0; j<a[i].size(); j++) a[i][j] = a[i-1][j] ^ a[i-1][j+1];
	}
	for (i64 i=0; i<n; i++) {
		for (i64 j=i; j<n; j++) {
			ans[i][j] = a[j-i][i];
		}
	}
	//for (i64 i=0; i<n; i++) cout << ans[i] << endl;
	mx.rsz(n, vi(n, 0));
	vector<vi> mxInCols(n, vi(n, 0));
	for (i64 j=n-1; j>=0; j--) {
		for (i64 i=j; i>=0; i--) {
			//tracker2(i,j);
			if (i < n-1) mxInCols[j][i] = max(mxInCols[j][i+1], ans[i][j]);
			else mxInCols[j][i] = ans[i][j];
		}
	}
	//cout << "----------\n";
	//for (i64 i=0; i<n; i++) cout << mxInCols[i] << endl;
	for (i64 i=0; i<n; i++) {
		for (i64 j=i; j<n; j++) {
			if (i == j) mx[i][j] = mxInCols[j][i];
			else mx[i][j] = max(mxInCols[j][i], mx[i][j-1]);
		}
	}
	//cout << "----------\n";
	//for (i64 i=0; i<n; i++) cout << mx[i] << endl;
	cin >> q; while (q--) {
		cin >> l >> r; l--; r--;
		cout << mx[l][r] << endl;
	}
}

/** -----MAIN FUNCTION----- **/
int main() {
			#ifdef Akikaze
			//freopen("FILE.INP", "r", stdin);
			//freopen("FILE.OUT", "w", stdout);
			#endif
	VarInput();
			#ifdef Akikaze
			auto TIME1 = chrono::steady_clock::now();
			#endif
	ProSolve();
			#ifdef Akikaze
			auto TIME2 = chrono::steady_clock::now();
			auto DIFF = TIME2 - TIME1;
			cout << "\n\nTime elapsed: " << chrono::duration<double>(DIFF).count() << " seconds.";
			#endif
	return 0;
}

/**
KKKKWWWWK;:.....:;,,,,,,,::,,,,,,,::,,,,,,i;,;ttttttt;:....:;EEDLffjfLGKWWWKLjjjfDWWWWWDffjffffi::::
WWWWWWWWW;:.....:;,,,,,,,::,,,,,,,:::,,,,,;;,,ttttttt,:....:,GDDGLLffLGDWWWKLjttjGWWWWWDfjjjjjji:...
WWWWWKWWW;:.....:,,,,,,,,::,,,,,,,:::,,,,,;;,;ttttttt,:....:,LGGGGGLLLLDWWWKftttjGWWWWWGjjjjjjj;:...
WWWWKKKWW;:.....:,,,,,,,,::,,,,,,,:.:,,,,,;;,,ttttttt,:....:,DDGGGGLLLLDWWWKfttttGWWWWWGjtjjjjj;:...
WWWWWWWWWi:.....:,,,,,,,,::,,,,,,,:::,,,,,;;,,ttttttt,......,EDGGGLLLLLDWWWKjtittGWWWWWLjtttttt;:...
WWWWWWWWWi:.....:,,,,,,,,::,,:,,,,:::,,,,,;;,;ttiiiit,......,DDLLLLLfLLDWWWKjiiitGWWWWWLttttttt;:...
WWWWWWWWWi:.....:::::::::::::::::::.:::::::,,,,,,;;;;,:.....,fLfffffjffGKKWEjiiitLWWWWWLttttttt;:...
WWWWWWKEDi:.....:::.::.:.:.......:..::::::::::::::::::......:,,,,,,,,,,;;;;;,,,,,,;;;;;;,,,;;;;,:...
KKEEKKEDG;:......::,,::,,:::::::::::::::::::.:::::::::......:::::::::::::::::::::::::::::::::::::...
jjttffLDG;:......:,ii;;ii,:,ii;;ii,:,i;,,;;::,;,,,,,:.......::,,,,,,:::,,:,,:::,,:,,,::::,::,::::...
ii;iiitLf;:......:,it;;it;:,it;;tt,:,tt;;ti,:;i;;it;:.......:,ii;;ii,:;ti;it;::;;;;ti,:;i;;ii,::....
iiiiiijft,:......:,ii,,;i,:,ii;;ii,:,ii;;ii,:;i;;;i;:.......:,ii;;ii,:,t;;it;::;;;;ti::;i;;ii,::....
tttttjffi,.......:,;;,,;;,:,;;;,;;,:,;;,,;;::,;,,;;,:........,;;,,i;,:,;;,;i,::;;,;i;::;;;,;i,:.....
ffjjffLft;:......:,i;;,;i,:,ii;;ii,:,ii;,;;::,;;,;;,:........,;;,,;;::,;,,;;,::;;,,i;::;;;,;;,:.....
LLLLLGGGf;:......:,ii;;it;:,tt;;tt,:,ii;;ii::;i;;;i;:........,ii;;i;::,i;;ii;:,ii;;ti::;i;;ii,:.....
DGGGGDDDLi:......::;;,,;;,::ii;;ii,:,i;,;i;::;i;;;i;:........,ii;;ii::;i;;;t;:,ti;;ti::;t;;tt,:.....
EEEEDDEDGt:......::::::::::::::::::::,:::,:::,,,,,,,::.......:,,,,,,:::,,,,;,::;,,,;;::,;,,;;,:.....
EEEEDDEEDj:....................................::::::........:::::::::::::::::::::::::::::::::::....
EEEEDDDEEG;:......................................................::................................
EEKEEEEEEGj:..............................................:.........................................
KKKKKKKKKEL;:............................................::.........................................
WWWWWWWKKKDj:.........................................:::::...::::,:............................::::
WWWWWWWWWKEG,:............::::................:jfLffLLj::,,::::.::,:.......................:::::,,;i
KWWWWWWWWWKD;::::,,,,,,,,,;;;,;::::::::..::.;tffLjffDGjfttL,,:::::,,,:.............:.......:,,,,;;ii
KKWWWWWWWWft,:::,tGGGGGGLGGfji;;tfttttfffLL;ittjjjLLGLGffEjttji,,,::;i,,,,,;;;;;;;,;,,,,;;,,,;;;;;;i
KKKKKKKWWD;:::..:;DGDEEEEEEGji,;;iitjittLttit;tjjfDGGfLfGfGffjfjfit,;;;itLDEDDDGGGGGjiitti;;itji;;;i
KKKEDEEKWK;:....:;GGDKWWKKELLji;;iiti;;;tjjjLtfjjtfjLLLLGffLLLLfLLj;;,,;;tDEDDDDGGGLt;;tii;;iitiitit
WWKEDDEKWWG,:...:;DKDEW#WEjt;;i;ii;;;;;,GLDDGDDLGEitDjLLGGGLDGfEELfGi,,i;;tjLGDGLGEjiiitttiitttiiitj
WWWKKKEEKKWj::.::iDEDDEWWDii;;;;;;,,;;,,LDEGEKEDELGLfGLfLLLfDGKWDELGLjii;;;;tGGLfGEjiiiiiittti;;;;it
WWKKKEDDDKKKt;,;iLGGGLLLGfiii;i;,;i;ii;DDKDLKEEEKKDKfLjEfELDGEKELEKEEtti;;i;tffffLGLt;;ttttjt;;iittj
WWKKEDGGGDEEEDDDGfjtttiii;;,,;i;,ii;;itEKKKKWKKKKKKEEELtLfDGKWDEWKKLLGDj,;iijLfjjjfLfitjtttjtittjfff
KEEDGLffLGGGGGLfjti;;;ii;;,;,;iii;,iiiDWKKKKWWW#WWWKKEEDKGDfWfKWWEGGGjiti;iitjtttttttittiittttjjjttf
EDDGLfjjfLLfffjtti;;;;tjt;;;,;;;;;,,;;KWWKEWWWWWWKEKKEKDEEDWEKWKEDDDEG,,iii;;iiiiii;;;iii;;;iitttttL
KKEEDGjitffLLLffjti;;itjj;;,,;,;,;,,;DKWWWWWWWWWWWKWWEWKKW#EEKKKEGWWEj;:,i;,,;iti;;;iiiiii;;iitiijjD
WWWDLfjiiitfDGfLLffttjjji,,,;;;;;,,,;KWWKWWWWWWWWKWWWWWKWWWWKKKEWWWKfii,:;;;;tti;,,tGGGLGGLLLfjjjfDD
WWDfjtiii;;;;;,;;iitfLj;,,:,i;i;ti;;jWWWWWWW#W#WWWWWWWWWWWWEWWGW#KWGjti,:,,,,iti;,,fWEjtjLLjfLjjjji;
WDGfji;;iii;;,:,,,,,;;;;;,,;;ii;;i;;KWWWWWWW#W#WKWWW#W###WGWE#WWKWKfti;,,:,;;;ff;;;fWKfjt;;ijfjjfi,:
EGGGfjiitiii;,,,,,,,;;;ti;;;iii;;t;iWWWWWWWW#WKKWWWWWW###WW#WWWWKELjti;;;,,,,,;;;;;jGGjt;;itjjtit,:.
LEEGGLjjji;;;;,,,,;;iitttt;;tti;;tfGW#WW#WKWWWK#WW##W###WWWWW#WWKELtii;;;;,,,,;;;,;fji,;iii;iti,;,:.
fWDLGLfLjii;;;,,,;;;;;;;iii;iji;itfEWWWWW#WW#W##WW#W######W#WWWKGLjiii;;;;i;;;;ti;;ti;:,;i;,;;;:,,:.
fWEDGLffjjti;;,:,,,,,,;iii;;tjt;itfKWWWWWW##WW#WW###W##W###W#WELjtii;;;,;;ii;,,i,,ij;,,,;i;;;,,::...
fWWKGtttii;,;i,,;i;,;iit;tf;;tfiitjWWW##W#WW#WW##WWW########WKftitii;;;;t;tt;,,,::;,:,;;ii;;;i;:....
fWKKLtiii;,,;ti;tjtitii;,,;;tjftiiEWWWWWWW##WWW##W##K##W###WWEtii;;;;ffDKjfji;,,:;;;;;;itttiijt,:...
LWKEjttiii;ijjfGLjttti;;;;;iifLt;;EWW#W#WWWKWK#WW###WW#####WKGiiiiitjfffGjjti;;;;t;,;;ttijiiijti;:..
LKKEtittjLjjGDDEEGji;;;;;iittGGf;iKWWWWWWEEWW#WWWW#KKKW###WWKfii;itLGLjiffj;;;,;;ii;,,jjjiijt,,;,,:.
LKKDjijLGLfLDKKftjt,,::,;;;LffLGjKKWWWWWWKWWWW#WWW#WWKWW##WEGjii;;iLDKEtjjt;t;;,,;iittLLDjtLfi,,:::.
LKEELffLGLLDDEj,,;tt;::,ittfGfjDGDWWKWW#KWKW##WW###WWEEKWWKDft;i;;;tGK#Eitiii;,:,;LfjfLtLLtLjjti,:..
GKEKDGLGGGDEEDii;;itti;;jtijLfjtGKWWWWWKWEWW#####W#WWGDEKKEDfi;;;;,,;fGt;i;;i;,,ittjjtttjGGELLti;:..
GEEDGfGGLffLLiiji;;;;tjtfjjffLfjGWWWWWWWWWWW#######GKDDDEEEDtti;;;,,,tt;,i,;jfttij;jfitfjLGEEf;;,:..
GEEDLjLDDjtfi,ijt;iitff;tDDLfGLEGWW#WWWWW#######W##EGEDGDEEGjiii;i;;,,,,,,,;jGt;ttfjjjifDDfLEE;::,::
LEEDLjffjfGGiifGDjfttLDitffjfGjDDKWWWWKWW##W#W#####KGLGGDGDLttiiiiii;,,;;:;tit,,tiii;iiLGGGtLEi:.:,:
GEEELjfttfGLfjfGDLGGGKKfLfLGLLjGKKWWWWWW###########DtfGGLEGfjttttttti;,;;:ii;,,;;i,i;iiLLj;;fft:.::.
GEEGGLLLfjjfGELLLfGGGLEt;;tjGGLEW##WWWWW##W########WWEGLLLftttttttjti;,t;,.jt;iiiiijfitjjt;,;tt;,:,,
DDLGGDEDLjjjGEftjLEfffi,,,;tjjEWWWWWWW##WW#########WWWELLjjttittttttti;i;ttjf;ititffjitjfj;::;itiitj
DGLGEEKDjtjLGjttjfLLGj,,;i;iiiDWWWKKWW##W##########WWWELfjttiittttjtttGjjKji,,fGjjfLj;tLft;::,,ittjL
GDGDEKKLttfKDjtLDfLDDi,itttjiiEKWWWWW##############WWKELfjtttitttttjjttEftit;;DDLjfLjijjtti,::,;jjLG
GEDDEKEGjGWWKEKWWEEEEfjfLjttjLKKWKWWW##############WKKEGfjtttttttjjjjt;jfj;tjLEELjfffttiti;;::,,;fDE
GEDDEKKGjLKWW#WWKDGEEEDGDLjtjDKWWKWW###############WKKEDLjjttttjjjjffjt;LjtjfGDGGfLtLjffLjit;:,,,jEE
LEDDEEKGjjLKW###EttDEEGfjLDLEEKWWW##W###W##########WEEEGLfjjjjjtjjfffDDLjjftLLLftfjiLDEDffftj;i;,iDK
LEDEEEEDjtfEW#WWLtjEEGfjjfEKEEWWWWW################WWEEGGLjjjjjjjffLKDEGttjjfjttijfDGLLfjft,;ttt;;fD
LEDEKEEDffGWW#WWDfGELLffLfKEEWWWWW#################KDEDDLLfjjjjjjffLfLLftttjtjfGjifEELfjjj,.:,;ittjj
GEEKKWKEGDKWWW#WWEEELGfjLEEEEWWWW#################WKDDDDGLLfjjjjfLLfjLLjjjjfjjLEDjEWELfjjj;::,,ijfjj
DEEKWWWKEEWWWWWWWWWWEGjfGEEKKWWWW#################WELGEDGGLffjjffLLffjjtjLDLLLfEEjKWELGjfjti;itffffj
EEEKWW#WKKWWWWWWWWW#KLLEDDEKWWWWW##############W#WEELGDDGGLffjfffLfffttttfDGGGLEKDWWKEDitfLLLGGGGLLL
DDEKWW#WKKWWWWWWWWWWEGEKEEKEKWWW#################WGGLGGDGGLfjfffffffji;tjfLGDEEEWKDEGLGijGEEEDGLLLff
GDEKWW#WWKKKKKKKWWWWDEKKEEDLWWW########W########WEDLLLGDGGLGEGtjfffLfi;;;tGDDKEDKLtfDLftttfGfjiii;;;
GDKKWW#WWKKKWKDEKKWWKKKKKKDEWWW##W##############KELLLLGDGGGELjLEjjjfj:,tijDDDEEDEGjjDGjt;,iti;,,,,,,
EKKKWWWWWKKWWKDDKKWWWKKKWKKKWWW##WW###WW###WWW#WEGLffLLGGLEDLLDEL;tGi:,jjGGGDEDLLDGffGji;,;;;,,:,:::
WKKKWWWWWWWWWKDLGEKKWKEKWKKKWW##WWW##WWW##WWW#WEDLfffLLLLEDDEEKKGjfDLjLjiLLLDEDjfGGffGti;;;;;,,,,,,:
WKEEEEEKWWWKEEEGLDEKKEDGEKKWW###WW###WW##WWWWWDGLffffLLLDELDEEKWKEGGGLLLiijttDDLGDDGGLjttiiiiiiii;;;
WKEEt;;LWWWEDDDDDDEEGGGjLEKWW##W####WW#WWKWWWDfjjjjffLLLEEGDKEWWWEDDGGfLfit;,;GGKKEGGfGGGLfjffLLLfjj
WWKi:.:iKKKEEDEEDDDDGGfitKWWW##K###WWW#KEKWWfiiittjjfLLfGEDKKEKWKEDDDGtifftji;jDKKEDGfEKEEEEEEEEKEDD
WKt:  :jEEEEEEEEDDEDDDjtGKKWW##W###WW#GfKWL;,,,;ittjfLfEEDDEKEEKWWELGDLjffjGEfLDWWEDLLEEEEEEKKEEEKKE
Kt:. :iGDDDDDDDDDDDDGGLLKWEW##WW#WW##GDKDi....:,;ittjfKWWKKKKEEKWKKEEGGfjjLDEEGGWKDDfLDGLDKKEEGGDEEE
t:. .;LGGDGGGGGGGGGGLLGGGWWW#WW#WWWWGEj;.      .,;iitftGLKWKKKKDEKEDKKDGftLDDGLGEDLfjDEDDEWWWKDDEKKK
:. .,tLGDDGLLLLLLGGGLLGGDWW##W###WWKK:,        ...;;it;tGEKKWKKEEKEEKKDDt;tGEGfLDDLjfEWWWWW#W#WWWWWW
. .:j;iLGGLffLLLLLLGLLDGDKW######WWW.:           ...;i;;jEKKKKWWKKWWKGLDGtffGGfjGDfjGEKWWWWWWWWWWWWW
..:tGiifLLLffffLLLLLfLGLGKW#####WWW.:             ....;;;DKKKKKWKKKWKLfDKDLjfGjjGGtjLGEWKKKKKKKEDEEK
:,ifLjjLLffffffLLLLLfLLLGKW#W###WW:,               ...::tGKKKEKWKKKKKDfGEEGfLLjfGftjGDEEDEEEDEDDGDED
iitLLtjfffffffffLLLLLLGGDWWWW##WWG..               .....::KDGEKWKKWKKELLEKEjtjjffttLGGEEDDDDDDDDDDDD
Dj;tjtjffffLffjjfLLLLGGGG#######W::                 ....::EEEKKWEDEKKKDLDEDfttffLtfLLLGGGGGGGGGGGGGG
DL,;ttffjjfLffjjLLLLLGDGDW######E:                   ....:.WWKKKEDEKKKKGGDLLjtjfDLfjffLLLLLLLffffffL
DDjitjffjfjjffffLfLLLLDGGWW#####: ..                  ..:..EWKKEKKKWKKKEEDftttjfGfttjjffffffjfjfjjjj
DDjttjjfffjjfffffjfLLLDDDW#####W: ...   . .i,iit;;ft   .....KKKEKKWKWEEKKDfjLLfjfjtjjjjjjjjjjjjjjjjt
DGjtjjffffLfLfffffLLLLGDEW#####t....   .. GG.ttjLDf:,f .....;KKWWWWWWKDEDDLLDGftjjjjjjjjtttttttttttt
DLjjjfffffffffffLLGLLLGDE######: .: .  .. ,.       .jE,:.....EKWWWWWWWKELGDDEGjjjjttttttttttttititti
DfjjfLLfffffLLLLLGDGGEEEKWW###L .:... ...        .    .j......KKWWWWWKKKGDDDEGjtjtttttttiiiiiiiiiiii
DjjfLLfLLfjfGLGGGDDDDDEE#W#W##,.::....... .:...::::..   ;.....iKWWWWWKKEDDGLffttjtttiiii;;;;;;;;;;;,
LjffLLLGLfffGGDDDEDDEEKKWW###W..,.........    :,:::...:: :.....KWWKKKKKEfGDGfffjjtttii;;;;;;;,,,,,,,
LLLLGGGDDGGDEEEEEEDDKKKWWW###,.:,.....  .:  :,,:..:...:,, :.... KWKKWKWGjLDDGLLLttti;;;;,,;;;,,,,,,,
LGLLGGLGDDDEEEEKKKKKKKKW#####:.::........:..,,:::::...:,,:......tKKWWKKDfDKGjjfLttti;;;;,;;;;,,,,,,,
GGfLLLLGDEEEEEEKKKKKKKKWW####..::........::;;,::::::...:,,,......KWWWWEDLDEGjijftiiiii;i;;;i;;;;;;;;
LGffffGEKKKKWKKWWWKWKKKW####j.::::.......:;,,::::,:....:,,:;:.....WWWKKEGEEKGtfjiiiiiiiiiiiiiiiii;;;
LLfLfLEWWWWWWWW#WWWKKEWWW###:.::::::...:::,:,::,:::.....:,,;:.....EWWKKKDEKWKLLtiiiiiiiiiiii;ii;;;;;
LffGGDKWWWWWWWWWKKEEEEWWWW##..::.:::.:.:::,,:,,:::::....:,,:,:.....WWWEEEEKWWKDt;;iiii;;;;;,,;;,,,,,
LffDDDDEEDDEDDEDDEDDDDEKWWWW..::::::::.:..:,:,:,:::.....:,,,;,.....tWKEEEEKWWWDt;;iiii;;,,,:,,,:::::
LLfGGLLGGLGGDDDDDGGDGEEWWE#W.::::::::::::.,,:,,,:::......:,,;,:.....EEEKEDEWWWDi;;;iii;;,,,:,;;,::::
LfjGLLLGGLLGDDGDDLGDGEEWEEWW..:::::,,..:..,,,,,,::.......:,,:,,.....jEEKGGEWWWGt;;iiiii;;,,:,,,,::::
ffjLGGGGGLGDGLLDGLGDEEKWGE#W...::,:,:.::.::,,,,,::.....::::,,,,,.....KKEDDKWKKDj;;iiiiii;,,,,,,,::::
ffjfLLGGLLGDGLLDGLLGEKWWWKWW...::,,,:.:.::,,,:,:,:......::,:,;;,... .EEDDEDKKWEj;;iiiiiii;,,,,,,::::
LftjLLGLLGGDGLGGKGfjDWWWEEW#....:,,,::::::,,,,::::..  ..:::,,,,,:....DEDEEGGDEDfi;;iiiiii;,,:,,:::::
LfjjLGDGLGGGGGGGGEEEEWDGE#W#....::,:::.:::,,,::::.. .....:::,:,,,... GKDEEEDEKEELiiiiiiii;,:,,,:::::
GLjjLDDGGLGGLLLGLLKKEGKWWWW#i...::,:.:::::,,,::....:.::...:.,:,,,:....KDLLDEDEDDLjttttttti,,,;;,::::
GGffDDGGGGDLLLGLfLGKWWW##WW#i;...:,:::,,::,,:::,,,;,;t;: ,i::::,,,:...EDjtGDGLjffjfjjjjttt;;;i;,,:,:
DGffGDLLLGDLLLGfffLGGLW#####,t:.::,:::,,::::;:,;ii;;iitt:::i::;:,,:...LEfjGLLftjLfffjjjttttiti;,,,,:
KEGLGGLffGGLfffjjjfGfffL####;i,:::::::,:::tiiii;i,,;iiii:,;:;,f:,,,:...WKKKKKKDDEEGEfjtttttttt;,,,,,
KEEEDGffLGLjtfffffLGjtjW####;;,.:::..:::jt;;;ii;;i;;iii;:,;;,,,;:::::..WWWWWWKKEEEDEftiiiiitti;,,,,,
DDDDDGLLGGLfjLGfffLGtitjjGW#f;,::::.::,ii;i;;;i;;iiii;;,:,:,;;;W:,:::::WWWWWWWWKGEKEt;;;;;;;;;;,,,,,
GDDDEDDGGLLfLGLjtjLLtittjjjW#;;::.:.:;i;;;,;;;i;;iii;;i.,,,::,:Gj::::::WWWWWWWWWDGGDi;;;;,,,,,,,,,,,
DDEEDGGGDGGGGDLLffLftttjjttjfi;::.::;t,i;,,;,;;;;;;;;;;.,,,,;;:ED:,:,,:KKWWWWWWWWEEKt;;;;,;,,,,,,,,,
DGDEDGLGEDGGGLffffjitttjjiitji;,::::j;,i,;;;;;;;;;;;;;,.:,,:,;,.L#:,,,,WWWWWKWWWWWKEt;;;;;;;,,,,,,,,
LGDEEGLGDGLLLLjjjftitttjftitjLit,,:;j,;i,,,;;,;;,,;;;,::,;,::;,.EG,,:;,WWWWWKWWKKWEEt;;;;;;;;;;;;;,,
GGEEDGGGLfffGLfjtjffjjttjtttjfiii,,tj:ii,:,;;;;;,,,,,,.:,;;,.,,,.GW:,;,WWKWWWWWWWWKGjttttiiitttiiii;
GLLDDDDLffjfGLffjjLfjtitfjjjjLtij;,tf,t;::,,,,,,,,,,,,.,,,,,:,,::;f;;i,KWKKWWWWWWKKLijjjjjjjtttttttt
GLfGGGDLffjfLfjjjfGjtiitfjtjjLLitt:tf;i;,,,;,,,,,,,,,::,,,,,:;;:;.KG:i;WKKWWKWWWWWWGtjjjjjjttttttttt
EEGLLGDGfLfLLffjjLLtiiitfjjjjLfjij,jj;ti,,,,,,,,,,,,,.:,,,,::;;:;::L:iiWWWKWWWWWWWWKLjjjtttttttttiii
DDLffLGGLLfLLjjjjfftiiitftttjGfftttjj;i;:,,,,,,,:::,,.:,,,,,:,,:i,,E;iLWWKKWKKWWWWWKDtttttttttiiiiii
DLfjfLDLffffjttjjfftiiiijtjjfLLLjttfj;it:,,,,:,,,::,,.::,,,,:,,,ii,WtiKWWKKWKKWWWWWEGtiiiiiiiiiiiiii
DfjjjGGfjfLLjjjjfLLjjjjffffffLfjfjtffiti,,,,,,,:,:::::,:,,,,:,,:ii,LtiKWWWKKWWWWWKKKGtiiiiiiiiiiii;i
DGLLLDGfffLGLfffLLfjtttjfjjjffLjfjjtLtti:::,:,:,::::.:,,,,,,,:,:ii;f;;KKWWKKWKWWWWKKEjii;i;;;;;;;;;;
GLLLGGfjfjfLfjjjLGLftttjfjjtjfffLLjjjGtt:,,,,,,,,::: ::,,,,,::,,it;Ei;KWWWKKWKWWWWWWELi;;;;;;;;;;;;;
GGGLGLfjjjfffjjjLDGLjtttjjjjjffjfLffjLti,,,,:,,,,:::.::,,,,:,:,;tt;LiiKKKWWWWWWWWWWWKDi;;;;;;;;;;,,,
GGLLDLffjfffffffGGDGfjtjfjjjjLLLffLjfjtt,,,,,:,:,:::.:::::,:::,itt;ti;KKKWWWWWWWWWKKKEi;;;,,,,,,,,,,
LLLGGjjjffLffjjfLGGLfjjjfjjttjjffjjLfjjt,,,,,,,,,::::::::::,,:,ittDtijWKKWWWWWWWWWWKEDi;;;;;,,,,,,,,
fjLDjijfLLGLfjfLGLfjjjjjfjjjjfLGGLLDjftt;,,,,,:,,,,.:::,,,,,,:,ttt#tiWWWKWWWWWWWWWWWKEj;;;i;;;,,,,,,
jjLEfjjfjfLfjttLGLjtjtttjjtjfLLLGGGDEjftt,,,,:::::: ::::::::::,ttKKjiWWWKKWWWWWWWKWWKKDi;ii;;;;;,,,,
jjfGfffjtjjjjffLGGjtjjiifjjjfLLLGGGGELjLt,,,,,,::::.::::::,:,,,ttWELKEWWWKKKWWWWWWWWWWKj;ii;;;,,,,;;
jjjffffjjffjjffLLLftttitjjjtjfffLLGLGLjft,,,,,:::,,.::::::,,,:;tjWKE,WKWWWKKKWWWWWWWWWWjii;;;,,,,,,;
**/

// Tribute to a friend I owe countless. Thanks, TN.