using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;

namespace ConsoleApp1
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int q = int.Parse(s[1]);
            int[] x = new int[n];
            int w = 0;
            string[] s1 = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
            {
                x[i] = int.Parse(s1[i]);
            }
            for (int i = 0; i < q; i++)
            {
                List<int> y = new List<int>();
                string[] s2 = Console.ReadLine().Split(' ');
                int a = int.Parse(s2[0]);
                int b = int.Parse(s2[1]);
                for (int j = a; j <= b; j++)
                {
                    y.Add(x[j - 1]);
                }
                y.Sort();
                int br = 1;
                int max = 1;
                for (int j = 0; j < y.Count-1; j++)
                {
                    w= y[j];
                    if (y[j + 1] == w)
                    {
                        br++;
                        max = Math.Max(max, br);
                    }
                    else
                    {
                        br = 1;
                    }

                      
                }         
                Console.WriteLine(max);



            }
        }
    }
}