using System;
class Program
{
    static int Funkcija(List<int> a1)
    {
        int xor = a1[0];
        int and = a1[0];
        int rez = 1;
        for (int i = 0; i < a1.Count; i++)
        {
            for (int j = i; j < a1.Count; j++)
            {
                xor = xor ^ a1[j];
                and = and & a1[j];
            }
            if (and > xor)
                rez = a1.Count - i;
            xor = a1[i];
            and = a1[i];
        }
        return rez;
    }
    static void Main()
    {
        string[] s = Console.ReadLine().Split();
        int n = int.Parse(s[0]);
        int q = int.Parse(s[1]);
        int[] a = new int[n];
        int[] l = new int[q];
        int[] r = new int[q];
        List<int> a1 = new List<int>();
        s = Console.ReadLine().Split();
        for (int i = 0; i < n; i++)
        {
            a[i] = int.Parse(s[i]);
        }
        for(int i = 0; i < q; i++)
        {
            s = Console.ReadLine().Split();
            l[i] = int.Parse(s[0]);
            r[i] = int.Parse(s[1]);
        }
        for(int i = 0; i < q; i++)
        {
            for (int j = l[i] - 1; j < r[i]; j++)
                a1.Add(a[j]);
            Console.WriteLine(Funkcija(a1));
            a1.Clear();
        }
    }
}