func main() var T: int :: cui@input().toInt(&) for(1, T) var ans: int :: 11 var S: []char :: cui@input() for i(0, ^S - 8) for j(i + 1, ^S - 7) do ans :: [ans, f(i, j, S)].min() end for end for do cui@print("\{ans}\n") end for func f(i: int, j: int, s: []char): int var res: int :: 0 for ii(0, 3) do res :+ s[i + ii] <> "good"[ii] ?(1, 0) end for for ii(0, 6) do res :+ s[j + ii] <> "problem"[ii] ?(1, 0) end for ret res end func end func