Enter an original string with $ marker (e.g., banana$) for forward transform, or a BWT result with $ (e.g., annb$aa) for reverse transform.
Generate all rotations of the input string and sort them lexicographically.
Use the BWT string to reconstruct the original by building the sorted matrix and following arrows.