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: def solve(dic, cnt, n):
  if n < 10:
    return cnt

  if n in dic:
    return -1

  dic[n] = True

  s = str(n)
  max_score = 0
  for i in range(1, len(s)):
    a, b = int(s[:i]), int(s[i:])
    max_score = max(max_score, a * b)

  return solve(dic, cnt + 1, max_score)

q = int(input())
for _ in range(q):
  dic = dict()
  print(solve(dic, 0, int(input())))

Python: Q = int(input())
src = [int(input()) for i in range(Q)]
for n in src:
    ans = 0
    _n = n
    st = set()
    while _n >= 10:
        if _n in st:
            print(-1)
            break
        st.add(_n)
        s = str(_n)
        next = 0
        for i in range(1,len(s)):
            next = max(next, int(s[:i]) * int(s[i:]))
        _n = next
        ans += 1
    else:
        print(ans)

Python: #!/usr/bin/env python3
q = int(input())
for _ in range(q):
    n = input()
    for k in range(len(n)**2):
        if len(n) == 1:
            print(k)
            break
        n = str(max(int(n[:i]) * int(n[i:]) for i in range(1, len(n))))

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
        #    print(d)
            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(k)
            if k>=len(d):
                k=-1
            elif M==d[k]:
                c=-1
            d.insert(k,M)
            N=str(M)
            c+=1
        #    print(k)
    print(c)

Python: def solve(n):
    ans = 0
    mp = {}
    while (n >= 10):
        s = str(n)
        next = -1
        for i in range(1, len(s)):
            next = max(next, int(s[0:i])*int(s[i:]))
        if next in mp:
            ans = -1
            break
        mp[next] = True
        n = next
        ans += 1
    return ans


def main():
    q = int(input())
    for i in range(q):
        n = int(input())
        print(solve(n))


main()

Python: Q = int(input())

def solve(x,ans):
    X = str(x)
    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(ans,n)
        
    #print(ret)
    return solve(ret,ans + 1)

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

Python: from math import log10

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)

Python: import math
for _ in range(int(input())):
    n=int(input())
    c=0
    while n>9:
        c+=1
        n=max((n//(10**x))*(n%(10**x)) for x in range(1,int(math.log10(n))+1))
    print(c)

Python: #!/usr/bin/env python
# -*- coding: utf-8 -*-

Q = int(input())
N = [input() for i in range(0,Q)]

integer = lambda x: int(x) if x != '' else 0
for n in N:
    ans = '0' if int(n) // 10 == 0 else str(n)
    count = 0
    while int(ans) // 10 > 0:
        count += 1
        tmp = 0
        for i in range(1,len(ans)):
            tmp = max(tmp,integer(ans[:i]) * integer(ans[i:]))
        ans = str(tmp)
    else:
        print(count)

Python: trial = int(input())
for t in range(trial):
    targ = int(input())
    cnt = 0
    while True:
        if targ < 10:
            print(cnt)
            break
        else:
            maxtarg = 0
            for word in range(1,len(str(targ))):
                maxtarg = max( maxtarg , int(str(targ)[0:word]) * int(str(targ)[word:len(str(targ))]))
            targ = maxtarg
            cnt += 1

Python: from functools import reduce

g=lambda x,y:x*y
cv=lambda s:str(max([reduce(g,list(map(int,[s[:i],s[i:]]))) for i in range(1,len(s))]))

for _ in range(int(input())):
	c=0
	n=input()
	s=set()
	while 1:
		if len(n)==1:break
		if n in s:
			c=-1
			break
		s.add(n)
		n=cv(n)
		c+=1
	print(c)

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: "かけざん"
"最大のものを取得して、一桁になるまでに操作を行う回数を答える"


def kakezan(n):
    ret = 0
    str_n = str(n)
    digit_amount = len(str_n)
    for i in range(digit_amount-1):
        # print(str_n[:i+1])
        # print(str_n[i+1:])
        # print("")
        ret = max(ret, int(str_n[:i+1])*int(str_n[i+1:]))

    return ret


Q = int(input())  # 入力される整数の個数
N = [int(input()) for i in range(Q)]

for n in N:
    cnt = 0
    while n >= 10:
        n = kakezan((n))
        cnt += 1
    print(cnt)