@@ -0,0 +1,1571 @@
+https://www.hackerrank.com/challenges/sherlock-and-queries%0Aimport java.io.*;%0Aimport java.util.*;%0A%0Apublic class Solution%7B%0A    private final static int MOD = 1000000007;%0A    public static void main(String%5B%5D args) throws IOException%7B%0A        //INPUT%0A        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));%0A        String%5B%5D strs = br.readLine().split(%22 %22);%0A        int N = Integer.parseInt(strs%5B0%5D);%0A        int M = Integer.parseInt(strs%5B1%5D);%0A        int%5B%5D A = getArr(br.readLine().split(%22 %22));%0A        int%5B%5D B = getArr(br.readLine().split(%22 %22));%0A        int%5B%5D C = getArr(br.readLine().split(%22 %22));%0A        %0A        //SOLVE%0A        Map%3CInteger, Integer%3E map = new HashMap%3CInteger, Integer%3E();%0A        for(int i = 0; i %3C M; ++i)%7B%0A            int key = B%5Bi%5D;%0A            Integer j = map.get(key);%0A            map.put(key, (j == null) ? C%5Bi%5D : (int)((((long)j) * C%5Bi%5D) %25 MOD));%0A        %7D%0A        %0A        for(int divisor : map.keySet())%7B%0A            long multiplier = map.get(divisor);%0A            for(int j = divisor - 1; j %3C N; j += divisor)%7B%0A                A%5Bj%5D = (int)((A%5Bj%5D * multiplier) %25 MOD);%0A            %7D%0A        %7D%0A        %0A        //OUTPUT%0A        StringBuffer sb = new StringBuffer();%0A        for(int i = 0; i %3C N; ++i)%7B%0A            sb.append(A%5Bi%5D + %22 %22);%0A        %7D%0A        System.out.print(sb);%0A    %7D%0A    private static int%5B%5D getArr(String%5B%5D strs)%7B%0A        final int N = strs.length;%0A        int%5B%5D arr = new int%5BN%5D;%0A        for(int i = 0; i %3C N; ++i)%7B%0A            arr%5Bi%5D = Integer.parseInt(strs%5Bi%5D);%0A        %7D%0A        return arr;%0A    %7D%0A%7D%0A

Create sherlock-and-queries.java