Archaeologists have deciphered the hieroglyphs carved on the walls of a pyramid. One wall lists N sacred numbers. Every positive integer divisible by at least one of those N numbers is sacred as well.
The writings on M other walls say that the Qi-th smallest sacred number has magic properties. The archaeologists want to know which numbers those are.
You are given positive integers A1,A2,…,AN and positive integers Q1,Q2,…,QM. For each i, find the Qi-th smallest positive integer that is divisible by at least one of A1,A2,…,AN.