#include #define int long long #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() using namespace std; templateistream&operator>>(istream&I,vector&v){for(auto&i:v)I>>i;return I;} templateostream&operator<<(ostream&O,vector&v){for(auto&i:v)O<>s; int n=s.size(); sort(all(s)); if(n<10){ int ans=0; do ans=__gcd(ans,stoll(s));while(next_permutation(all(s))); cout<>t; while(t--)AC::solve(); }