I have a strange problem when tackling this problem in Java. The following two lines of code produce different output in the 4th test:
System.err.println(SI + " " + n);
System.out.println(SI + " " + n);
n is the index of a gateway that is connected to SI.
In the first three tests this works just fine, while in the last one, the stderr prints "35 28" and the stdout "18 26". Any ideas?