Imports System Imports System.Collections.Generic Imports System.Collections.ArrayList Imports System.Collections Imports System.Collections.DictionaryBase Module Module1 Sub Main() FileOpen(1, "DATA3.txt", OpenMode.Input) FileOpen(2, "OUT3.txt", OpenMode.Output) For i As Integer = 0 To 4 Dim b As Integer = CInt(LineInput(1)) ' Dim list As New Dictionary(Of String, ArrayList) Dim keysn As Integer = 0 Dim keys(100) As String For c As Integer = 0 To b - 1 Dim inc() As String = Split(LineInput(1)) Dim al As New ArrayList Try list.Add(inc(0), al) list(inc(0)).Add(inc(1)) keys(keysn) = inc(0) keysn = keysn + 1 Catch ex As Exception list(inc(0)).Add(inc(1)) End Try Dim bl As New ArrayList Try list.Add(inc(1), bl) list(inc(1)).Add(inc(0)) keys(keysn) = inc(1) keysn = keysn + 1 Catch ex As Exception list(inc(1)).Add(inc(0)) End Try Next For cc As Integer = 0 To keysn - 1 Dim ccc As String = keys(cc) If ccc <> "1" Then If list(ccc).Contains("2") Then keys(cc) = "99999" End If For dd As Integer = 0 To list(ccc).Count - 1 If list(ccc)(dd) <> "1" Then If list(list(ccc)(dd)).Contains("2") Then keys(cc) = "99999" End If 'For ff As Integer = 0 To list(list(ccc)(dd)).Count - 1 ' If (list(list(ccc)(dd)))(ff) <> "1" Then ' If list((list(list(ccc)(dd)))(ff)).Contains("2") Then ' keys(cc) = "99999" ' End If ' End If 'Next End If Next End If Next Dim result As String = "a" For ee As Integer = 0 To keysn - 1 If keys(ee) <> "99999" And keys(ee) <> "2" And keys(ee) <> "1" And list("1").Contains(keys(ee)) Then result = result + keys(ee) + " " End If Next If result = "a" Then result = "none" Else result = result.Substring(1) End If PrintLine(2, result) Next End Sub End Module