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.*;

public class Main2{
	static int n,in[],log=18;
	static int[][]ans,idx;
	static int[]first;
	static void pre() {
		ans=new int[n][log];
		idx=new int[n][log];
		for(int i=0;i<n;i++) {
			ans[i][0]=1;
			idx[i][0]=i;
		}
		for(int i=1,len=2;len<=n;i++,len<<=1) {
			for(int j=n-1;j>=0;j--) {
				if(idx[j][i-1]!=j) {
					
					int[]right=solve(idx[j][i-1], Math.min(j+len-1,n-1), i, len);
					ans[j][i]=ans[j][i-1]-1+right[0];
					idx[j][i]=right[1];
				}
				else {
					int first=st.query(j, Math.min(j+len-1,n-1));
					if(first>Math.min(j+len-1,n-1)) {
						ans[j][i]=1;
						idx[j][i]=j;
					}
					else {
						int[]right=solve(first, Math.min(j+len-1,n-1), i, len);
						ans[j][i]=1+right[0];
						idx[j][i]=right[1];
					}
				}
			}
		}
	}
	
	static int[] solve(int l,int r,int i,int len) {
		if(l+len-1>r)return solve(l, r, i-1, len>>1);
		int cnt=ans[l][i]-1,start=idx[l][i];
		
		if(start==l) {
			int first=st.query(l,r);
			if(first>r) {
				return new int[] {1,l};
			}
			else {
				int[]right=solve(first, r, i, len);
				return new int[] {1+right[0],right[1]};
			}
		}
		
		int[]right=solve(start, r, i, len);
		return new int[] {cnt+right[0],right[1]};
	}
	static class SparseTable {
		int[]log,min[],arr;
		int inf=(int)1e9;
		SparseTable(int[]in,int n) {
			arr=in;
			log = new int[n+1];
			for (int i = 2; i <= n; i++)
				log[i] = log[i / 2] + 1;
			
			min=new int[n][22];
			for(int i=0;i<n;i++) {
				min[i][0]=i;
			}
			for(int i=1,len=2;len<=n;i++,len<<=1) {
				for(int j=0;j<n;j++) {
					int u=min[j][i-1],v=j+(len>>1)>=n?inf:min[j+(len>>1)][i-1];
					if(v==inf) {
						min[j][i]=u;
					}
					else
						min[j][i]=(arr[u]<arr[v]?u:v);
				}
			}
		}
		int query(int l,int r) {
			int len = r - l + 1;
			int lg = log[len];
			int u = min[l][lg];
			int v = min[r - (1 << lg) + 1][lg];
			int bestIdx = arr[u] < arr[v] ? u : v;
			return arr[bestIdx];//or return bestIdx if we want the best index
		}
		
	}
	static SparseTable st;
	static void main() throws Exception{
		n=sc.nextInt();
		int q=sc.nextInt();
		in=sc.intArr(n);
		int[]d=new int[100001];
		d[1]=1;
		for(int i=2;i<d.length;i++) {
			if(d[i]==0) {
				d[i]=i;
				for(int j=i+i;j<d.length;j+=i) {
					if(d[j]==0) {
						d[j]=i;
					}
				}
			}
		}
		first=new int[n];
		int[]index=new int[d.length];
		Arrays.fill(index, n+7);
		Arrays.fill(first, n+7);
		for(int i=n-1;i>=0;i--) {
			while(in[i]>1) {
				int div=d[in[i]];
				first[i]=Math.min(first[i], index[div]);
				index[div]=i;
				while(in[i]%div==0) {
					in[i]/=div;
				}
			}
		}
		st=new SparseTable(first, n);
		pre();
		int len=1<<(log-1);
		while(q-->0) {
			pw.println(solve(sc.nextInt()-1, sc.nextInt()-1, log-1, len)[0]);
		}
    }
    public static void main(String[] args) throws Exception{
    	sc=new MScanner(System.in);
    	pw = new PrintWriter(System.out);
        int tc=1;
//        tc=sc.nextInt();
        for(int i=1;i<=tc;i++) {
//            pw.printf("Case #%d:", i);
            main();
        }
        pw.flush();
    }
    static PrintWriter pw;
    static MScanner sc;
    static class MScanner {
        StringTokenizer st;
        BufferedReader br;
        public MScanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }
     
        public MScanner(String file) throws Exception {
            br = new BufferedReader(new FileReader(file));
        }
     
        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        public int[] intArr(int n) throws IOException {
            int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
            return in;
        }
        public long[] longArr(int n) throws IOException {
            long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            return in;
        }
        public int[] intSortedArr(int n) throws IOException {
            int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
            shuffle(in);
            Arrays.sort(in);
            return in;
        }
        public long[] longSortedArr(int n) throws IOException {
            long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            shuffle(in);
            Arrays.sort(in);
            return in;
        }
        public Integer[] IntegerArr(int n) throws IOException {
            Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
            return in;
        }
        public Long[] LongArr(int n) throws IOException {
            Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            return in;
        }
        public String nextLine() throws IOException {
            return br.readLine();
        }
     
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
     
        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
     
        public char nextChar() throws IOException {
            return next().charAt(0);
        }
     
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
     
        public boolean ready() throws IOException {
            return br.ready();
        }
     
        public void waitForInput() throws InterruptedException {
            Thread.sleep(3000);
        }
        
    }
    static void sort(int[]in) {
    	shuffle(in);
        Arrays.sort(in);
    }
    static void sort(long[]in) {
    	shuffle(in);
        Arrays.sort(in);
    }
    static void shuffle(int[]in) {
        for(int i=0;i<in.length;i++) {
            int idx=(int)(Math.random()*in.length);
            int tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        }
    }
    static void shuffle(long[]in) {
        for(int i=0;i<in.length;i++) {
            int idx=(int)(Math.random()*in.length);
            long tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        }
    }
}