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: MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    q = int(input())
    power10 = [1]
    for i in range(7):
        power10.append(10*power10[-1])

    for _ in range(q):
        N = int(input())
        if N//10 == 0:
            print(0)
            continue

        visited = {N}
        cnt = 0
        while True:
            cnt += 1
            next_number = -1
            for i in range(1,len(str(N))):
                next_number = max(next_number,(N//power10[i])*(N%power10[i]))
            if next_number in visited:
                cnt = -1
                break
            if next_number//10 == 0:
                break
            else:
                visited.add(next_number)
                N = next_number

        print(cnt)        
if __name__ == '__main__':
    main()

Python: q = int(input())
for i in range(q):
    n = int(input())
    
    cnt = 0
    li = list()
    while n >= 10:
        cnt += 1
        di = 10
        ma = 0
        while di < n:
            l = n % di
            u = n // di
            ma = max(ma, l * u)
            di *= 10
        n = ma
        if ma in li:
            cnt = -1
            break
        li.append(ma)
    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 solve(N, cnt):
    if len(str(N)) == 1:
        return cnt
    sN = str(N)
    maxNum = 0
    for i in range(1, len(sN)):
        left = int(sN[0:i])
        right = int(sN[i:])
        maxNum = max(left * right, maxNum)
    ret = solve(maxNum, cnt + 1)
    return ret


Q = int(input())
for i in range(Q):
    N = int(input())
    ans = solve(N, 0)
    print(ans)

Python: #!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    f = [0]*10
    M = 1000000
    for n in range(10,M+1):
        k = str(n)
        m = 1
        for i in range(1,len(k)):
            nm = int(k[:i])*int(k[i:])
            if m < nm:
                m = nm
        f.append(f[m]+1)
    q = I()
    for i in range(q):
        print(f[I()])
    return

#Solve
if __name__ == "__main__":
    solve()

Python: import sys
import math
Q = sys.stdin.readline()
for _ in range(int(Q)):
    cnt = 0
    N = int(sys.stdin.readline())
    digLeng = int(math.log10(N)) + 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: import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

def main():
    Q = int(input())
    for _ in range(Q):
        n = input()
        count = 0
        while len(n) > 1:
            if count == 1000000:
                count = -1
                break
            tmp = 0
            for i in range(1,len(n)):
                tmp = max(tmp, int(n[:i])*int(n[i:]))
            count += 1
            n = str(tmp)
        print(count) 

if __name__ == '__main__':
    main()