SELECT kods 
FROM Kuponi 
WHERE LENGTH(kods) = 6 AND kods REGEXP '^B*AB*AB*$';