Temp codes
C++#include <bits/stdc++.h>
#if __linux__
#define ge getchar_unlocked
#define pu putchar_unlocked
#else
#define ge getchar
#define pu putchar
#endif
#define debug(x) cerr << #x << '=' << (x) << ' '
#define endl pu('\n')
#define sp pu(' ')
using namespace std;
typedef long long ll;
char ch;
template <typename T>
void read(T &x) {
x=0;
bool sgn=0;
while ('0'>ch||ch>'9') ch=ge(), sgn |= (ch=='-');
while ('0'<=ch&&ch<='9') {
x=x*10+ch-'0';
ch=ge();
}
if (sgn) x=-x;
}
template <typename T>
void write(T x) {
if (x<0) {
pu('-');
write<T>(-x);
return;
}
static int sta[110];
int top=0;
do {
sta[top++]=x%10, x/=10;
} while (x);
while (top) pu(sta[--top]+'0');
}
int t, cntn, cntm, cnts;
int n[4], m[4], s[4];
map<int, int> hasn, hasm, hass, hasgcd;
namespace xxs{
const int N = 1e6+5;
int prime[80000], cnt;
bool flag[N];
void xxs(){
for (int i=2;i<=N-3;i++){
if (!flag[i]){
prime[++cnt]=i;
}
for (int j=1;j<=cnt&&prime[j]*i<=N-3;j++){
flag[prime[j]*i]=1;
if (i%prime[j]==0) break;
}
}
}
void fj(int a[], map<int, int> b, int &cnta){
for (int i=1;i<=3;i++){
for (int j=1;j<=cnt;j++){
while (a[i]%prime[j]==0){
a[i]/=prime[j];
b[prime[j]]++;
}
}
}
}
}
void solve(){
read(n[1]), read(n[2]), read(n[3]);
read(m[1]), read(m[2]), read(m[3]);
read(s[1]), read(s[2]), read(s[3]);
xxs::fj(n, hasn, cntn);
xxs::fj(m, hasm, cntm);
xxs::fj(s, hass, cnts);
for (auto i:hasn){
if (hass[i.first]) hasgcd[i.first] = min(i.second, hass[i.first]);
}
}
int main(){
xxs::xxs();
read(t);
while (t--) solve();
}