import math,algorithm 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 var P = newSeq[float](101) for i in 10..100: P[i] = log10(i.float / 10.0) scan().times: let a = scan() let b = scan() let xyz = b.float * log10(a.float) let z = xyz.int let p = xyz - z.float # 10^p == A => p*log10 = logA let i = P.upperBound(p) - 1 put(i.int32 div 10) putchar_unlocked(' ') put(i.int32 mod 10) putchar_unlocked(' ') printInt(z) putchar_unlocked('\n') # b*(log(a)) == z * log10 + log(XY)