**Appendix A.**

In the following algorithms, "=" means "equals to" and "||" means "concatenation".
