formatted generator for p=5 case