From LZ77 to the run-length encoded burrows-wheeler transform, and back