using System;
using System.Collections.Generic;

namespace ConsoleApp3
{
    class Program
    {
        
        static long Funkcija(List<long> a, int l, int r)
        {
            if(r!= a.Count) a.RemoveRange(r, a.Count - r);


            if (l != 1) a.RemoveRange(0, l - 1);


            Dictionary<long, long> d = new Dictionary<long, long>();
            foreach (long aa in a)
            {
                if (d.ContainsKey(aa)) d[aa]++;
                else d[aa] = 1;
            }
            long max = 0;
            foreach (KeyValuePair<long, long> 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();
            List<long> a = new List<long>();
            List<long> b = new List<long>();

            for (int i = 0; i < n; i++)
            {
                a.Add(long.Parse(s1[i]));
                b.Add(a[i]);
            }

            long br = 0;
            List<long> rez = new List<long>();
            while(br < q)
            {
                string[] s2 = Console.ReadLine().Split();
                int l = int.Parse(s2[0]);
                int r = int.Parse(s2[1]);

                rez.Add(Funkcija(a, l, r));
                br++;

                a.Clear();
                for (int i = 0; i < n; i++)
                {
                    a.Add(b[i]);
                }
            }
            foreach (long res in rez) Console.WriteLine(res);



        }
    }
}