#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<pair<int, int>> niska(q);

    for (int i = 0; i < q; i++) {
        cin >> niska[i].first;
        cin >> niska[i].second;
    }

    for (int i = 0; i < q; i++) {
        int k = niska[i].first - niska[i].second + 1;
        k = k * k;
        cout << k;
    }
}