Since you message in folder A depend on the messages in folder B you must generate the messages of B before A. Therefore B must be added before A.