from random import seed, randrange seed(123456) n = 1000000 a = "".join(['A' if randrange(2)==0 else 'N' for i in range(n)])