#include #include const long double eps = 1e-7; long double area_of_triangle(long long p, long long q, long long r) { if (p + q <= r) return 0.0; long double s; s = (p + q + r) / 2.0; return sqrtl(s * (s - p) * (s - q) * (s - r)); } void solve(long long S, long long T) { int i, j, k = 0, l, r, m; long long ans[10000][3]; for (i = 1; i * i <= S; i++) { if (S % i != 0) continue; l = i; r = (T - i) / 2; if (l <= r) { while (l < r) { m = (l + r) / 2; if (S - area_of_triangle(i, m, T - i - m) > eps) l = m + 1; else r = m; } if (fabsl(area_of_triangle(i, l, T - i - l) - S) < eps) { ans[k][0] = i; ans[k][1] = l; ans[k++][2] = T - i - l; } } i = S / i; l = i; r = (T - i) / 2; if (l <= r) { while (l < r) { m = (l + r) / 2; if (S - area_of_triangle(i, m, T - i - m) > eps) l = m + 1; else r = m; } if (fabsl(area_of_triangle(i, l, T - i - l) - S) < eps) { ans[k][0] = i; ans[k][1] = l; ans[k++][2] = T - i - l; } } i = S / i; } printf("%d\n", k); for (i = 0; i < k; i++) printf("%lld %lld %lld\n", ans[i][0], ans[i][1], ans[i][2]); } int main() { int i, t; long long S, T; scanf("%d", &t); for (i = 1; i <= t; i++) { scanf("%lld %lld", &S, &T); solve(S, T); } fflush(stdout); return 0; }