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 sys
import math
Q = sys.stdin.readline()
for _ in range(int(Q)):
    cnt = 0
    N = int(sys.stdin.readline())
    if N != 0:
        digLeng = int(math.log10(N)) + 1
    else:
        digLeng = 1
    while digLeng > 1:
        Nmax = 0
        for dig in range(digLeng):
            lNum = N // int(math.pow(10,dig))
            rNum = N % int(math.pow(10,dig))
            Nmax = max(Nmax,lNum * rNum)
        N = Nmax
        cnt += 1
        if N != 0:
            digLeng = int(math.log10(N)) + 1
        else:
            digLeng = 1
    print(cnt)

Python: # your code goes here
#times volume24 2424
Q=int(input())
for i in range(Q):
    N=str(input())
    c=0
    while len(N)>1 and c<15:
        M=0
        for j in range(1,len(N)):
  #          print(N[:j])
            l=int(N[:j])
            r=int(N[j:])
            l*=r
            if M<l:
                M=l
        #    print(M)
        N=str(M)
        c+=1
  #  print(N)
    if c>=15:
        d=[int(N)]
        while len(N)>1 and c>=0 and c<50:
            M=0
            for j in range(1,len(N)):
      #          print(N[:j])
                l=int(N[:j])
                r=int(N[j:])
                l*=r
                if M<l:
                    M=l
    #        print(M)
            k=0
            while k<len(d) and M<d[k]:
                k+=1
       #     print(d)
            if k>=len(d):
                k=-1
            elif M==d[k]:
                c=-1
            d.insert(k,M)
            N=str(N)
      #      print(N)
    print(c)

Python: def proc(n):
    new = []
    n = str(n)
    for i in range(1, len(n)):
        new.append(int(n[:i]) * int(n[i:]))
    return max(new)

for _ in range(int(input())):
    ans = 0
    n = int(input())
    while(n > 9):
        n = proc(n)
        ans += 1
    print(ans)

Python: Q = int(input())

def solve(x,ans):
    #X = str(x)
#    print(x,ans)
    if len(x) == 1:
        print(ans)
        return
    ret= 0
    for i in range(1,len(x)):
        n = int(x[i:]) * int(x[:i])
        ret = max(ret , n)
        
    #print(ret)
    return solve(str(ret),ans + 1)

for i in range(Q):
    solve(input(),0)

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