abstract contract ERC721EnumerableB is ERC721B, IERC721Enumerable {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721B) returns (bool) {
        return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256 tokenId) {
        require(index < ERC721B.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");

        uint count;
        uint length = _owners.length;
        for( uint i; i < length; ++i ){
            if( owner == _owners[i] ){
                if( count == index ){
                    delete count;
                    delete length;
                    return i;
                }
                else
                    ++count;
            }
        }

        delete count;
        delete length;
        require(false, "ERC721Enumerable: owner index out of bounds");
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _owners.length;
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721EnumerableB.totalSupply(), "ERC721Enumerable: global index out of bounds");
        return index;
    }
}
/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 */
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256 tokenId) {
    require(index < ERC721B.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");

    uint count;
    uint length = _owners.length;
    for( uint i; i < length; ++i ){
        if( owner == _owners[i] ){
            if( count == index ){
                delete count;
                delete length;
                return i;
            }
            else
                ++count;
        }
    }

    delete count;
    delete length;
    require(false, "ERC721Enumerable: owner index out of bounds");
}

/**
 * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
 */