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)
}

Python: import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    q = I()
    qi = 0

    while qi < q:
        qi += 1
        n = S()
        r = 0
        while len(n) > 1:
            r += 1
            t = 0
            for i in range(1,len(n)):
                u = int(n[:i]) * int(n[i:])
                if t < u:
                    t = u
            n = str(t)
        rr.append(r)

    return '\n'.join(map(str, rr))


print(main())

Python: import sys
# -*- coding: utf-8 -*-

def multiple(target,count):
    length = len(target)
    result = []
    if length == 1:
        return count
    for i in range(1,length):
        prefix = int(target[:i])
        suffix = int(target[i:])
        result.append(prefix*suffix)
    return multiple(str(max(result)), count+1)

count=int(input())
for i in range(count):
    print(multiple(input(),0))

Python: for i in range(int(input())):
    n = int(input())
    j = 0
    while n >= 10:
        L = [(n // (10**k)) * (n % (10**k))
             for k in range(1, int(log10(n)) + 1)]
        n = max(L)
        j += 1
    print(j)

C++: #include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt; scanf("%d", &kkt);

	while (kkt--) {
		ll N; scanf("%lld", &N);
		string s = to_string(N);
		ll res = 0;
		while (s.size() > 1) {
			ll tmp = 0;
			for (int i = 0; i < (ll)s.size() - 1; i++) {
				ll a = stoll(s.substr(0, i + 1));
				ll b = stoll(s.substr(i + 1, s.size()));
				chmax(tmp, a * b);
			}
			res++;
			s = to_string(tmp);
		}
		cout << res << "\n";
	}
	return 0;

}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cstdlib>
using namespace std;

string toString(int n) {
  char buff[128];
  sprintf(buff, "%d", n);
  return string(buff);
}

int main() {
  int Q;
  cin >> Q;
  while(Q--) {
    string N;
    cin >> N;

    int res;
    for(res = 0; N.size() != 1; ++res) {
      int maxi = -1;
      for(int i = 1; i < (int)N.size(); ++i) {
        string a = N.substr(0,i);
        string b = N.substr(i);
        int tmp = atoi(a.c_str()) * atoi(b.c_str());
        maxi = max(maxi, tmp);
      }
      N = toString(maxi);
    }

    cout << res << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
int e,n,c,k,i;
using namespace std;
int main() {
  cin>>e;
  while(e--){
    cin>>n;
    c=0;
    while(n>9){
      int m=0,b=1;
      for(c++,i=0;i<5;i++){
        b*=10;
        k=(n/b)*(n%b);
        if(k>m)m=k;
      }
      n=m;
    }
    cout<<c<<endl;
  }
}

C++: #include <iostream>
#include <math.h>
using namespace std;
int DivideMul(int N,int a){
  int L=N%(int)pow(10,a);
  int U=(N-L)/pow(10,a);
  return L*U;
}

int Next(int N){
  int n=10000000;
  int s=int( log(N)/log(10) );
  for(int i=1;i<s;++i){
      n=min(n,DivideMul(N,i));
  }
  return n;
}


int main(){
  int T;
  cin >> T;
  for(int i=0; i<T; ++i){
    
    int N;
    cin >> N;

    int j=0;
    for( j=0; N>9 ; j++){
      N=Next(N);
    }
   
    cout << j << endl;;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;

int solve(int x){
    int cnt = 0;
    set<int> st;
    while(x >= 10){
        if(st.count(x)==0) st.insert(x);
        else return -1;
        string s = to_string(x);
        int n = s.size();
        int ma = 0;
        for(int i=1;i<n;i++){
            int a = stoi(s.substr(0,i)), b = stoi(s.substr(i,n-i));
            ma = max(ma, a*b);
        }
        x = ma;
        cnt++;
    }
    return cnt;
}


int main() {
    int Q, N;
    cin >> Q;
    for(int i=0;i<Q;i++){
        cin >> N;
        cout << solve(N) << endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

typedef long long ll;

int solve(ll n)
{
    int cnt = 0;

    while (n / 10 != 0) {
        ll max_n = 0;

        for (int i = 10; n / i != 0; i *= 10) {
            ll tmp = (n / i) * (n % i);

            if (tmp > max_n)
                max_n = tmp;
        }
        n = max_n;
        cnt++;
    }

    return cnt;
}

int main()
{
    int q;

    cin >> q;
    while (q--) {
        ll n;

        cin >> n;
        cout << solve(n) << endl;
    }

    return 0;
}