def doi_prefix_to_naan(prefix_str, allow_lossy=False):
    """Convert the number after "10." in a DOI to a 1 letter + 4 digit string.
    E.g.: doi:10.5072/D9 -> 5072 -> b5072

    Should give same output as N2T doip2naan.d2n(

    Args:
        prefix_str (str, int): The number after "10." and before the slash in a DOI.
            E.g., 123 from doi:10.123/X.
        allow_lossy (bool): N2T doip2naan does not allow lossy conversions, and
            returns the original DOI if the prefix > 99999. When this flag is set to
            True, this function behaves in the same way.
    """
    n = int(prefix_str)
    last4_str = '{:04d}'.format(n)[-4:]
    if n < 10 ** 5:
        return 'bcdfghjkmn'[n // 10 ** 4] + last4_str
    if n < 10 ** 6:
        if allow_lossy:
            return ' pqrstvwxz'[n // 10 ** 5] + last4_str
        raise OverflowError('"{}" requires a lossy conversion'.format(prefix_str))
    raise OverflowError('"{}" is out of range'.format(prefix_str))