#K38887. Numbers with Three Distinct Prime Factors

    ID: 26298 Type: Default 1000ms 256MiB

Numbers with Three Distinct Prime Factors

Numbers with Three Distinct Prime Factors

Alice recently learned about prime numbers and she is fascinated by the behavior of composite numbers, especially those which can be expressed as a product of distinct primes. In this problem, you are asked to help Alice generate a sequence of numbers where each number has exactly three distinct prime factors. Formally, you are to find the first \(N\) numbers which have exactly three distinct prime factors.

Definition: A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. For the purpose of this problem, a number \(x\) is said to have exactly three distinct prime factors if there exist three distinct prime numbers \(p, q, r\) such that \(p \times q \times r\) divides \(x\) and no other distinct primes divide \(x\).

The sequence starts with 30 since \(30 = 2 \times 3 \times 5\) and it is the smallest number with exactly three distinct prime factors. Your task is to find subsequent numbers in the sequence.

inputFormat

The input is read from standard input (stdin) and is structured as follows:

  1. The first line contains an integer \(T\), the number of test cases.
  2. The following \(T\) lines each contain a single integer \(N\).

Each test case requires you to output the first \(N\) numbers in the sequence where every number has exactly three distinct prime factors.

outputFormat

For each test case, output a single line containing the first \(N\) numbers with exactly three distinct prime factors separated by a single space. The result for each test case should be printed on a new line.

## sample
2
3
5
30 42 60

30 42 60 66 70

</p>