<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def scrypt_mcf(scrypt, password, salt=None, N=SCRYPT_N, r=SCRYPT_r, p=SCRYPT_p, prefix=SCRYPT_MCF_PREFIX_DEFAULT):
 """Derives a Modular Crypt Format hash using the scrypt KDF given Expects the signature: scrypt(password, salt, N=SCRYPT_N, r=SCRYPT_r, p=SCRYPT_p, olen=64) If no salt is given, a random salt of 128+ bits is used. (Recommended.) """

    if isinstance(password, unicode):
        password = password.encode('utf8')
    elif not isinstance(password, bytes):
        raise TypeError('password must be a unicode or byte string')
    if salt is not None and not isinstance(salt, bytes):
        raise TypeError('salt must be a byte string')
    if salt is not None and not (1 <= len(salt) <= 16):
        raise ValueError('salt must be 1-16 bytes')
    if r > 255:
        raise ValueError('scrypt_mcf r out of range [1,255]')
    if p > 255:
        raise ValueError('scrypt_mcf p out of range [1,255]')
    if N > 2**31:
        raise ValueError('scrypt_mcf N out of range [2,2**31]')
    if b'\0' in password:
        raise ValueError('scrypt_mcf password must not contain zero bytes')

    if prefix == SCRYPT_MCF_PREFIX_s1:
        if salt is None:
            salt = os.urandom(16)
        hash = scrypt(password, salt, N, r, p)
        return _scrypt_mcf_encode_s1(N, r, p, salt, hash)
    elif prefix == SCRYPT_MCF_PREFIX_7 or prefix == SCRYPT_MCF_PREFIX_ANY:
        if salt is None:
            salt = os.urandom(32)
        salt = _cb64enc(salt)
        hash = scrypt(password, salt, N, r, p, 32)
        return _scrypt_mcf_encode_7(N, r, p, salt, hash)
    else:
        raise ValueError("Unrecognized MCF format")