Module Module1 Sub Main() FileOpen(1, "DATA5.txt", OpenMode.Input) FileOpen(2, "OUT5.txt", OpenMode.Output) For i As Integer = 0 To 4 Dim input As Integer = CInt(LineInput(1)) Dim list(input - 1, 1) Dim out As String For b As Integer = 0 To input - 1 Dim tmp As String = LineInput(1) Dim tmp1() As String = Split(tmp, " ") list(b, 0) = tmp1(0) list(b, 1) = tmp1(1) Next Dim indi As Integer = 1 Dim s As Integer = 1 Dim size As Integer = 1 While s <> 9999 For c As Integer = 0 To input - 1 If list(c, 1) = s Then s = list(c, 0) If s = 1 Then Exit While End If size = size + 1 Exit For End If Next End While out = size PrintLine(2, out) Next FileClose(1) FileClose(2) End Sub End Module