// Contract: WantedCaptains
// Target function: function onERC721Received(address, address, uint256, bytes calldata) public virtual override returns (bytes4)
4a5926201d863aca033a84206be5496390ec86bbc26078e334a9a71f56232);
        addCaptainHash(4, 1, 0xe70fdeacc2eac206d4f4fab013972fd44acebabc9f819dac48945820207b49a9);
        addCaptainHash(4, 1, 0xfb5c27e47140214de418518ecda1426bf2f5fcd0026ff8cf15fda6c5c47053b5);
        addCaptainHash(5, 0, 0x45ef7b55c04a04d246986cf77c924430970df227bd3168f22236f69fe8847e4a);
        addCaptainHash(5, 0, 0x825b99e1cc0c21aee0bfc2cf7635da7ee1a5684052cf79ee365be888df5d5d38);
        addCaptainHash(5, 0, 0xddecb56ea7e10ef9aa69c029b3435ba9b61740ca18c631e008c75bc5491fa7f0);
        addCaptainHash(5, 0, 0xe09d6cb69d879094c5af9ba3d508644e4dabc444ea00563dc6d4b2f2a17e4b84);
        addCaptainHash(5, 1, 0x0a0982cad8007b35acb29d71dc32fe29a7314ec572a9b2ce5dec21543e1620ec);
        addCaptainHash(5, 1, 0x81a9c1a0362c2f33e5dbb95f7db9ebc22f323891e45fb2836af667c2450bc3cf);
        addCaptainHash(5, 1, 0xa026dcc4b6e60813b77590992846c344a1f211fcf9e03a15c6276b5b319ba66b);
        addCaptainHash(5, 1, 0xbc4106efe2a42daf1bd32897c6896cc55b645a09f221542e2ec6ca450464541d);
        addCaptainHash(6, 0, 0x1f1ca4e0b34dd94dc7167f0478bd3caf81e9c45a94e556bd536eaf6f3a536e03);
        addCaptainHash(6, 0, 0x748d65f80c99b91d117fcc25ef16d96a637ef902b20f8a88b37fe56d16aded3c);
        addCaptainHash(6, 0, 0x9c2de03dea37a58900375303f7999fa8540385f7e74e682a49916a2ccf4b6d19);
        addCaptainHash(6, 0, 0xfc5ca89c6ac1517741874abe7ff324f2b4ed6f7aaa1a0cddd60df0f66eb23daf);
        addCaptainHash(6, 1, 0x830b329f0930a256085276af2385335791fec77eb67c62bd876b02c40a509b42);
        addCaptainHash(6, 1, 0xa088a3c717bfc13f8f74caf5d5283bf1a7763032fe34f3f5ea4f24f69ea87448);
        addCaptainHash(6, 1, 0xad9c73536c378e3e5435a4026464e9be0edcef972fb2b084fc67886a3b4d95be);
        addCaptainHash(6, 1, 0xf099bec5fbba302ed6a6c76b670d89cdb28f4def1e85f40e5c88da1d7f583f01);
        addCaptainHash(7, 0, 0x060fce1231d27447aeb9ef672552547b530d9e4dca4c9ea9886ddff537468636);
        addCaptainHash(7, 0, 0x0f9e73137f3e06f27e41b3543058b0ae7cfa3f58c40040d39aa4ea4793020ea7);
        addCaptainHash(7, 0, 0x336f13867f2a56ceb3bb52e390adc0cd9af4e54ed06728566b58bd89bcf504f7);
        addCaptainHash(7, 0, 0x9ac48b7d145c8c012b86994f0f3e7413f59c23e40ac6d3a56a19320db0f9eade);
        addCaptainHash(7, 1, 0x188a047bb4b638514d685996b7a1d960348f40bab2069cdd3479d8d65ad6311e);
        addCaptainHash(7, 1, 0x47bd5c88b1d41a3594f33db4ad5fd5064df0d9fc45cbe7307b81b5640eb1b7e0);
        addCaptainHash(7, 1, 0x499b863e7349680c3d88985abbbba8e7913cca88b6c7ea2ccbbafdf197713ac4);
        addCaptainHash(7, 1, 0x7c033eb4f59dfbb3e99596e378c92289f496aa2b7508e2001fcf9c29bf2cf23d);
        addCaptainHash(8, 0, 0x1e06f5adeb6e400a18fceedb5d1c8be5950d9b4bac0722862330f369f04d6ddb);
        addCaptainHash(8, 0, 0x2add5e788382e40ec86f6ecbf70f992c4189b7627b1dbed97b3e36ef6d627775);
        addCaptainHash(8, 0, 0x3f064e31b4f641f509d3a85ca25a3f14c710c2c9fae4f44ee773c3a4d5cd79d4);
        addCaptainHash(8, 0, 0x91cef15bdfb7b00415e88eb026ea14189536ed9474ede30b86b1ad7cb143a988);
        addCaptainHash(8, 1, 0x199ee3d925ad5740f423878a176a9fbf5df85d1ed281a7faf7b9e796350e2e30);
        addCaptainHash(8, 1, 0x7465a645837f790e477fa456c8becf89ac4a260a1f33955023c92e2ea114d7f7);
        addCaptainHash(8, 1, 0x9c4e7d4041f3e62927d6beff375ffc221ebd0c114f08cfe844711cd7af1b1786);
        addCaptainHash(8, 1, 0xb943b8e5f184ce3583530dd5b29baab90ef613f724f5dfbd500118446b7ef9ec);
        addCaptainHash(9, 0, 0x315ccf86e8ab84368e40dd6fe320eb4f3f5cd894fce9e4be9e25f09fb3ceaf57);
        addCaptainHash(9, 0, 0x387af437796bcaf0ef6f8d43795722b18d53b113e1555505761b9a8176572c94);
        addCaptainHash(9, 0, 0xe8357c5095db9937b6fa5e115912d18d866fe620430f0a70f0fc6813a92969da);
        addCaptainHash(9, 0, 0xf35822d7cb1623312b971efffe26d6076d4d4ff072bcb6607d2ccd89c783e221);
        addCaptainHash(9, 1, 0x62318debc68a2edf055112cf49b193c28941981673c456f2e7b6de9b07880e9d);
        addCaptainHash(9, 1, 0xd414dbf7b8a7c7cda3f91ae61e3643b106a720d63f0106c89a3a71b6161d32d9);
        addCaptainHash(9, 1, 0xd6c8cb029b338c19aafd7a7c7c4c083ad62514818b04b3ce25ee52f725ce312d);
        addCaptainHash(9, 1, 0xf03b00dd758421a377cd3c6d87501c612c6fe72f802b94571c14eac88c8e7bc4);
        addCaptainHash(10, 0, 0x586b3d414063501cdd2717645b28edcb6bf5acecce41c2f0a889084e16bc7e8a);
        addCaptainHash(10, 0, 0x911b5637ff2800671311565968162cb0b56465b00d216a93a9b7d270cd83bf40);
        addCaptainHash(10, 0, 0xbb5d896b497cbf7a1fbfd44cc0550b0b4f3f78bdbca9845fa43faaae5fa78c6d);
        addCaptainHash(10, 0, 0xf26b6cc2d5030cfd2c8f808e5327e44b327256230f07c41a0d204fdb0b893ef5);
        addCaptainHash(10, 1, 0x1e751197b6d3008746d07ed38ef49f996aa2c9a124e8230a53ff3d671a5ea833);
        addCaptainHash(10, 1, 0x2ed60c891f5e896d59a639644dc998c916a7883f5936d59bdd63837a5278bc68);
        addCaptainHash(10, 1, 0x434868e943d0b4bfa483986e9a57f724274ecf0bbb983c65d8c91531eb998ce4);
        addCaptainHash(10, 1, 0xc50895fd991ab11910232cc0b0fd1bb4c3f860a1a0de4f7ad3c144014a8d3f79);
    }

    function setMainContract(address mainContractAddress) public onlyOwner {
        mainContract = IERC721(mainContractAddress);
    }
    
    function addCaptainHash(uint248 captainId, uint8 groupId, bytes32 hash) private {
        // GroupID should be 0 or 1
        uint256 index = (captainId * 10) + groupId;
        
        captainHashes[index].push(hash);
        captainValidHashes[index][hash] = true;
    }

    function getCaptainHashes(uint248 captainId, uint8 groupId) public view returns (bytes32[] memory) {
        require(groupId < 9, "Group ID should be lower than 10");
        uint256 index = (captainId * 10) + groupId;

        return captainHashes[index];
    }

    function isValidSecret(uint248 captainId, uint8 groupId, uint256 tokenId, bytes32 secret) public view returns (bool) {
        require(groupId < 2, "Group ID should be 0 or 1");
        uint256 index = (captainId * 10) + groupId;

        bytes32 hash = keccak256(abi.encodePacked(tokenId, secret));

        return captainValidHashes[index][hash];
    }

    function claim(uint256 captainId, uint256 tokenId_0, bytes32 secret_0, uint256 tokenId_1, bytes32 secret_1) public {
        require(!claimedCaptains[captainId], "captain already claimed");
        require(mainContract.ownerOf(tokenId_0) == _msgSender(), "no owner of tokenId_0");
        require(mainContract.ownerOf(tokenId_1) == _msgSender(), "no owner of tokenId_1");

        require(isValidSecret(uint248(captainId), 0, tokenId_0, secret_0), "tokenId is not member of group 0 for captainId");
        require(isValidSecret(uint248(captainId), 1, tokenId_1, secret_1), "tokenId is not member of group 1 for captainId");

        // Mark the captain as claimed to avoid reentracies
        claimedCaptains[captainId] = true;

        // Starts captain transfer to claimer
        mainContract.safeTransferFrom(address(this), _msgSender(), captainId);
    }