What order are they supposed to be printed in?
Have you tried debugging your program by printing out all the values of variables as they are generated and changed?
Maybe you would see what the...