// yuki 1626 三角形の構築 // 2021.8.10 #include #include typedef long long ll; int ans[100][3], w; void check(int T, int a, int b) { if (b > 0) { int c = T-a-b; if (c > 0 && a >= b && a >= c) ans[w][0] = a, ans[w][1] = b, ans[w++][2] = c; } } int main() { int N, i, T, t, a; ll S; scanf("%d", &N); while (N--) { scanf("%lld%d", &S, &T); if (T & 1) { puts("0"); continue; } t = T >> 1; S *= S; if (S % t) { puts("0"); continue; } S /= t; int x = (int)(pow(S, 1.0/3)+1); w = 0; for (i = 1; i <= x; ++i) { if (S%i == 0 && (a = t-i) > 0) { ll aa = (ll)a*a - 4*(S/i); ll a2 = sqrt(aa); if (a2*a2 == aa && !((a-a2) & 1)) check(T, a, t-(a-a2)/2); } } printf("%d\n", w); for (i = 0; i < w; ++i) printf("%d %d %d\n", ans[i][0], ans[i][1], ans[i][2]); } return 0; }