How to randomize the result of variable A & B to be unique

In reply to dave_59:

And Dave, the relative code are all here as above. I’m also very strange with the result.