def isSol(res):
    """
    Check if the string is of the type ai bj ck
    """
    if not res or res[0] != 'a' or res[-1] != 'c':
        return False

    l = 0
    r = len(res)-1

    while res[l] == "a":
            l+=1
    
    while res[r] == "c":
            r-=1
    
    if r-l+1 <= 0:
        return False
    
    for x in res[l:r-l+1]:
        if x != 'b':
            return False
    
    return True