Two strings A and B are equivalent (denoted by A∼B) if they have the same lengths and A can be transformed into B by performing the following operation zero or more times: c