$ cat lo_instance.txt 1 1 2 2 3 3 1 3 3 1 $ python3.6 lo_solver.py 5 < lo_instance.txt 0: 0 1 1: 0 4 2: 1 0 3: 1 1 4: 1 2 5: 1 3 6: 1 4 7: 2 1 8: 2 2 9: 2 4 10: 3 1 11: 3 3 12: 4 0 13: 4 1 14: 4 2 $ cat lo_instance_bad.txt 0 0 0 3 1 2 2 1 2 2 2 4 3 1 4 0 $ python3.6 lo_solver.py 5 < lo_instance_bad.txt 0: 0 2 1: 0 3 2: 0 4 3: 1 0 4: 1 1 5: 1 2 6: 2 1 7: 2 4 8: 3 1 9: 3 2 10: 3 3 11: 4 0 12: 4 2 There is no solution. Residual has non-zero entries at 0: 0 2 1: 4 1 (2 non-zero entries) $