using System;
using System.Collections.Generic;
using System.Linq;


namespace ConsoleApp3
{
    class Program
    {
        static int MSB(long x)
        {
            int b = 0;
            while ((1L << (b + 1)) <= x) b++;
            return b;
        }
        static long Funkcija(long[] a, int l, int r)
        {
            Dictionary<int, long> d = new Dictionary<int, long>();
            for (int i = l; i <= r; i++)
            {
                int k = MSB(a[i]);
                if (d.ContainsKey(k)) d[k]++;
                else d[k] = 1;
            }

            long max = 0;
            foreach (var par in d)
                if (par.Value > max) max = par.Value;

            return max;
        }

        
        static void Main()
        {
            string[] s = Console.ReadLine().Split();
            long n = long.Parse(s[0]);
            long q = long.Parse(s[1]);
            string[] s1 = Console.ReadLine().Split();
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = long.Parse(s1[i]);
            

            List<long> rez = new List<long>();
            for(int i = 0; i< q; i++)
            
            {
                string[] s2 = Console.ReadLine().Split();
                int l = int.Parse(s2[0]);
                int r = int.Parse(s2[1]);
      
                rez.Add(Funkcija(a, l - 1, r - 1));

            }
            foreach (long res in rez) Console.WriteLine(res);
 
        }
    }
}