from decimal import Decimal, getcontext, ROUND_HALF_UP def main(): import sys input = sys.stdin.read().split() Q = int(input[0]) queries = input[1:Q+1] getcontext().prec = 30 # High precision to handle up to 15 decimal digits for p_str in queries: p = Decimal(p_str) # Step 1: Check if p is the square root of an integer e_candidate = (p ** 2).quantize(Decimal('1.'), rounding=ROUND_HALF_UP) sqrt_e = e_candidate.sqrt() error = abs(sqrt_e - p) if error <= Decimal('1e-10'): print(f"1 {int(e_candidate)}") else: # Use three terms as in the fourth sample print("3 10000000 15000000 20000000") if __name__ == "__main__": main()