everything works, although there's an unexpected error occuring when k=m=5 (at least in this example)