import math template times*(n:int,body) = (for _ in 0.." .} proc scan(): int = while true: let k = getchar_unlocked() if k < '0': break result = 10 * result + k.ord - '0'.ord template put(n:int32) = putchar_unlocked("0123456789"[n]) proc putchar_unlocked(c:char){. importc:"putchar_unlocked",header: "" .} proc printInt(a:int) = if a == 0: putchar_unlocked('0') return var n = a var rev = a var cnt = 0 while rev mod 10 == 0: cnt += 1 rev = rev div 10 rev = 0 while n != 0: rev = rev * 10 + n mod 10 n = n div 10 while rev != 0: putchar_unlocked((rev mod 10 + '0'.ord).chr) rev = rev div 10 while cnt != 0: putchar_unlocked('0') cnt -= 1 scan().times: let a = scan() let b = scan() let xyz = b.float * log10(a.float) let z = xyz.int let xy = pow(10.0, xyz - z.float) let x = xy.int let y = (xy * 10).int mod 10 put(x.int32) putchar_unlocked(' ') put(y.int32) putchar_unlocked(' ') printInt(z) putchar_unlocked('\n') # b*(log(a)) == z * log10 + log(XY)