#include <iostream>
#include<vector>
#include<map>
#define ll long long;
#define f first;
#define s second;
using namespace std;
vector<long long> niz;
vector<int> res;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, q;
    cin >> n >> q;
    int maks = 0;
    vector<int>res;
    for (int i = 0; i < n; i++) {
        long long x;
        niz.push_back(x);
    }
    int h = q;
    while (q--) {
        int l, r;
        cin >> l >> r;
        map<long long, long long> gra;
        for (int i = l - 1; i < r; i++) {
            gra[niz[i]]++;
            if (gra[niz[i]] > maks) maks = gra[niz[i]];
        }
        res.push_back(maks);
    }
    for (int i = 0; i < h; i++) {
        cout << res[i] << endl;
    }
}