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 JAVA):

Solution:
import java.io.*;
import java.util.*;
 
import java.math.*;
import java.awt.Point;
 
public class Main {
    static final long MOD = 1000000007L;
    //static final long MOD2 = 1000000009L;
    //static final long MOD = 998244353L;
    //static final long INF = 500000000000L;
    static final int INF =   1000000005;
    static final int NINF = -1000000005;
    //static final long NINF = -1000000000000000000L;
    static FastScanner sc;
    static PrintWriter pw;
    static final int[][] dirs = {{-1,0},{1,0},{0,-1},{0,1}};
 
 
    static final int MO = 1200;
    
    public static void main(String[] args) {
        sc = new FastScanner();
        pw = new PrintWriter(System.out);
 
        int N = sc.ni();
        int Q = sc.ni();
        int[] A = sc.intArray(N, 0);
        boolean[] sieve = new boolean[100001];
        Arrays.fill(sieve,true);
        for (int i = 2; i <= 100000; i++) {
            if (sieve[i]) {
                for (int j = 2*i; j <= 100000; j += i) {
                    sieve[j] = false;
                }
            }
        }
        ArrayList<Integer> primes = new ArrayList<Integer>();
        for (int i = 2; i <= 316; i++) {
            if (sieve[i]) primes.add(i);
        }
        int P = primes.size();

        ArrayDeque<Integer>[] divs = new ArrayDeque[100001];
        for (int i = 0; i < N; i++) {
            int n = A[i];
            for (int p: primes) {
                if (n%p == 0) {
                    if (divs[p]==null) divs[p] = new ArrayDeque<Integer>();
                    divs[p].add(i);
                    while (n%p==0) n /= p;
                }
            }
            if (n > 1) {
                if (divs[n]==null) divs[n] = new ArrayDeque<Integer>();
                divs[n].add(i);
            }
        }

        int[][] table = new int[17][N];
        int R = N;
        for (int L = N-1; L >= 0; L--) {
            int n = A[L];
            for (int p: primes) {
                if (n%p==0) {
                    while (divs[p].peekLast() > L) {
                        R = Math.min(R,divs[p].pollLast());
                    }
                }
                while (n%p==0) n /= p;
            }
            if (n > 1) {
                while (divs[n].peekLast() > L) {
                    R = Math.min(R,divs[n].pollLast());
                }
            }
            table[0][L] = R;
        }

        for (int i = 1; i < 17; i++) {
            for (int j = 0; j < N; j++) {
                int next = table[i-1][j];
                if (next < N)
                    table[i][j] = table[i-1][next];
                else
                    table[i][j] = N;
            }
        }

        for (int q = 0; q < Q; q++) {
            int ql = sc.ni()-1;
            int qr = sc.ni()-1;
            
            int lo = 1;
            int hi = 100000;
            while (lo < hi) {
                int m = (lo+hi)/2;
                int cur = ql;
                for (int bit = 16; bit >= 0; bit--) {
                    if ((m&(1<<bit)) > 0) {
                        cur = table[bit][cur];
                        if (cur==N) break;
                    }
                }
                if (cur > qr) {
                    hi = m;
                } else {
                    lo = m+1;
                }
            }
            pw.println(lo);
        }

        pw.close();
    }
 
    public static void sort(int[] arr) {
        Random rgen = new Random();
        for (int i = 0; i < arr.length; i++) {
            int r = rgen.nextInt(arr.length);
            int temp = arr[i];
            arr[i] = arr[r];
            arr[r] = temp;
        }
        Arrays.sort(arr);
    }
 
    public static void sort(long[] arr) {
        Random rgen = new Random();
        for (int i = 0; i < arr.length; i++) {
            int r = rgen.nextInt(arr.length);
            long temp = arr[i];
            arr[i] = arr[r];
            arr[r] = temp;
        }
        Arrays.sort(arr);
    }
 
    //Sort an array (immune to quicksort TLE)
    public static void sort(int[][] arr) {
        Random rgen = new Random();
        for (int i = 0; i < arr.length; i++) {
            int r = rgen.nextInt(arr.length);
            int[] temp = arr[i];
            arr[i] = arr[r];
            arr[r] = temp;
        }
        Arrays.sort(arr, new Comparator<int[]>() {
            @Override
            public int compare(int[] a, int[] b) {
                int ablock = a[0]/MO;
                int bblock = b[0]/MO;
                if (ablock != bblock)
                    return ablock-bblock;
                else
                    return a[1]-b[1];
            }
        });
    }
    
    public static void sort(long[][] arr) {
        Random rgen = new Random();
        for (int i = 0; i < arr.length; i++) {
            int r = rgen.nextInt(arr.length);
            long[] temp = arr[i];
            arr[i] = arr[r];
            arr[r] = temp;
        }
        Arrays.sort(arr, new Comparator<long[]>() {
            @Override
            public int compare(long[] a, long[] b) {
                if (a[0] > b[0])
                    return 1;
                else if (a[0] < b[0])
                    return -1;
                else
                    return 0;
                //Ascending order.
            }
        });
    }
 
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
 
        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in), 32768);
            st = null;
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int ni() {
            return Integer.parseInt(next());
        }
 
        int[][] graph(int N, int[][] edges) {
            int[][] graph = new int[N][];
            int[] sz = new int[N];
            for (int[] e: edges) {
                sz[e[0]] += 1;
                sz[e[1]] += 1;
            }
            for (int i = 0; i < N; i++) {
                graph[i] = new int[sz[i]];
            }
            int[] cur = new int[N];
            for (int[] e: edges) {
                graph[e[0]][cur[e[0]]] = e[1];
                graph[e[1]][cur[e[1]]] = e[0];
                cur[e[0]] += 1;
                cur[e[1]] += 1;
            }
            return graph;
        }
 
        int[] intArray(int N, int mod) {
            int[] ret = new int[N];
            for (int i = 0; i < N; i++)
                ret[i] = ni()+mod;
            return ret;
        }
 
        long nl() {
            return Long.parseLong(next());
        }
 
        long[] longArray(int N, long mod) {
            long[] ret = new long[N];
            for (int i = 0; i < N; i++)
                ret[i] = nl()+mod;
            return ret;
        }
 
        double nd() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}