Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()
	q := io.NextInt()
	for i := 0; i < q; i++ {
		io.Println(solve(io.NextInt()))
	}
}

func solve(n int) int {
	f := func(n int) int {
		max := 0
		for i := 10; ; i *= 10 {
			a := n / i
			b := n % i
			if a == 0 {
				break
			}
			max = intMax(a*b, max)
		}
		return max
	}

	cnt := 0
	for {
		if n < 10 {
			break
		}
		n = f(n)
		cnt++
	}

	return cnt
}

func intMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

C++: #include <cstdlib>
#include <iostream>
#include <map>
using namespace std;

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }

map<int, int> visited;
int dfs(int n) {
	if(n < 10)
		return 0;

	if(visited.count(n))
		return visited[n];

	visited[n] = -1;
	int next = 0;
	for(int i = 10; n / i; i *= 10) {
		int a = n / i;
		int b = n % i;
		chmax(next, a * b);
	}

	return visited[n] = dfs(next) + 1;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int q;
	cin >> q;

	for(int i = 0; i < q; ++i) {
		int n;
		cin >> n;

		cout << dfs(n) << endl;
	}

	return EXIT_SUCCESS;
}

C++: #include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <queue>
#include <map>
#include <stack>
using namespace std;

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};


int main() {
int r[8]={1,10,100,1000,10000,100000,1000000,10000000};

int q,n,ans;
cin>>q;
for(int z=0;z<q;z++){
ans=0;
cin>>n;
while(n>=10){
int m=0;
for(int i=1;i<7;i++){
if((n%(r[i]))*(n/(r[i]))>m) m=(n%(r[i]))*(n/(r[i]));

}
n=m;
ans++;


}
cout<<ans<<endl;

}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int Q;
int N[101];
int ct(int num){
    int cnt=0;
    while(num>9){
        num/=10;
        cnt++;
    }
    return cnt;
}
int eiei(int num){
    int rec=1;
    for(int i=0;i<num;i++) rec*=10;
    return rec;
}
int change(int num){
    int mx=0;
    for(int i=0;i<ct(num);i++){
        mx=max(mx,(num/eiei(i+1))*(num%eiei(i+1)));
    }
    return mx;
}
int ans(int num){
    int cnt=0;
    vector<int> vec;
    int rec=num;
    if(rec>9) cnt++;
    bool flag=true;
    while(flag){
        rec=change(rec);
        if(rec<10) break;
        cnt++;
        vec.push_back(rec);
        for(int i=0;i<vec.size();i++){
            for(int j=i+1;j<vec.size();j++){
                if(vec[i]==vec[j]){
                    cnt=-1;
                    flag=false;
                    break;
                }
            }
            if(!flag) break;
        }
    }
    
    return cnt;
}
int main(){
    cin>>Q;
    for(int i=0;i<Q;i++) cin>>N[i];
    
    for(int i=0;i<Q;i++){
        cout<<ans(N[i])<<endl;
    }
    
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long int ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back


int solve(int n){
    string s=to_string(n);
    
    int maxi=-1;
    rep(i,s.size()-1){
        int tmp;
        tmp=stoi( s.substr(0,i+1) ) * stoi( s.substr(i+1,s.size()-i) );
        maxi=max(maxi,tmp);
    }
    
    return maxi;
}

int main(){
    int abcde;
    cin>>abcde;
    rep(i,abcde){
        int n;
        cin>>n;
        
        int c=0;
        for(int i=0;i<1000000;i++){
            if(i==1000000-1)c=-1;
            
            if(n<10)break;
            n=solve(n);
            c++;
        }
        cout<<c<<endl;
    }
    
    return 0;
}