#P1516D. Cut
Cut
Description
This time Baby Ehab will only cut and not stick. He starts with a piece of paper with an array of length written on it, and then he does the following:
- he picks a range and cuts the subsegment 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).
Formally, he partitions the elements of into contiguous subarrays such that the product of every subarray is equal to its LCM. Now, for independent ranges , tell Baby Ehab the minimum number of subarrays he needs.
The first line contains integers and () — the length of the array and the number of queries.
The next line contains integers , , , () — the elements of the array .
Each of the next lines contains integers and () — the endpoints of this query's interval.
For each query, print its answer on a new line.
Input
The first line contains integers and () — the length of the array and the number of queries.
The next line contains integers , , , () — the elements of the array .
Each of the next lines contains integers and () — the endpoints of this query's interval.
Output
For each query, print its answer on a new line.
Note
The first query asks about the whole array. You can partition it into , , and . The first subrange has product and LCM equal to . The second has product and LCM equal to . And the third has product and LCM equal to . Another possible partitioning is , , and .
The second query asks about the range . Its product is equal to its LCM, so you don't need to partition it further.
The last query asks about the range . You can partition it into and .