Problem: This time Baby Ehab will only cut and not stick. He starts with a piece of paper with an array a of length n written on it, and then he does the following:

  * he picks a range (l, r) and cuts the subsegment a_l, a_{l + 1}, …, a_r out, removing the rest of the array. 
  * he then cuts this range into multiple subranges. 
  * to add a number theory spice to it, he requires that the elements of every subrange must have their product equal to their [least common multiple (LCM)](https://en.wikipedia.org/wiki/Least_common_multiple). 



Formally, he partitions the elements of a_l, a_{l + 1}, …, a_r into contiguous subarrays such that the product of every subarray is equal to its LCM. Now, for q independent ranges (l, r), tell Baby Ehab the minimum number of subarrays he needs.

Input

The first line contains 2 integers n and q (1 ≤ n,q ≤ 10^5) — the length of the array a and the number of queries.

The next line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^5) — the elements of the array a.

Each of the next q lines contains 2 integers l and r (1 ≤ l ≤ r ≤ n) — the endpoints of this query's interval.

Output

For each query, print its answer on a new line.

Example

Input


6 3
2 3 10 7 5 14
1 6
2 4
3 5


Output


3
1
2

Note

The first query asks about the whole array. You can partition it into [2], [3,10,7], and [5,14]. The first subrange has product and LCM equal to 2. The second has product and LCM equal to 210. And the third has product and LCM equal to 70. Another possible partitioning is [2,3], [10,7], and [5,14].

The second query asks about the range (2,4). Its product is equal to its LCM, so you don't need to partition it further.

The last query asks about the range (3,5). You can partition it into [10,7] and [5].

Solution (in CPP):

Solution:
// vim: filetype=html tabstop=73 background=light :
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")
//#pragma GCC optimize("branch-target-load-optimize")
//#pragma GCC optimize("branch-target-load-optimize2")
//#pragma GCC optimize("btr-bb-exclusive")
//#pragma GCC optimize("O3")

#ifndef __APPLE__
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif

//#include <bits/stdc++.h>

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <deque>
#include <map>
#include <fstream>
#include <utility>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <random>
#include <math.h>
#include <cassert>
#include <bitset>
#include <chrono>
#include <sstream>
#include <array>
#include <list>
#include <functional>
//#include <Python/Python.h>

using namespace std;

#define DEBUG_VIVOD " SHTO-TO POSHLO NE TAK\n"
//#define all(x) x.begin(), x.end()
//#define rall(x) x.rbegin(), x.rend()
//#define pb push_back
//#define pf push_front
//#define _USE_MATH_DEFINES
#define filin(x) freopen(x, "r", stdin)
#define filout(x) freopen(x, "w", stdout)
//#define deq deque
//#define vec vector
//#define umap unordered_map
//#define uset unordered_set
#define nan nullptr
#define endl '\n'
#define INF 1e9 + 2
//#define INF ((int64_t)1e18)
#define INF_LL ((int64_t)1e18)
#define int int64_t

//typedef long long ll;
typedef int64_t ll;
//typedef __int128 ll;
//typedef unsigned long long ull;
//typedef long long ull
typedef long double ull;
//typedef __float128 ull;
//typedef __int128 ull;
typedef long double ld;
typedef unsigned long long ui;

const int maxn = 1e5 + 5, l = 20;

int go[l][maxn];

void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<int> st(maxn, -1);
    vector<int> nxt(n + 1, n);
    for (int i = 0; i < n; ++i) {
        for (int j = 2; j * j <= a[i]; ++j) {
            if (a[i] % j == 0) {
                if (st[j] != -1) {
                    nxt[st[j]] = min(nxt[st[j]], i);
                }
                st[j] = i;
                if (a[i] / j != j) {
                    if (st[a[i] / j] != -1) {
                        nxt[st[a[i] / j]] = min(nxt[st[a[i] / j]], i);
                    }
                    st[a[i] / j] = i;
                }
            }
        }
        if (a[i] > 1) {
            if (st[a[i]] != -1) {
                nxt[st[a[i]]] = min(nxt[st[a[i]]], i);
            }
            st[a[i]] = i;
        }
    }
    vector<int> nxt2(n + 1, n);
    multiset<int> nw;
    int pos = 0;
    for (int i = 0; i < n; ++i) {
        while (pos < n && (nw.size() == 0 || *nw.begin() > pos)) {
            nw.insert(nxt[pos]);
            pos++;
        }
        nxt2[i] = pos;
        nw.erase(nw.find(nxt[i]));
    }
    for (int i = 0; i <= n; ++i) {
        go[0][i] = nxt2[i];
    }
    for (int i = 1; i < l; ++i) {
        for (int j = 0; j <= n; ++j) {
            go[i][j] = go[i - 1][go[i - 1][j]];
        }
    }
    while (q--) {
        int l1, r;
        cin >> l1 >> r;
        l1--;
        int ans = 0;
        for (int i = l - 1; i >= 0; --i) {
            if (go[i][l1] < r) {
                ans += (1 << i);
                l1 = go[i][l1];
            }
        }
        ans++;
        cout << ans << '\n';
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int q = 1;
//    cin >> q;
    while (q--) {
        solve();
    }
}