#include using namespace std; typedef long long ll; #define mem(x,v) memset(x,v,sizeof(x)) #define Rep(i,a,b) for(register int i=(a);i<=int(b);++i) #define rep(i,a,b) for(register int i=(a);i=int(b);--i) #define gc getchar #define pc putchar #define fi first #define se second inline ll read(){ ll x=0,f=1;char c=gc(); for(;!isdigit(c);c=gc())if(c=='-')f=-1; for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48); return x*f; } inline void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');} inline void writeln(ll x){write(x);pc('\n');} inline void wri(ll x){write(x);pc(' ');} int vec[100000],T,n; void solve(){ n = read(); int r = 0,x = n; while(x){ r += x%10; x/=10; } *vec = 0; for(int i=1;i*i<=n;++i){ if(n%i==0){ if(r%i==0)vec[++*vec] = i; if(i*i!=n && r%(n/i)==0) vec[++*vec] = n/i; } } sort(vec+1,vec+1+*vec); writeln(*vec); Rep(i,1,*vec){ if(i!=*vec)wri(vec[i]); else writeln(vec[i]); } } int main(){ int T = read(); while(T--){ solve(); } return 0; }