def inspect_chain(chain):
    """Return whether a chain is 'GOOD' or 'BAD'."""
    next_key = chain.pop('BEGIN')
    while True:
        try:
            next_key = chain.pop(next_key)
            if next_key == "END":
                break
        except KeyError:
            return "BAD"

    if len(chain) > 0:
        return "BAD"
    return "GOOD"