#include #define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++) const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; using namespace std; typedef long long ll; typedef vector vi; typedef vector vll; typedef pair pii; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; while (N--) { ll A, B; cin >> A >> B; if (A%10 == 0) { int cnt = 0; while (A) { A /= 10; cnt++; } cnt--; cout << 1 << " " << 0 << " " << cnt*B << endl; continue; } double p = B*log10(1.*A); int z = (int)p; p -= z; int q = 11; for (; q < 100; q++) { if (log10(1.*q)-1 > p) break; } q--; cout << q/10 << " " << q%10 << " " << z << endl; } return 0; }