Imports System.IO
Module Module1
Dim sw As StreamWriter = New StreamWriter("C:\Users\scvs\Desktop\out.txt")
Sub Main()
Dim sr As StreamReader = New StreamReader("C:\Users\scvs\Desktop\in.txt")
Dim a As Integer
a = Convert.ToInt32(sr.ReadLine)
For i = 1 To a
Dim ab As Integer
ab = Convert.ToInt32(sr.ReadLine)
sw.Write(ab)
sw.Write(" ")
If ab >= 25 Then
sw.WriteLine("0")
Else
danger(ab)
End If
Next
sw.Close()
End Sub
Private Sub danger(ByVal n As Integer)
Dim b As Integer
Dim i, k, w, j As Integer
Dim temp As Long = 1
For i = 1 To n
temp *= i
Dim str1 As String = ""
str1 = temp
Dim str2 As String = ""
str2 = Microsoft.VisualBasic.Right(str1, 6)
Dim str3 As Integer
For k = 1 To 6
str3 = Mid(str2, k, 1)
w = k
If str3 <> 0 Then Exit For
Next
Dim str4 As String = ""
str4 = Mid(str2, w, 7 - w)
b = Convert.ToInt32(str4)
j = j + b
Next
Dim kj As String = ""
Dim wh As String = ""
kj = Convert.ToString(j)
wh = kj
Dim str6 As String = ""
str6 = Microsoft.VisualBasic.Right(kj, 6)
For k = 1 To 6
kj = Mid(str6, k, 1)
w = k
If kj <> 0 Then Exit For
Next
Dim str5 As String = ""
str5 = Microsoft.VisualBasic.Right(wh, 7 - w)
'str5 = Mid(wh, w, 7 - w)
sw.WriteLine(str5)
End Sub