system './' . $exe_name;

BEGIN {
	$source_name = 'my_tmp.cpp';
	$exe_name = $^O eq 'MSWin32' ? 'my_a.exe' : 'my_a.out';
	return if -e $exe_name;
	open my $fh, '>', $source_name;
	print $fh <<'CODE';
#line 9

#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <quadmath.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N;
	cin >> N;
	rep(ii, N) {
		int A, B;
		cin >> A >> B;
		__float128 t = log10q(__float128(A)) * B;
		ll Z = (ll)floorq(t);
		int XY = (int)floorq(powq(__float128(10), t - Z) * 10);
		printf("%d %d %lld\n", XY / 10, XY % 10, Z);
	}
	return 0;
}

CODE
	system "g++ -m64 -O2 -lm -march=native -std=c++11 -lquadmath $source_name -o $exe_name 2> my_compile.log";
	if($? != 0) {
		open(my $fh, '<', 'my_compile.log');
		while(<$fh>) { print STDERR $_; }
		die 'compile error';
	}
}