def material_type(rec):
    """Determine material type for record (arg1). 
    
    Returns: 
    A string, one of BK (books), CF (computer files), MP
    (maps), MU (music), CR (continuing resource), VM (visual
    materials), MX (mixed materials)

    """
    l = rec[0]
    if l[2] in ('a', 't') and l[3] in ('a', 'c', 'd', 'm'):
        return 'BK'
    if l[2] == 'm':
        return 'CF'
    if l[2] in ('e', 'f'):
        return 'MP'
    if l[2] in ('c', 'd', 'i', 'j'):
        return 'MU'
    if l[2] == 'a' and l[3] in ('b', 'i', 's'):
        return 'CR'
    if l[2] in ('g', 'k', 'o', 'r'):
        return 'VM'
    if l[2] == 'p':
        return 'MX'
    raise ValueError
