// yuki 1626 三角形の構築 // 2021.8.10 #include #include typedef long long ll; int T, t; int ans[1000][3], w; void check(ll s, int k) { int i, x = sqrt(s); int a = t-k, b, c; for (i = k; i <= x; ++i) if (s % i == 0) { b = t-i, c = t - s/i; if (a+b+c == T) { ans[w][0] = a, ans[w][1] = b, ans[w++][2] = c; } } } int main() { int N, i; 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) { check(S/i, i); } 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; }