#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 l[3], r[3], m, n; l[0] = 1; r[0] = T / 3; while (l[0] < r[0]) { m = (l[0] + r[0]) / 2; if (S - area_of_triangle(m, (T - m) / 2, (T - m + 1) / 2) > eps) l[0] = m + 1; else r[0] = m; } l[1] = 1; r[1] = T / 3; while (l[1] < r[1]) { m = (l[1] + r[1] + 1) / 2; n = m; if (m + n <= T - m - n) n = (T - m * 2) / 2 + 1; if (area_of_triangle(m, n, T - m - n) - S > eps) r[1] = m - 1; else l[1] = m; } int i, j, k = 0; long long ans[10000][3]; for (i = l[0]; i <= l[1]; i++) { if (S % i != 0) continue; l[2] = i; r[2] = (T - i) / 2; while (l[2] < r[2]) { m = (l[2] + r[2]) / 2; if (S - area_of_triangle(i, m, T - i - m) > eps) l[2] = m + 1; else r[2] = m; } if (fabsl(area_of_triangle(i, l[2], T - i - l[2]) - S) < eps) { ans[k][0] = i; ans[k][1] = l[2]; ans[k++][2] = T - i - l[2]; } } 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; }