def bwt(s):
    
    assert  not in s and  not in s, 
    s =  + s +   
    table = sorted(s[i:] + s[:i] for i in range(len(s)))  
    last_column = [row[-1:] for row in table]  
    return .join(last_column)  


def ibwt(r):
    
    table = [] * len(r)  
    for i in range(len(r)):
        table = sorted(r[i] + table[i] for i in range(len(r)))  
    s = [row for row in table if row.endswith()][0]  
    return s.rstrip().strip()