Donation

Company: Kotak_16oct

Difficulty: medium

Problem Statement

Donation Problem Description There are 10^9 people standing in a line, at positions 1, 2, ..., 10^9 . At the start nobody has any coins. You are given an integer K and Q donation queries. Each query has the form L R Y : Donate Y coins to every person standing at a position X with L <= X <= R . The queries are independent: each one simply adds coins, and the order in which they are performed does not matter. After all Q queries have been performed, find the positions (1-based) of the first K people, in increasing order of position, whose total number of coins is a prime number . A person with 0 or 1 coins does not count, because 0 and 1 are not prime. If fewer than K people have a prime number of coins, the answer is -1 . Write a function K_Prime(Q, queries, K) that returns the K positions in increasing order, or the single value -1 when fewer than K people qualify. Input Format The first line contains an integer T , the number of test cases. For each test case: The first line con