using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.AccessControl;
using System.Text;
using System.Threading.Tasks;

namespace _2takm2025_26
{
    internal class Program
    {
        static List<int> LengthOfSubArray(int n, int q, long[] a, int[] aq)
        {
            List<int> res = new List<int>();
            for (int i = 0; i < aq.Length-1; i += 2)
            {
                int restemp = 0;
                int respart = 0;
                List<int> temp = new List<int>();
                if (aq[i] != aq[i + 1])
                {
                    for (int j = aq[i]; j < aq[i + 1]; j++)
                    {
                        restemp = 0;
                        respart = 0;
                        for (int k = j + 1; k <= aq[i + 1]; k++)
                        {
                            if ((a[k] & a[j]) > (a[k] ^ a[j]))
                            {
                                if (restemp == 2 || restemp == 1)
                                {
                                    respart++;
                                    restemp = 1;
                                }
                                else if (restemp == 0)
                                {
                                    respart += 2;
                                    restemp = 2;
                                }
                            }
                        }
                        if (respart == 0)
                        {
                            temp.Add(1);
                        }
                        else
                        {
                            temp.Add(respart);
                        };
                    }
                    res.Add(temp.Max());
                }
                else
                {
                    res.Add(1);
                }
            }
            return res;
        }
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int n = int.Parse(input[0]);
            int q = int.Parse(input[1]);
            long[] a = new long[n];
            input = Console.ReadLine().Split();
            for(int i = 0; i < n; i++)
            {
                a[i] = int.Parse(input[i]);
            }
            int[] aq = new int[q*2];
            for(int i = 0; i < q*2-1; i+=2)
            {
                input = Console.ReadLine().Split();
                aq[i] = int.Parse(input[0])-1;
                aq[i+1] = int.Parse(input[1])-1;
            }
            List<int> res = LengthOfSubArray(n, q, a, aq);
            for(int i = 0;i < res.Count; i++)
            {
                Console.WriteLine(res[i]);
            }
        }
    }
}