f=lambda s:all((x<y)^(y<z)for x,y,z in zip(s,s[1:],s[2:]))
for test in ("ABA","ABB","BAB","BUMP","BALD","BALDY","UPWARD","EXAMINATION","AZBYCXDWEVFUGTHSIRJQKPLOMN","AAA","BBA","ACE","THE","BUMPY","BALDING","ABCDEFGHIJKLMNOPQRSTUVWXYZ"):
print test, '-->', f(test)
Zj1sYW1iZGEgczphbGwoKHg8eSleKHk8eilmb3IgeCx5LHogaW4gemlwKHMsc1sxOl0sc1syOl0pKQoKZm9yIHRlc3QgaW4gKCJBQkEiLCJBQkIiLCJCQUIiLCJCVU1QIiwiQkFMRCIsIkJBTERZIiwiVVBXQVJEIiwiRVhBTUlOQVRJT04iLCJBWkJZQ1hEV0VWRlVHVEhTSVJKUUtQTE9NTiIsIkFBQSIsIkJCQSIsIkFDRSIsIlRIRSIsIkJVTVBZIiwiQkFMRElORyIsIkFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaIik6CglwcmludCB0ZXN0LCAnLS0+JywgZih0ZXN0KQ==