#include using namespace std; #define int long long #define REP(i,m,n) for(int i=(m);i<(n);i++) #define rep(i,n) REP(i,0,n) #define pb push_back #define all(a) a.begin(),a.end() #define rall(c) (c).rbegin(),(c).rend() #define mp make_pair #define endl '\n' //#define vec vector //#define mat vector > #define fi first #define se second #define double long double typedef long long ll; typedef unsigned long long ull; typedef pair pll; //typedef long double ld; typedef complex Complex; const ll INF=1e9+7; const ll MOD=998244353; const ll inf=INF*INF; const ll mod=MOD; const ll MAX=3010; const double PI=acos(-1.0); typedef vector > mat; typedef vector vec; //gcd ll gcd(ll a,ll b){ if(b==0)return a; return gcd(b,a%b); } signed main(){ ll q;cin>>q; while(q--){ ll s,t; cin>>s>>t; ll x=s*s*16LL; if(x%t!=0){ cout<<0< >st; for(ll i=1;i*i*i<=x;i++){ if(x%i!=0)continue; if(t-i<=0||(t-i)%2!=0)continue; ll a=(t-i)/2; ll X=x; X/=(t-2LL*a); ll y=sqrt(t*t-2LL*(t-a)*t-X+(t-a)*(t-a)); if(t*t-2LL*(t-a)*t-X+(t-a)*(t-a)==y*y){ if((t-a+y)%2==0){ ll b=(t-a+y)/2LL; ll c=t-a-b; vectorz(3); z[0]=a,z[1]=b,z[2]=c; sort(all(z)); if(z[0]>0&&z[1]+z[0]>z[2]){ st.insert(z); } } if((t-a-y)%2==0){ ll b=(t-a-y)/2LL; ll c=t-a-b; vectorz(3); z[0]=a,z[1]=b,z[2]=c; sort(all(z)); if(z[0]>0&&z[1]+z[0]>z[2]){ st.insert(z); } } } } cout<