read the first names from each file in name1, name2 and name3 while not (name1==name2 and name2==name3) { determine from which file came the name with the lowest alphabetical value read the next name from that file in the corresponding name1, name2, name3 variable } print name1, name2, name3