diff --git a/CMakePresets.json b/CMakePresets.json index 5c074df421..8fff29df28 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -33,7 +33,8 @@ "xmem_shim_test_controls", "startup_stub_xcrdapi", "startup_stub_xcrdapi_break_window_control", "xmem_run_break_readers_check", "xmem_run_break_readers_control", "xmem_cross_call_merge_check", "xmem_placeholder_split_check", "xmem_map_split_first_check", "startup_dstorage_break_window_check", - "xmem_page_runs_device_check", "linear_buffer_backing_check" + "xmem_page_runs_device_check", "linear_buffer_backing_check", + "bcpack_formats_check", "startup_stub_consumer" ] }, { "name": "release", "configurePreset": "release" }, @@ -47,7 +48,7 @@ "displayName": "Windows pull request smoke tests", "filter": { "include": { - "name": "^(desktop_root_signature|era_heap_(allocation|failure)|xmem_shim_mapped_pages|cpu_aot_fuzz_smoke|cpu_archive_texture_gpu_warp|dual_uav_warp|spirv_.*_warp|static_exe_intake|descriptor_heap_paging(_swapped)?_warp|startup_launch|startup_tools_lint|startup_gfx2hlsl_cvt_off_f32_i4_controls|startup_gfx2hlsl_sad_hi_msad_controls|startup_indirect_(dispatch|count_split|draw(_indexed)?|mesh(_xmem_arguments(_skip_wait)?)?|counts_control)_warp|startup_indirect_mesh_lease_warp_dual(-trace(-disabled)?)?|startup_shader_cache_key|startup_present_readback|xmem_(run_break_readers|cross_call_merge|placeholder_split|map_split_first)(_[a-z_]+)?|startup_dstorage_break_window(_[a-z_]+)?|xmem_page_runs_device(_join)?_warp|linear_buffer_backing_share_warp|startup_stage_package)$" + "name": "^(bcpack_all_formats(_golden_control)?|startup_bcpack_storage|desktop_root_signature|era_heap_(allocation|failure)|xmem_shim_mapped_pages|cpu_aot_fuzz_smoke|cpu_archive_texture_gpu_warp|dual_uav_warp|spirv_.*_warp|static_exe_intake|descriptor_heap_paging(_swapped)?_warp|startup_launch|startup_tools_lint|startup_gfx2hlsl_cvt_off_f32_i4_controls|startup_gfx2hlsl_sad_hi_msad_controls|startup_indirect_(dispatch|count_split|draw(_indexed)?|mesh(_xmem_arguments(_skip_wait)?)?|counts_control)_warp|startup_indirect_mesh_lease_warp_dual(-trace(-disabled)?)?|startup_shader_cache_key|startup_present_readback|xmem_(run_break_readers|cross_call_merge|placeholder_split|map_split_first)(_[a-z_]+)?|startup_dstorage_break_window(_[a-z_]+)?|xmem_page_runs_device(_join)?_warp|linear_buffer_backing_share_warp|startup_stage_package)$" } } }, diff --git a/README.md b/README.md index 1c26df1061..bd6b59850d 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ The control-flow CPU translator supports [source-built string memory transfers]( | CPU differential fuzz | Generate 20 deterministic leaf functions from seed `0xA902`, translate them, and compare native, default and `/O2` builds over 313 inputs each. | `ctest --preset dev --no-tests=error -R '^cpu_aot_fuzz_smoke$' -V` | | Script states | Reproduce a parent/child lookup, an ambiguous selection or a damaged sibling link with a synthetic tree. | `ctest --preset dev --no-tests=error -R '^script_(state_literals\|path_links)$' -V` | | Resource metadata | Check a [relocated resource root](docs/experiments.md#relocated-resource-root) against its block directory and type schema. | `ctest --preset dev --no-tests=error -R '^resource_relocated_root$' -V` | -| Texture recovery | [Decode MDU rANS symbols](docs/experiments.md#decoding-mdu-rans-symbol-streams) using [bcpack-rs by Ahmet Dedeler](https://github.com/Ahmet-Dedeler/bcpack-rs), or check a packed mip tail, a first refill byte, the fields of a generated BC7 block, or a resident mip drawn on the software adapter. [Look up a texture key across archives and inspect a matching descriptor](docs/experiments.md#reading-logical-ranges-and-probing-structured-resources). [Batch export TTPF textures with optional Rust kernels](docs/experiments.md#batch-export-ttpf-textures-to-dds). | `ctest --preset dev --no-tests=error -R '^(bcpack_prefix_and_mip_tail\|bcpack_rans_symbols\|bc7_block_reference\|bc7_draw_warp\|resource_range_controls)$' -V` | +| Texture recovery | [Check standalone BCPack BC1–BC7 reconstruction](docs/experiments/bcpack-standalone.md) or [decode MDU rANS symbols](docs/experiments.md#decoding-mdu-rans-symbol-streams) using [bcpack-rs by Ahmet Dedeler](https://github.com/Ahmet-Dedeler/bcpack-rs), or check a packed mip tail, a first refill byte, the fields of a generated BC7 block, or a resident mip drawn on the software adapter. [Look up a texture key across archives and inspect a matching descriptor](docs/experiments.md#reading-logical-ranges-and-probing-structured-resources). [Batch export TTPF textures with optional Rust kernels](docs/experiments.md#batch-export-ttpf-textures-to-dds). | `ctest --preset dev --no-tests=error -R '^(bcpack_all_formats\|startup_bcpack_storage\|bcpack_prefix_and_mip_tail\|bcpack_rans_symbols\|bc7_block_reference\|bc7_draw_warp\|resource_range_controls)$' -V` | | Audio metadata | Inventory stream counts, codec IDs and sample rates in a bounded [AWC sound-effect or music bank](docs/experiments.md#awc-sound-effect-format-metadata) with flag word `0xff000001` or `0xff020001`. | `ctest --preset dev --no-tests=error -R '^audio_awc_metadata$' -V` | | Compute shader recompilation | Translate fixed, indexed and row-pitch raw UAV stores for 1D, 2D and 3D thread groups, including an optional runtime constant buffer, and compare the complete buffer on D3D12. [Bindings and commands](docs/experiments.md#compute-uav-stores-from-a-native-container) · [Bounded gfx1030 DS lane routing](docs/experiments.md#bounded-gfx1030-ds-lane-routing) · [Private gfx1030 LDS access and updates, including 64-bit min/max and xor](docs/experiments.md#private-gfx1030-lds-word-access) | `ctest --preset dev --no-tests=error -R '^compute_store_aot_'` | | gfx1013 compute DPP16 | Lower `v_or_b32_dpp` with `quad_perm`, and `v_or_b32_dpp`/`v_add_nc_u32_dpp` with `row_shr:1`–`15` with or without `bound_ctrl`, under full row/bank masks; compare source-built fixtures with logical-thread references. Scope and limits: [quad_perm](docs/experiments.md#gfx1013-compute-dpp16-quad-permutation), [row_shr](docs/experiments.md#gfx1013-compute-dpp16-row-shift-right) | `ctest --preset dev --no-tests=error -R '^compute_store_aot_dpp_' -V` | diff --git a/docs/experiments.md b/docs/experiments.md index 5d92b84175..9d035f9d0e 100644 --- a/docs/experiments.md +++ b/docs/experiments.md @@ -12875,6 +12875,20 @@ mapping, archive stream discovery and rendered pixels remain separate work. The existing prefix probe keeps its diagnostic behavior. No local archive or texture payload is used by these checks. +### Standalone BCPack block reconstruction + +The startup DirectStorage stand-in reconstructs BC1–BC7 packed blocks without an +installed GDK or external table file. BC1's fitted endpoint window and quadrant +masks are removed; BC2 and BC6H now decode rather than report blank success. +See [the standalone implementation notes](experiments/bcpack-standalone.md) for +source provenance, synthetic golden checks, atomic storage tests, and optional +oracle reproduction commands. + +```powershell +cmake --build --preset dev --target bcpack_formats_check startup_stub_consumer startup_stub_xcrdapi +ctest --preset dev --no-tests=error -R '^(bcpack_all_formats|startup_bcpack_storage)' -V +``` + ### BCPack lane decoder paths The startup storage stand-in decodes BCPack streams with `decode_lanes` in diff --git a/docs/experiments/bcpack-standalone.md b/docs/experiments/bcpack-standalone.md new file mode 100644 index 0000000000..b2a5245758 --- /dev/null +++ b/docs/experiments/bcpack-standalone.md @@ -0,0 +1,133 @@ +# Standalone BCPack BC1–BC7 reconstruction + +`src/startup_stubs/bcpack_decoder.h` reconstructs the seven BC block formats from +complete BCPack streams. BC2 uses fifteen lanes and BC6H uses sixteen. BC1 now +uses independent endpoint/index references and the full 255-entry initial +dictionary. The old fitted BC1 endpoint window and quadrant masks are removed. +BC6H supports all fourteen modes and changes of precision/subset count across +historical references. The output is packed BC blocks, not RGBA pixels. + +The DirectStorage stand-in decodes into a temporary buffer and publishes it +only after the complete request succeeds. BC2/BC6H no longer return successful +blank textures. An invalid format or malformed stream fails. Existing file, +memory, outer RFC 1950 zlib and physical-page destination handling applies. +Historical `bcpack-blank` counters remain in the log schema for compatibility; +this decoder does not produce blank-success requests. + +## Sources and constants + +The entropy decoder and existing BC3/4/5/7 code retain their bcpack-rs and +silicon-rans notices in [THIRD_PARTY_NOTICES.md](../../tools/_bcpack_rans/THIRD_PARTY_NOTICES.md). +The new BC1/2/6H routines are original C++ reconstruction code. Research used +the installed GDK interface, local implementation inspection, and comparisons +with public bcpack-rs and VIctory implementations. This is not a claim of a +strict clean-room process. No GPL implementation or binary table blob was +copied into these files. + +`bcpack_tables_extra.inl` contains fixed format dictionaries and rank mappings. +They were reconstructed by sending chosen, entirely synthetic lane streams to +the developer oracle's `BCPackDecompress` API and reading the resulting standard +BC fields. There is no sample fitting, approximation, per-asset lookup or +run-time learning. The recovery tool does not read the DLL's data section. + +The BC6H wire descriptors adapt Microsoft's MIT-licensed +[DirectXTex BC6HBC7.cpp](https://github.com/microsoft/DirectXTex/blob/a8e5dbf42909aeeb9fcf9c2ae399ae3c06737379/DirectXTex/BC6HBC7.cpp), +revision `a8e5dbf42909aeeb9fcf9c2ae399ae3c06737379`, SHA-256 +`187434fab12351df0f875ae09390981034e8479159a6f4aaaf0904f007182b8a`. +The emitted BCPack blocks use ascending high base-endpoint bits in modes 13/14; +the descriptor generator applies that ordering explicitly. Preserve the +DirectXTex MIT notice when redistributing those descriptors. + +Normal builds, tests and runtime DLLs require neither GDK nor BCPack.dll. +The optional oracle target and script below are development tools only. They +require a separately installed developer oracle, which is not redistributed. + +## Reproduce the public checks + +From an x64 Visual Studio developer PowerShell: + +```powershell +. ./tools/dev.ps1 +cmake --preset dev +cmake --build --preset dev --target bcpack_formats_check startup_stub_consumer startup_stub_xcrdapi +ctest --preset dev --no-tests=error -R '^(bcpack_all_formats|startup_bcpack_storage)' -V +python -B tests/bcpack_tables_check.py +``` + +The golden test generates 12,330 synthetic streams from source. It checks all +255 initial references plus the zero predictor, independently selected endpoint +and index references, all fourteen BC6H modes and all 32 partitions. Random +symbol streams cover all seven formats and block counts 2, 17, 255, 256, 257 +and 1024, including mode changes and history-ring wrap. BC7 selects all 285 +mapped controls. Every supported entropy path must reproduce the same bytes. + +Each group is checked against a fixed FNV-1a-64 hash of the independent oracle's +complete output. The expected hashes are not generated by the decoder under +test. A one-byte mutation must fail the golden control. Truncation, wrong output +alignment, nonzero trailing data and invalid formats must fail with zero bytes +reported. An undefined BC6H mode must fail too. The storage test checks full BC2 +and BC6H destination bytes against fixed synthetic oracle outputs across +memory/file, raw/zlib and linear/cross-page requests. Missing page grants, unsupported formats and a bad final BC6H mode after +three valid blocks must preserve the destination; a following valid request +must still succeed. + +The unchanged `synthetic_11` BC1 input in `startup_stub_consumer.cpp` had 491 +wrong bytes in its former 512-byte expected output. Its first eight expected +bytes were `85 31 64 d5 af be ff bf`; the oracle returns +`8d 73 0a 07 ea b8 fa be`. The fixture now checks the oracle's complete 512 +bytes, keeping the original input, size and malformed-input controls. + +## Optional oracle reproduction + +For the original experiment the installed BCPack library reported version +`1.2603.3.0`. Its binaries, private headers and title payloads are not part of +this repository. Supply paths to your own local installation and to the public +DirectXTex source pinned above: + +```powershell +cmake --build --preset dev --target bcpack_oracle_bridge +./out/build/dev/bcpack_formats_check.exe --oracle 'C:/path/to/BCPack.dll' +python -B tools/bcpack_recover_constants.py ` + --sdk 'C:/path/to/BCPack.dll' ` + --bridge out/build/dev/bcpack_oracle_bridge.dll ` + --bc6-reference out/DirectXTex/DirectXTex/BC6HBC7.cpp ` + --output out/bcpack_tables_extra.inl ` + --storage-goldens out/bcpack_storage_goldens.h +python -c "from pathlib import Path; assert Path('src/startup_stubs/bcpack_tables_extra.inl').read_text() == Path('out/bcpack_tables_extra.inl').read_text()" +python -c "from pathlib import Path; assert Path('tests/bcpack_storage_goldens.h').read_text() == Path('out/bcpack_storage_goldens.h').read_text()" +``` + +The recovery script queries each dictionary entry separately. BC1/2 ranks are +recovered with zero predictors. BC6H's base endpoint uses the sixteen-bit mode; +the other endpoints use modes exposing their complete stored precision. The +generated table file reproduced LF-normalized SHA-256 +`181f279bbc84a3e93aa4d44bf6f7c6e522493b3a92538b7209e4b22721a3a12e`. +An oracle change may change output; investigate differences before replacing +goldens or format constants. + +## Local comparison and limits + +A separate read-only comparison covered 105,845 chunks from 45 local archive +pools, totaling 16,356,958,208 decoded bytes. Every chunk was compared byte for +byte with the installed oracle on the AVX2 path. A distributed sample of 882 +chunks also used the reference and scalar paths. There were no byte mismatches +or guard violations. No archive bytes or extracted textures are included here. + +| Format | Local archive chunks | +|---|---:| +| BC1 | 100,020 | +| BC2 | 0 | +| BC3 | 35 | +| BC4 | 77 | +| BC5 | 325 | +| BC6H | 268 | +| BC7 | 5,120 | + +An additional 312 oracle-compressed synthetic cases across BC1–BC7 matched +byte for byte on all three paths, including random, repeated and historical +blocks and individual BC6H/BC7 modes. Inputs rejected by the oracle compressor +were excluded from that successful-compression count, not called passes. +The public synthetic golden suite supplies BC2 coverage independently of the +local archives. These are packed-block decoding checks, not GPU image or +full-application startup measurements. Finite test coverage cannot establish +correctness for every possible stream. diff --git a/docs/startup-runtime.md b/docs/startup-runtime.md index a82fb4e1db..293b4c8d90 100644 --- a/docs/startup-runtime.md +++ b/docs/startup-runtime.md @@ -2847,7 +2847,7 @@ These are measured on one executable; treat them as hypotheses for others. `src/startup_stubs/logical_view_table.h` without a device. It covers the first and last records, one past the end, handles inside a record or below the heap, missing heap fields, memory that wraps past the top of the address space, and records crossing the end of a window. -- BCPack DirectStorage requests are decoded for BC7 and BC1 streams into destination memory as single atomic texture payloads; each request decompresses a complete multi-lane rANS chunk directly into its destination buffer and is excluded from chunk continuation caching. Unhandled formats fall back to zero-filled destinations. At process exit, one `x2w-dstorage BCPack summary` line reports request and zero-filled counts for every format 1..15 that was requested. The consumer fixture sends a format 6 request and checks that it succeeds, leaves a zero-filled destination, and appears in both counts; BC1 and BC7 requests must not be counted as zero-filled. +- BCPack DirectStorage requests decode BC1–BC7 complete multi-lane rANS payloads into temporary memory and publish only after success. They are excluded from continuation caching. BC2/BC6H now reconstruct packed blocks; invalid formats and damaged streams fail without publishing blank textures. BC1 uses independent endpoint/index history and exact format dictionaries; the fitted window and quadrant masks have been removed. File and memory sources, outer zlib and physical-page destinations share this path. Historical zero-filled counters remain in the summary log schema but are no longer incremented. [Implementation, synthetic fixtures and oracle reproduction](experiments/bcpack-standalone.md). - The XG stand-in normally uses desktop copyable footprints. Its opt-in BC7 diagnostic reports standard GFX10 4 KiB tiled geometry for a single-slice, single-mip, non-MSAA `BC7_UNORM` 2D texture with an unknown layout, default alignment, and no resource flags. diff --git a/src/startup_stubs/bcpack_blocks_extra.inl b/src/startup_stubs/bcpack_blocks_extra.inl new file mode 100644 index 0000000000..0ff5487be1 --- /dev/null +++ b/src/startup_stubs/bcpack_blocks_extra.inl @@ -0,0 +1,173 @@ +// Standalone BC1, BC2 and BC6H block reconstruction from BCPack lane symbols. +// SPDX-License-Identifier: MIT + +template +inline State bcpack_predictor(size_t block, size_t reference, const State (&history)[256], + const State (&dictionary)[Count]) { + if (reference == 0) return {}; + if (reference <= block) return history[(block - reference) & 255]; + const size_t index = reference - block - 1; + return index < Count ? dictionary[index] : State{}; +} + +inline void bcpack_quad(const uint8_t (&rank)[256][4], uint16_t symbol, size_t quadrant, + const uint8_t* predictor, uint8_t* positions) { + const size_t base = (quadrant >> 1) * 8 + (quadrant & 1) * 2; + constexpr size_t offsets[4] = {0, 1, 4, 5}; + for (size_t k = 0; k < 4; ++k) { + const size_t p = base + offsets[k]; + positions[p] = static_cast((predictor[p] + rank[symbol & 255][k]) & 3); + } +} + +inline bool decode_bc1_blocks(const std::vector& symbols, size_t blocks, + uint8_t* output, size_t capacity) { + if (blocks > capacity / 8 || blocks > symbols.size() / 12) return false; + constexpr uint8_t widths[6] = {5,6,5,5,6,5}; + Bc1FullState history[256] = {}; + for (size_t i = 0; i < blocks; ++i) { + // Lane 1 is the index distance. Lane 0 is a zigzag delta from it to + // the endpoint distance; they can select different historical blocks. + const size_t xr = symbols[blocks + i] & 255; + const size_t er = static_cast(static_cast(xr) + unzigzag(symbols[i])) & 255; + const auto ep = bcpack_predictor(i,er,history,BC1_FULL_DICTIONARY); + const auto ix = bcpack_predictor(i,xr,history,BC1_FULL_DICTIONARY); + Bc1FullState state{}; + for (size_t c = 0; c < 6; ++c) { + state.ep[c] = static_cast((ep.ep[c] + unzigzag(symbols[(2+c)*blocks+i])) & ((1u<& symbols, size_t blocks, + uint8_t* output, size_t capacity) { + if (blocks > capacity / 16 || blocks > symbols.size() / 30) return false; + const size_t target = blocks*2; + Bc2State history[256] = {}; + for (size_t i = 0; i < blocks; ++i) { + const uint8_t d = interleave(symbols[2*i],symbols[2*i+1]); + const size_t xr = interleave(symbols[target+2*i],symbols[target+2*i+1]); + const size_t er = static_cast(static_cast(xr)+unzigzag(d)) & 255; + const auto ep = bcpack_predictor(i,er,history,BC2_FULL_DICTIONARY); + const auto ix = bcpack_predictor(i,xr,history,BC2_FULL_DICTIONARY); + Bc2State state{}; + uint64_t alpha = 0; + for (size_t p = 0; p < 16; ++p) { + // BC2 stores explicit four-bit alpha, biased around eight. Its + // predictor follows endpoint history, independently of colour indices. + state.alpha[p] = static_cast((ep.alpha[p]+unzigzag(symbols[(2+p/2)*target+2*i+p%2])) & 15); + alpha |= static_cast(state.alpha[p]^8) << (4*p); + } + for (size_t c = 0; c < 3; ++c) { + const unsigned bits = c == 1 ? 6 : 5; + for (size_t e = 0; e < 2; ++e) { + state.ep[3*e+c] = static_cast((ep.ep[3*e+c]+unzigzag(symbols[(10+c)*target+2*i+e])) & ((1u<(((even>>bit)&1)<<(2*bit) | ((odd>>bit)&1)<<(2*bit+1)); + } + return value; +} + +inline uint16_t bcpack_add_aligned(uint16_t predictor, int32_t delta, unsigned shift) { + const uint32_t aligned = static_cast(static_cast(delta)) << shift; + return static_cast((predictor+aligned) & (0xffffu<((bit&1)<<(at%8)); +} + +inline bool decode_bc6_blocks(const std::vector& symbols, size_t blocks, + uint8_t* output, size_t capacity) { + if (blocks > capacity/16 || blocks > symbols.size()/32) return false; + const size_t target = blocks*2; + constexpr uint8_t codes[14] = {0,1,2,6,10,14,18,22,26,30,3,7,11,15}; + Bc6State history[256] = {}; + for (size_t i = 0; i < blocks; ++i) { + const unsigned mode = symbols[15*target+2*i]+1; + if (mode < 1 || mode > 14) return false; + const bool two = mode <= 10; + const unsigned part = symbols[15*target+2*i+1]&31; + const uint8_t d = interleave(symbols[2*i],symbols[2*i+1]); + const size_t xr = interleave(symbols[target+2*i],symbols[target+2*i+1]); + const size_t er = static_cast(static_cast(xr)+unzigzag(d)) & 255; + const auto ep = bcpack_predictor(i,er,history,BC6_DICTIONARY); + const auto ix = bcpack_predictor(i,xr,history,BC6_DICTIONARY); + Bc6State state{}; + // Keep signed/bias-centred values left aligned, so changing modes can + // reuse a predictor without confusing its original precision with this mode's. + for (size_t c = 0; c < 3; ++c) { + const unsigned s0 = 16-BC6_ENDPOINT_BITS[mode][0]; + const unsigned sc = 16-BC6_ENDPOINT_BITS[mode][c+1]; + const uint16_t v0 = bcpack_wide(symbols[(2+c)*target+2*i],symbols[(2+c)*target+2*i+1]); + const uint16_t v1 = bcpack_wide(symbols[(5+c)*target+2*i],symbols[(5+c)*target+2*i+1]); + state.ep[0][c] = bcpack_add_aligned(ep.ep[0][c],unzigzag(v0),s0); + state.ep[1][c] = bcpack_add_aligned(ep.ep[1][c],unzigzag(v1),sc); + if (two) { + state.ep[2][c] = bcpack_add_aligned(ep.ep[2][c],unzigzag(symbols[(8+c)*target+2*i]),sc); + state.ep[3][c] = bcpack_add_aligned(ep.ep[3][c],unzigzag(symbols[(8+c)*target+2*i+1]),sc); + } else { + // One-subset blocks still update the hidden second-subset + // history used by a later two-subset block. + state.ep[2][c] = static_cast((state.ep[0][c]>>s0)<(h) : static_cast(h); + uint16_t nibble = 0; + for (unsigned k = 0; k < 4; ++k) nibble |= ((v>>(2*k+parity))&1)<>shift; + } + bcpack_put_bit(block,at,value>>wire.bit); + } + size_t at = header; + const size_t anchor = two ? ANCHOR_2[part] : 0; + for (size_t p = 0; p < 16; ++p) { + const unsigned width = bits-static_cast(p == 0 || p == anchor); + const unsigned value = (state.ix[p]>>(16-bits))+(1u<<(bits-1)); + for (unsigned b = 0; b < width; ++b) bcpack_put_bit(block,at++,value>>b); + } + history[i&255] = state; + } + return true; +} diff --git a/src/startup_stubs/bcpack_decoder.h b/src/startup_stubs/bcpack_decoder.h index e255040f50..a279b804c5 100644 --- a/src/startup_stubs/bcpack_decoder.h +++ b/src/startup_stubs/bcpack_decoder.h @@ -2,6 +2,7 @@ // Adapted from bcpack-rs by Ahmet Dedeler (https://github.com/Ahmet-Dedeler, https://ahmetdedeler.com). // Source: https://github.com/Ahmet-Dedeler/bcpack-rs // SPDX-License-Identifier: MIT OR Apache-2.0 +// New BC1/2/6H reconstruction in bcpack_blocks_extra.inl is an original MIT contribution. // Incorporates rANS interval models derived from Microsoft silicon-rans (MIT License). #pragma once @@ -1119,48 +1120,6 @@ inline bool decode_bc7_blocks(const std::vector& symbols, size_t num_b return true; } -inline bool decode_bc1_blocks(const std::vector& symbols, size_t target, - uint8_t* output, size_t output_capacity) { - if (output_capacity < target * 8) return false; - const uint8_t ENDPOINT_WIDTHS[6] = { 5, 6, 5, 5, 6, 5 }; - uint8_t hist[256][6] = {}; - for (size_t i = 0; i < target; ++i) { - uint16_t l0_sym = symbols[0 * target + i]; - size_t v = l0_sym & 0xFF; - size_t d = (v & 1) ? (255 - (v >> 1)) : (v >> 1); - uint8_t pred[6] = {}; - if (d == 0) { - // zero - } else if (d <= i) { - std::memcpy(pred, hist[(i - d) & 255], 6); - } else { - size_t slot = (static_cast(i) - static_cast(d)) & 255; - std::memcpy(pred, BC1_WINDOW[slot], 6); - } - uint8_t e[6]; - for (int k = 0; k < 6; ++k) { - uint16_t sym = symbols[(2 + k) * target + i]; - int32_t res = unzigzag(sym); - uint32_t mask = (1u << ENDPOINT_WIDTHS[k]) - 1; - e[k] = static_cast((pred[k] + res) & mask); - } - std::memcpy(hist[i & 255], e, 6); - uint16_t c0 = (static_cast(e[0]) << 11) | (static_cast(e[1]) << 5) | e[2]; - uint16_t c1 = (static_cast(e[3]) << 11) | (static_cast(e[4]) << 5) | e[5]; - uint32_t idx0 = symbols[8 * target + i] & 0xFF; - uint32_t idx1 = symbols[9 * target + i] & 0xFF; - uint32_t idx2 = symbols[10 * target + i] & 0xFF; - uint32_t idx3 = symbols[11 * target + i] & 0xFF; - uint32_t w = BC1_QUAD_MASKS[0][idx0] | BC1_QUAD_MASKS[1][idx1] | - BC1_QUAD_MASKS[2][idx2] | BC1_QUAD_MASKS[3][idx3]; - uint8_t* blk = output + i * 8; - std::memcpy(blk + 0, &c0, 2); - std::memcpy(blk + 2, &c1, 2); - std::memcpy(blk + 4, &w, 4); - } - return true; -} - inline constexpr uint8_t ALPHA_CODE[8] = { 0, 2, 3, 4, 5, 6, 7, 1 }; inline constexpr uint8_t COLOUR_CODE[4] = { 0, 2, 3, 1 }; @@ -1419,83 +1378,46 @@ inline bool decode_bc3_blocks(const std::vector& symbols, size_t num_b return true; } +#include "bcpack_blocks_extra.inl" + inline bool decode_bcpack(const unsigned char* input, size_t input_size, unsigned bc_format, unsigned char* output, size_t output_size, size_t* produced) { - if (!input || !output || !produced) return false; - if (input_size == 0 || output_size == 0) return false; - - if (bc_format == 7) { - if (output_size % 16 != 0) return false; - size_t num_blocks = output_size / 16; - size_t target_per_lane = num_blocks * 2; - const uint8_t ab[16] = { 3, 3, 7, 7, 7, 7, 7, 6, 6, 4, 5, 7, 7, 7, 7, 4 }; - std::vector symbols; - if (!decode_lanes(input, input_size, ab, 16, target_per_lane, symbols)) { - return false; - } - if (!decode_bc7_blocks(symbols, num_blocks, output, output_size)) { - return false; - } - *produced = output_size; - return true; - } else if (bc_format == 1) { - if (output_size % 8 != 0) return false; - size_t num_blocks = output_size / 8; - size_t target_per_lane = num_blocks; - const uint8_t ab[12] = { 7, 7, 4, 5, 4, 4, 5, 4, 7, 7, 7, 7 }; - std::vector symbols; - if (!decode_lanes(input, input_size, ab, 12, target_per_lane, symbols)) { - return false; - } - if (!decode_bc1_blocks(symbols, num_blocks, output, output_size)) { - return false; - } - *produced = output_size; - return true; - } else if (bc_format == 4) { - if (output_size % 8 != 0) return false; - size_t num_blocks = output_size / 8; - size_t target_per_lane = num_blocks; - const uint8_t ab[12] = { 7, 7, 7, 7, 5, 5, 5, 5, 5, 5, 5, 5 }; - std::vector symbols; - if (!decode_lanes(input, input_size, ab, 12, target_per_lane, symbols)) { - return false; - } - if (!decode_bc4_blocks(symbols, num_blocks, output, output_size)) { - return false; - } - *produced = output_size; - return true; - } else if (bc_format == 5) { - if (output_size % 16 != 0) return false; - size_t num_blocks = output_size / 16; - size_t target_per_lane = num_blocks * 2; - const uint8_t ab[12] = { 3, 3, 7, 7, 5, 5, 5, 5, 5, 5, 5, 5 }; - std::vector symbols; - if (!decode_lanes(input, input_size, ab, 12, target_per_lane, symbols)) { - return false; - } - if (!decode_bc5_blocks(symbols, num_blocks, output, output_size)) { - return false; - } - *produced = output_size; - return true; - } else if (bc_format == 3) { - if (output_size % 16 != 0) return false; - size_t num_blocks = output_size / 16; - size_t target_per_lane = num_blocks * 2; - const uint8_t ab[12] = { 3, 3, 7, 5, 5, 5, 5, 4, 5, 4, 7, 7 }; - std::vector symbols; - if (!decode_lanes(input, input_size, ab, 12, target_per_lane, symbols)) { - return false; - } - if (!decode_bc3_blocks(symbols, num_blocks, output, output_size)) { - return false; - } - *produced = output_size; - return true; + if (!produced) return false; + *produced = 0; + if (!input || !output || input_size == 0 || output_size == 0 || + bc_format < 1 || bc_format > 7) return false; + + // Hardware alphabet indices, not literal symbol bit widths. + static constexpr uint8_t alphabets[7][16] = { + {7,7,4,5,4,4,5,4,7,7,7,7}, + {3,3,3,3,3,3,3,3,3,3,4,5,4,7,7}, + {3,3,7,5,5,5,5,4,5,4,7,7}, + {7,7,7,7,5,5,5,5,5,5,5,5}, + {3,3,7,7,5,5,5,5,5,5,5,5}, + {3,3,7,7,7,4,4,4,5,5,5,7,7,7,7,4}, + {3,3,7,7,7,7,7,6,6,4,5,7,7,7,7,4}, + }; + const size_t bytes_per_block = bc_format == 1 || bc_format == 4 ? 8 : 16; + if (output_size % bytes_per_block) return false; + const size_t blocks = output_size / bytes_per_block; + const size_t target = output_size / 8; + const size_t lanes = bc_format >= 6 ? 16 : bc_format == 2 ? 15 : 12; + std::vector symbols; + if (target > symbols.max_size() / lanes) return false; + if (!decode_lanes(input, input_size, alphabets[bc_format-1], lanes, target, symbols)) return false; + bool ok = false; + switch (bc_format) { + case 1: ok = decode_bc1_blocks(symbols,blocks,output,output_size); break; + case 2: ok = decode_bc2_blocks(symbols,blocks,output,output_size); break; + case 3: ok = decode_bc3_blocks(symbols,blocks,output,output_size); break; + case 4: ok = decode_bc4_blocks(symbols,blocks,output,output_size); break; + case 5: ok = decode_bc5_blocks(symbols,blocks,output,output_size); break; + case 6: ok = decode_bc6_blocks(symbols,blocks,output,output_size); break; + case 7: ok = decode_bc7_blocks(symbols,blocks,output,output_size); break; } - return false; + if (!ok) return false; + *produced = output_size; + return true; } } // namespace x2w_bcpack diff --git a/src/startup_stubs/bcpack_tables.h b/src/startup_stubs/bcpack_tables.h index 47f2d3d5b4..50dfd8e53d 100644 --- a/src/startup_stubs/bcpack_tables.h +++ b/src/startup_stubs/bcpack_tables.h @@ -1,6 +1,6 @@ // Generated BCPack model and codebook tables. -// Codebook, rank, and dictionary tables (BC7_CONTROL_TABLE, BC7_DICTIONARY, BC1_WINDOW, -// BC1_QUAD_MASKS, plus bcpack_tables_bcn.inl: RANK_PAIR_BC4, BC4_DICTIONARY, RANK_PAIR_BC5, +// Codebook, rank, and dictionary tables (BC7_CONTROL_TABLE, BC7_DICTIONARY, +// plus bcpack_tables_bcn.inl: RANK_PAIR_BC4, BC4_DICTIONARY, RANK_PAIR_BC5, // BC5_DICTIONARY, RANK_PAIR_BC3_ALPHA, RANK_QUAD_BC3_COLOUR, BC3_DICTIONARY) adapted // from bcpack-rs (pinned revision c55c5fad539644b8cf5a705051df214291763fc0) // by Ahmet Dedeler (https://github.com/Ahmet-Dedeler, https://ahmetdedeler.com). @@ -1623,404 +1623,7 @@ inline constexpr Bc7DictEntry BC7_DICTIONARY[255] = { { 0, { { 0x7f, 0x7f, 0x7e, 0x7e, 0x56, 0x3e, 0xfe, 0xfe }, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, { { 0x04, 0x04, 0x0a, 0x00, 0x0f, 0x04, 0x01, 0x01, 0x0b, 0x00, 0x0d, 0x0b, 0x0c, 0x0d, 0x0b, 0x04 }, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, }; -inline constexpr uint8_t BC1_WINDOW[256][6] = { - { 0, 0, 0, 0, 0, 0 }, - { 7, 29, 6, 8, 30, 7 }, - { 15, 29, 15, 16, 36, 17 }, - { 20, 37, 14, 3, 6, 2 }, - { 0, 0, 0, 0, 0, 0 }, - { 10, 21, 11, 6, 15, 7 }, - { 12, 23, 11, 7, 15, 6 }, - { 12, 26, 12, 7, 15, 7 }, - { 22, 36, 15, 20, 32, 14 }, - { 14, 23, 8, 1, 2, 1 }, - { 23, 5, 30, 9, 5, 30 }, - { 11, 22, 11, 7, 15, 7 }, - { 17, 22, 7, 10, 11, 3 }, - { 12, 25, 12, 7, 16, 7 }, - { 13, 28, 8, 5, 12, 3 }, - { 11, 20, 8, 16, 31, 14 }, - { 23, 32, 30, 17, 12, 29 }, - { 8, 44, 30, 6, 26, 30 }, - { 10, 24, 30, 6, 45, 30 }, - { 10, 12, 4, 8, 8, 2 }, - { 16, 23, 30, 14, 6, 26 }, - { 12, 25, 13, 10, 22, 12 }, - { 19, 27, 10, 13, 16, 5 }, - { 11, 24, 12, 4, 11, 6 }, - { 29, 60, 29, 6, 13, 6 }, - { 17, 31, 11, 1, 2, 1 }, - { 26, 54, 24, 12, 24, 10 }, - { 23, 48, 30, 20, 37, 30 }, - { 16, 23, 10, 10, 15, 6 }, - { 11, 24, 10, 6, 13, 5 }, - { 18, 52, 30, 14, 22, 30 }, - { 14, 51, 30, 9, 34, 30 }, - { 2, 3, 1, 19, 37, 16 }, - { 14, 15, 30, 10, 32, 30 }, - { 29, 57, 27, 27, 52, 25 }, - { 13, 29, 15, 8, 20, 11 }, - { 13, 17, 5, 9, 10, 3 }, - { 18, 50, 29, 15, 10, 29 }, - { 11, 25, 13, 8, 19, 10 }, - { 17, 31, 12, 6, 12, 4 }, - { 22, 18, 30, 19, 41, 30 }, - { 10, 22, 11, 8, 18, 9 }, - { 18, 30, 31, 10, 44, 30 }, - { 25, 50, 24, 2, 4, 1 }, - { 11, 30, 31, 7, 15, 29 }, - { 12, 19, 8, 11, 16, 7 }, - { 19, 29, 30, 14, 55, 28 }, - { 9, 20, 10, 4, 10, 5 }, - { 12, 23, 10, 7, 14, 5 }, - { 26, 53, 25, 6, 13, 6 }, - { 19, 27, 31, 11, 19, 30 }, - { 21, 31, 30, 22, 31, 30 }, - { 10, 19, 5, 11, 21, 6 }, - { 30, 50, 3, 29, 46, 2 }, - { 15, 9, 30, 7, 9, 30 }, - { 14, 18, 6, 11, 14, 4 }, - { 28, 56, 26, 4, 7, 3 }, - { 8, 20, 10, 6, 13, 7 }, - { 28, 58, 26, 15, 32, 14 }, - { 10, 19, 8, 7, 10, 4 }, - { 16, 22, 9, 13, 17, 7 }, - { 1, 2, 1, 14, 28, 12 }, - { 22, 45, 30, 9, 15, 30 }, - { 19, 22, 30, 16, 23, 31 }, - { 25, 50, 24, 21, 43, 20 }, - { 6, 11, 4, 16, 31, 13 }, - { 13, 25, 8, 3, 6, 1 }, - { 5, 9, 3, 12, 24, 10 }, - { 16, 29, 13, 8, 14, 6 }, - { 20, 37, 16, 13, 26, 10 }, - { 18, 35, 15, 5, 9, 3 }, - { 13, 25, 11, 7, 12, 5 }, - { 11, 21, 7, 7, 14, 4 }, - { 20, 39, 16, 11, 21, 8 }, - { 16, 31, 12, 4, 8, 2 }, - { 22, 41, 30, 18, 23, 30 }, - { 24, 50, 24, 9, 20, 8 }, - { 3, 12, 7, 4, 16, 8 }, - { 18, 27, 12, 16, 22, 10 }, - { 24, 49, 23, 13, 28, 12 }, - { 24, 49, 24, 18, 38, 18 }, - { 17, 32, 12, 14, 28, 9 }, - { 20, 10, 31, 13, 10, 31 }, - { 7, 8, 2, 5, 5, 1 }, - { 1, 2, 1, 10, 21, 9 }, - { 10, 18, 6, 1, 1, 0 }, - { 22, 46, 21, 1, 3, 1 }, - { 11, 20, 8, 8, 14, 5 }, - { 17, 35, 31, 14, 14, 29 }, - { 16, 22, 31, 12, 40, 31 }, - { 12, 22, 9, 8, 15, 6 }, - { 18, 15, 30, 15, 33, 31 }, - { 19, 32, 30, 15, 43, 31 }, - { 18, 35, 15, 8, 15, 5 }, - { 21, 43, 20, 18, 37, 17 }, - { 10, 17, 6, 9, 15, 6 }, - { 14, 27, 12, 7, 14, 5 }, - { 8, 15, 7, 12, 26, 11 }, - { 18, 37, 17, 1, 1, 0 }, - { 17, 45, 30, 15, 33, 31 }, - { 13, 24, 11, 8, 17, 7 }, - { 23, 47, 22, 16, 32, 15 }, - { 18, 33, 13, 11, 22, 8 }, - { 4, 10, 4, 8, 17, 7 }, - { 1, 2, 1, 3, 7, 3 }, - { 11, 22, 9, 6, 12, 4 }, - { 16, 28, 11, 13, 24, 9 }, - { 12, 24, 12, 7, 13, 6 }, - { 23, 47, 22, 7, 15, 6 }, - { 11, 32, 30, 11, 31, 30 }, - { 14, 26, 11, 10, 19, 7 }, - { 20, 41, 19, 1, 3, 1 }, - { 14, 27, 12, 8, 17, 6 }, - { 11, 21, 9, 8, 15, 6 }, - { 1, 2, 1, 7, 13, 6 }, - { 19, 34, 14, 16, 30, 12 }, - { 13, 27, 13, 7, 16, 7 }, - { 15, 32, 16, 8, 19, 9 }, - { 15, 42, 31, 11, 22, 30 }, - { 23, 48, 23, 5, 10, 4 }, - { 22, 45, 21, 11, 23, 10 }, - { 31, 62, 30, 31, 61, 29 }, - { 13, 26, 11, 5, 8, 3 }, - { 19, 39, 19, 9, 21, 10 }, - { 7, 14, 2, 6, 12, 2 }, - { 21, 42, 20, 4, 7, 3 }, - { 10, 17, 7, 8, 13, 5 }, - { 10, 22, 8, 11, 19, 7 }, - { 19, 33, 31, 12, 31, 31 }, - { 21, 43, 20, 5, 11, 5 }, - { 9, 21, 8, 8, 13, 7 }, - { 10, 21, 10, 6, 13, 6 }, - { 15, 29, 12, 11, 21, 8 }, - { 21, 43, 20, 9, 19, 8 }, - { 3, 8, 3, 5, 11, 5 }, - { 16, 31, 13, 9, 18, 7 }, - { 11, 21, 11, 6, 13, 6 }, - { 10, 21, 10, 7, 15, 7 }, - { 27, 3, 1, 26, 1, 0 }, - { 18, 37, 18, 16, 32, 16 }, - { 12, 23, 10, 9, 18, 7 }, - { 12, 25, 12, 8, 18, 8 }, - { 11, 20, 9, 2, 5, 1 }, - { 7, 15, 7, 8, 18, 9 }, - { 17, 33, 15, 13, 24, 11 }, - { 9, 19, 9, 7, 15, 7 }, - { 21, 43, 20, 13, 28, 12 }, - { 17, 36, 17, 2, 4, 2 }, - { 10, 19, 9, 6, 13, 5 }, - { 20, 41, 19, 7, 14, 7 }, - { 3, 9, 6, 2, 8, 5 }, - { 13, 24, 10, 11, 20, 8 }, - { 18, 39, 18, 6, 10, 5 }, - { 19, 38, 18, 8, 17, 8 }, - { 16, 35, 17, 4, 11, 4 }, - { 11, 23, 11, 10, 21, 10 }, - { 17, 36, 17, 7, 15, 7 }, - { 13, 27, 13, 7, 13, 7 }, - { 9, 15, 4, 8, 13, 4 }, - { 9, 19, 7, 6, 9, 3 }, - { 19, 39, 19, 11, 25, 11 }, - { 11, 23, 11, 8, 17, 8 }, - { 14, 29, 14, 7, 16, 7 }, - { 12, 22, 8, 5, 9, 4 }, - { 10, 20, 9, 8, 17, 8 }, - { 21, 41, 19, 15, 32, 14 }, - { 14, 28, 13, 1, 2, 0 }, - { 8, 16, 8, 7, 14, 7 }, - { 9, 18, 8, 8, 16, 7 }, - { 10, 17, 7, 3, 4, 1 }, - { 14, 28, 13, 2, 4, 1 }, - { 14, 30, 14, 3, 6, 3 }, - { 19, 38, 18, 5, 11, 5 }, - { 12, 26, 12, 1, 2, 1 }, - { 9, 16, 6, 8, 13, 5 }, - { 8, 13, 4, 7, 11, 4 }, - { 16, 35, 16, 4, 8, 4 }, - { 13, 28, 13, 4, 9, 4 }, - { 15, 31, 15, 6, 13, 6 }, - { 12, 24, 11, 9, 19, 9 }, - { 9, 19, 8, 7, 14, 6 }, - { 14, 28, 13, 5, 10, 4 }, - { 10, 21, 7, 4, 6, 2 }, - { 16, 34, 17, 11, 25, 12 }, - { 15, 30, 15, 8, 16, 8 }, - { 13, 27, 13, 10, 20, 10 }, - { 9, 20, 9, 0, 1, 0 }, - { 16, 32, 15, 2, 4, 2 }, - { 13, 27, 12, 3, 6, 3 }, - { 13, 26, 12, 12, 23, 11 }, - { 12, 25, 12, 5, 11, 5 }, - { 11, 23, 11, 5, 11, 5 }, - { 16, 34, 16, 7, 13, 6 }, - { 16, 35, 31, 15, 25, 31 }, - { 16, 33, 16, 7, 16, 7 }, - { 13, 26, 13, 8, 19, 8 }, - { 18, 35, 17, 11, 23, 10 }, - { 18, 36, 18, 13, 28, 13 }, - { 12, 25, 12, 4, 9, 4 }, - { 9, 18, 7, 6, 11, 4 }, - { 15, 30, 14, 9, 20, 9 }, - { 17, 35, 16, 9, 19, 9 }, - { 11, 24, 11, 2, 4, 2 }, - { 16, 33, 16, 0, 1, 0 }, - { 15, 31, 15, 4, 9, 4 }, - { 16, 31, 15, 14, 27, 13 }, - { 14, 29, 14, 13, 25, 12 }, - { 11, 23, 11, 3, 6, 3 }, - { 16, 32, 16, 10, 22, 10 }, - { 11, 22, 11, 4, 9, 4 }, - { 11, 22, 10, 1, 2, 0 }, - { 8, 14, 5, 2, 4, 1 }, - { 9, 16, 6, 6, 10, 4 }, - { 10, 21, 10, 9, 19, 9 }, - { 14, 29, 14, 11, 23, 11 }, - { 9, 18, 8, 6, 13, 6 }, - { 6, 13, 6, 5, 11, 5 }, - { 7, 14, 6, 0, 1, 0 }, - { 4, 7, 2, 3, 4, 1 }, - { 10, 20, 9, 4, 8, 4 }, - { 9, 17, 7, 5, 9, 3 }, - { 7, 14, 7, 1, 2, 1 }, - { 10, 20, 10, 6, 11, 5 }, - { 8, 15, 5, 4, 6, 2 }, - { 8, 17, 8, 1, 2, 1 }, - { 10, 20, 10, 3, 6, 3 }, - { 7, 10, 3, 6, 8, 3 }, - { 8, 15, 7, 6, 12, 6 }, - { 9, 19, 9, 2, 4, 2 }, - { 6, 11, 4, 3, 4, 1 }, - { 6, 11, 4, 0, 1, 0 }, - { 8, 16, 7, 2, 5, 2 }, - { 16, 34, 16, 15, 29, 15 }, - { 7, 16, 7, 5, 10, 5 }, - { 8, 14, 5, 5, 9, 3 }, - { 9, 18, 8, 4, 8, 4 }, - { 5, 9, 3, 4, 7, 2 }, - { 9, 18, 8, 5, 10, 5 }, - { 6, 12, 6, 2, 4, 2 }, - { 7, 12, 5, 4, 7, 3 }, - { 5, 11, 5, 1, 2, 1 }, - { 8, 17, 8, 3, 6, 3 }, - { 16, 31, 31, 16, 32, 31 }, - { 7, 14, 7, 3, 6, 3 }, - { 5, 11, 6, 4, 9, 4 }, - { 7, 15, 7, 4, 8, 4 }, - { 2, 4, 2, 0, 0, 1 }, - { 5, 11, 5, 3, 6, 3 }, - { 4, 8, 4, 1, 1, 1 }, - { 3, 6, 3, 1, 2, 1 }, - { 2, 4, 1, 1, 2, 1 }, - { 4, 8, 4, 3, 6, 3 }, - { 3, 6, 3, 2, 4, 2 }, - { 4, 9, 4, 2, 4, 2 }, - { 17, 27, 31, 15, 34, 31 }, - { 0, 0, 1, 0, 0, 0 }, -}; - -inline constexpr uint32_t BC1_QUAD_MASKS[4][256] = { - { - 0x00000a0au, 0x00000f0fu, 0x00000000u, 0x00000505u, 0x00000f0au, 0x00000a0fu, 0x00000f0bu, 0x00000b0fu, - 0x00000f0eu, 0x00000e0fu, 0x00000b0bu, 0x00000e0eu, 0x00000d0fu, 0x00000b0au, 0x0000050au, 0x00000a0eu, - 0x0000070fu, 0x00000e0au, 0x00000a0bu, 0x00000f07u, 0x00000f0du, 0x00000a05u, 0x0000050fu, 0x00000f05u, - 0x00000d0du, 0x00000707u, 0x00000606u, 0x00000909u, 0x0000020au, 0x0000080au, 0x00000a02u, 0x00000500u, - 0x00000005u, 0x00000a08u, 0x00000101u, 0x0000090au, 0x00000404u, 0x0000030fu, 0x00000a06u, 0x00000a09u, - 0x00000c0fu, 0x00000b0eu, 0x00000f0cu, 0x00000f03u, 0x0000060au, 0x00000e0bu, 0x0000070eu, 0x00000e07u, - 0x00000d0bu, 0x00000b0du, 0x0000070au, 0x00000a07u, 0x00000d0au, 0x0000000fu, 0x00000a0du, 0x00000507u, - 0x00000d05u, 0x0000000au, 0x0000050du, 0x00000705u, 0x0000020fu, 0x0000060eu, 0x00000f00u, 0x0000080fu, - 0x00000f08u, 0x00000e06u, 0x0000030du, 0x00000f02u, 0x00000b09u, 0x00000205u, 0x0000070cu, 0x0000090bu, - 0x0000030bu, 0x00000805u, 0x00000c0eu, 0x00000e0cu, 0x00000508u, 0x00000b03u, 0x00000d03u, 0x00000a00u, - 0x00000502u, 0x00000d0eu, 0x0000070bu, 0x0000020bu, 0x00000b07u, 0x0000050eu, 0x00000c07u, 0x00000e0du, - 0x0000050bu, 0x00000b02u, 0x0000080eu, 0x00000c0cu, 0x0000060fu, 0x00000109u, 0x00000f06u, 0x0000090fu, - 0x00000604u, 0x00000e08u, 0x00000e05u, 0x00000209u, 0x00000f09u, 0x00000303u, 0x00000406u, 0x00000202u, - 0x00000b05u, 0x00000d07u, 0x0000020du, 0x00000708u, 0x00000506u, 0x00000806u, 0x00000808u, 0x00000608u, - 0x00000901u, 0x00000905u, 0x00000902u, 0x00000d02u, 0x00000807u, 0x0000070du, 0x00000706u, 0x00000607u, - 0x0000090du, 0x00000509u, 0x00000605u, 0x00000d09u, 0x00000105u, 0x00000307u, 0x00000903u, 0x0000050cu, - 0x00000c06u, 0x00000305u, 0x0000060cu, 0x00000c0du, 0x00000309u, 0x00000405u, 0x00000d0cu, 0x00000504u, - 0x00000703u, 0x00000501u, 0x00000503u, 0x00000c05u, 0x0000020eu, 0x0000080bu, 0x0000080du, 0x00000207u, - 0x00000e02u, 0x0000010fu, 0x00000f04u, 0x0000010du, 0x00000d08u, 0x00000f01u, 0x00000702u, 0x00000a03u, - 0x0000040fu, 0x00000704u, 0x00000b08u, 0x00000c0au, 0x0000030au, 0x00000a0cu, 0x00000d01u, 0x00000809u, - 0x00000407u, 0x00000206u, 0x00000602u, 0x00000908u, 0x00000700u, 0x0000000du, 0x00000a01u, 0x0000010au, - 0x0000040au, 0x0000060bu, 0x0000010bu, 0x00000d00u, 0x00000a04u, 0x00000e09u, 0x00000007u, 0x00000b01u, - 0x0000090eu, 0x00000b06u, 0x00000e04u, 0x0000040eu, 0x00000b0cu, 0x00000e03u, 0x0000030eu, 0x00000c0bu, - 0x00000802u, 0x00000301u, 0x00000002u, 0x00000208u, 0x0000040cu, 0x00000103u, 0x00000c04u, 0x00000200u, - 0x0000000eu, 0x0000000bu, 0x00000008u, 0x00000906u, 0x00000800u, 0x00000e00u, 0x00000009u, 0x00000b00u, - 0x00000609u, 0x00000600u, 0x00000006u, 0x00000900u, 0x00000203u, 0x00000907u, 0x0000080cu, 0x00000d06u, - 0x00000201u, 0x0000060du, 0x00000709u, 0x00000302u, 0x00000c08u, 0x00000408u, 0x00000804u, 0x00000107u, - 0x00000102u, 0x00000d04u, 0x0000040du, 0x00000701u, 0x00000001u, 0x00000306u, 0x00000603u, 0x0000090cu, - 0x00000c09u, 0x00000400u, 0x00000004u, 0x00000100u, 0x00000e01u, 0x00000601u, 0x00000904u, 0x00000409u, - 0x0000040bu, 0x0000010eu, 0x00000b04u, 0x00000106u, 0x00000003u, 0x0000000cu, 0x00000c00u, 0x00000402u, - 0x00000801u, 0x00000108u, 0x00000300u, 0x00000204u, 0x00000c03u, 0x0000030cu, 0x00000c02u, 0x00000104u, - 0x00000401u, 0x00000803u, 0x0000020cu, 0x00000308u, 0x00000403u, 0x00000304u, 0x0000010cu, 0x00000c01u, - }, - { - 0x0000a0a0u, 0x0000f0f0u, 0x00000000u, 0x00005050u, 0x0000f0a0u, 0x0000a0f0u, 0x0000f0b0u, 0x0000b0f0u, - 0x0000f0e0u, 0x0000e0f0u, 0x0000b0b0u, 0x0000e0e0u, 0x0000d0f0u, 0x0000b0a0u, 0x000050a0u, 0x0000a0e0u, - 0x000070f0u, 0x0000e0a0u, 0x0000a0b0u, 0x0000f070u, 0x0000f0d0u, 0x0000a050u, 0x000050f0u, 0x0000f050u, - 0x0000d0d0u, 0x00007070u, 0x00006060u, 0x00009090u, 0x000020a0u, 0x000080a0u, 0x0000a020u, 0x00005000u, - 0x00000050u, 0x0000a080u, 0x00001010u, 0x000090a0u, 0x00004040u, 0x000030f0u, 0x0000a060u, 0x0000a090u, - 0x0000c0f0u, 0x0000b0e0u, 0x0000f0c0u, 0x0000f030u, 0x000060a0u, 0x0000e0b0u, 0x000070e0u, 0x0000e070u, - 0x0000d0b0u, 0x0000b0d0u, 0x000070a0u, 0x0000a070u, 0x0000d0a0u, 0x000000f0u, 0x0000a0d0u, 0x00005070u, - 0x0000d050u, 0x000000a0u, 0x000050d0u, 0x00007050u, 0x000020f0u, 0x000060e0u, 0x0000f000u, 0x000080f0u, - 0x0000f080u, 0x0000e060u, 0x000030d0u, 0x0000f020u, 0x0000b090u, 0x00002050u, 0x000070c0u, 0x000090b0u, - 0x000030b0u, 0x00008050u, 0x0000c0e0u, 0x0000e0c0u, 0x00005080u, 0x0000b030u, 0x0000d030u, 0x0000a000u, - 0x00005020u, 0x0000d0e0u, 0x000070b0u, 0x000020b0u, 0x0000b070u, 0x000050e0u, 0x0000c070u, 0x0000e0d0u, - 0x000050b0u, 0x0000b020u, 0x000080e0u, 0x0000c0c0u, 0x000060f0u, 0x00001090u, 0x0000f060u, 0x000090f0u, - 0x00006040u, 0x0000e080u, 0x0000e050u, 0x00002090u, 0x0000f090u, 0x00003030u, 0x00004060u, 0x00002020u, - 0x0000b050u, 0x0000d070u, 0x000020d0u, 0x00007080u, 0x00005060u, 0x00008060u, 0x00008080u, 0x00006080u, - 0x00009010u, 0x00009050u, 0x00009020u, 0x0000d020u, 0x00008070u, 0x000070d0u, 0x00007060u, 0x00006070u, - 0x000090d0u, 0x00005090u, 0x00006050u, 0x0000d090u, 0x00001050u, 0x00003070u, 0x00009030u, 0x000050c0u, - 0x0000c060u, 0x00003050u, 0x000060c0u, 0x0000c0d0u, 0x00003090u, 0x00004050u, 0x0000d0c0u, 0x00005040u, - 0x00007030u, 0x00005010u, 0x00005030u, 0x0000c050u, 0x000020e0u, 0x000080b0u, 0x000080d0u, 0x00002070u, - 0x0000e020u, 0x000010f0u, 0x0000f040u, 0x000010d0u, 0x0000d080u, 0x0000f010u, 0x00007020u, 0x0000a030u, - 0x000040f0u, 0x00007040u, 0x0000b080u, 0x0000c0a0u, 0x000030a0u, 0x0000a0c0u, 0x0000d010u, 0x00008090u, - 0x00004070u, 0x00002060u, 0x00006020u, 0x00009080u, 0x00007000u, 0x000000d0u, 0x0000a010u, 0x000010a0u, - 0x000040a0u, 0x000060b0u, 0x000010b0u, 0x0000d000u, 0x0000a040u, 0x0000e090u, 0x00000070u, 0x0000b010u, - 0x000090e0u, 0x0000b060u, 0x0000e040u, 0x000040e0u, 0x0000b0c0u, 0x0000e030u, 0x000030e0u, 0x0000c0b0u, - 0x00008020u, 0x00003010u, 0x00000020u, 0x00002080u, 0x000040c0u, 0x00001030u, 0x0000c040u, 0x00002000u, - 0x000000e0u, 0x000000b0u, 0x00000080u, 0x00009060u, 0x00008000u, 0x0000e000u, 0x00000090u, 0x0000b000u, - 0x00006090u, 0x00006000u, 0x00000060u, 0x00009000u, 0x00002030u, 0x00009070u, 0x000080c0u, 0x0000d060u, - 0x00002010u, 0x000060d0u, 0x00007090u, 0x00003020u, 0x0000c080u, 0x00004080u, 0x00008040u, 0x00001070u, - 0x00001020u, 0x0000d040u, 0x000040d0u, 0x00007010u, 0x00000010u, 0x00003060u, 0x00006030u, 0x000090c0u, - 0x0000c090u, 0x00004000u, 0x00000040u, 0x00001000u, 0x0000e010u, 0x00006010u, 0x00009040u, 0x00004090u, - 0x000040b0u, 0x000010e0u, 0x0000b040u, 0x00001060u, 0x00000030u, 0x000000c0u, 0x0000c000u, 0x00004020u, - 0x00008010u, 0x00001080u, 0x00003000u, 0x00002040u, 0x0000c030u, 0x000030c0u, 0x0000c020u, 0x00001040u, - 0x00004010u, 0x00008030u, 0x000020c0u, 0x00003080u, 0x00004030u, 0x00003040u, 0x000010c0u, 0x0000c010u, - }, - { - 0x0a0a0000u, 0x0f0f0000u, 0x00000000u, 0x05050000u, 0x0f0a0000u, 0x0a0f0000u, 0x0f0b0000u, 0x0b0f0000u, - 0x0f0e0000u, 0x0e0f0000u, 0x0b0b0000u, 0x0e0e0000u, 0x0d0f0000u, 0x0b0a0000u, 0x050a0000u, 0x0a0e0000u, - 0x070f0000u, 0x0e0a0000u, 0x0a0b0000u, 0x0f070000u, 0x0f0d0000u, 0x0a050000u, 0x050f0000u, 0x0f050000u, - 0x0d0d0000u, 0x07070000u, 0x06060000u, 0x09090000u, 0x020a0000u, 0x080a0000u, 0x0a020000u, 0x05000000u, - 0x00050000u, 0x0a080000u, 0x01010000u, 0x090a0000u, 0x04040000u, 0x030f0000u, 0x0a060000u, 0x0a090000u, - 0x0c0f0000u, 0x0b0e0000u, 0x0f0c0000u, 0x0f030000u, 0x060a0000u, 0x0e0b0000u, 0x070e0000u, 0x0e070000u, - 0x0d0b0000u, 0x0b0d0000u, 0x070a0000u, 0x0a070000u, 0x0d0a0000u, 0x000f0000u, 0x0a0d0000u, 0x05070000u, - 0x0d050000u, 0x000a0000u, 0x050d0000u, 0x07050000u, 0x020f0000u, 0x060e0000u, 0x0f000000u, 0x080f0000u, - 0x0f080000u, 0x0e060000u, 0x030d0000u, 0x0f020000u, 0x0b090000u, 0x02050000u, 0x070c0000u, 0x090b0000u, - 0x030b0000u, 0x08050000u, 0x0c0e0000u, 0x0e0c0000u, 0x05080000u, 0x0b030000u, 0x0d030000u, 0x0a000000u, - 0x05020000u, 0x0d0e0000u, 0x070b0000u, 0x020b0000u, 0x0b070000u, 0x050e0000u, 0x0c070000u, 0x0e0d0000u, - 0x050b0000u, 0x0b020000u, 0x080e0000u, 0x0c0c0000u, 0x060f0000u, 0x01090000u, 0x0f060000u, 0x090f0000u, - 0x06040000u, 0x0e080000u, 0x0e050000u, 0x02090000u, 0x0f090000u, 0x03030000u, 0x04060000u, 0x02020000u, - 0x0b050000u, 0x0d070000u, 0x020d0000u, 0x07080000u, 0x05060000u, 0x08060000u, 0x08080000u, 0x06080000u, - 0x09010000u, 0x09050000u, 0x09020000u, 0x0d020000u, 0x08070000u, 0x070d0000u, 0x07060000u, 0x06070000u, - 0x090d0000u, 0x05090000u, 0x06050000u, 0x0d090000u, 0x01050000u, 0x03070000u, 0x09030000u, 0x050c0000u, - 0x0c060000u, 0x03050000u, 0x060c0000u, 0x0c0d0000u, 0x03090000u, 0x04050000u, 0x0d0c0000u, 0x05040000u, - 0x07030000u, 0x05010000u, 0x05030000u, 0x0c050000u, 0x020e0000u, 0x080b0000u, 0x080d0000u, 0x02070000u, - 0x0e020000u, 0x010f0000u, 0x0f040000u, 0x010d0000u, 0x0d080000u, 0x0f010000u, 0x07020000u, 0x0a030000u, - 0x040f0000u, 0x07040000u, 0x0b080000u, 0x0c0a0000u, 0x030a0000u, 0x0a0c0000u, 0x0d010000u, 0x08090000u, - 0x04070000u, 0x02060000u, 0x06020000u, 0x09080000u, 0x07000000u, 0x000d0000u, 0x0a010000u, 0x010a0000u, - 0x040a0000u, 0x060b0000u, 0x010b0000u, 0x0d000000u, 0x0a040000u, 0x0e090000u, 0x00070000u, 0x0b010000u, - 0x090e0000u, 0x0b060000u, 0x0e040000u, 0x040e0000u, 0x0b0c0000u, 0x0e030000u, 0x030e0000u, 0x0c0b0000u, - 0x08020000u, 0x03010000u, 0x00020000u, 0x02080000u, 0x040c0000u, 0x01030000u, 0x0c040000u, 0x02000000u, - 0x000e0000u, 0x000b0000u, 0x00080000u, 0x09060000u, 0x08000000u, 0x0e000000u, 0x00090000u, 0x0b000000u, - 0x06090000u, 0x06000000u, 0x00060000u, 0x09000000u, 0x02030000u, 0x09070000u, 0x080c0000u, 0x0d060000u, - 0x02010000u, 0x060d0000u, 0x07090000u, 0x03020000u, 0x0c080000u, 0x04080000u, 0x08040000u, 0x01070000u, - 0x01020000u, 0x0d040000u, 0x040d0000u, 0x07010000u, 0x00010000u, 0x03060000u, 0x06030000u, 0x090c0000u, - 0x0c090000u, 0x04000000u, 0x00040000u, 0x01000000u, 0x0e010000u, 0x06010000u, 0x09040000u, 0x04090000u, - 0x040b0000u, 0x010e0000u, 0x0b040000u, 0x01060000u, 0x00030000u, 0x000c0000u, 0x0c000000u, 0x04020000u, - 0x08010000u, 0x01080000u, 0x03000000u, 0x02040000u, 0x0c030000u, 0x030c0000u, 0x0c020000u, 0x01040000u, - 0x04010000u, 0x08030000u, 0x020c0000u, 0x03080000u, 0x04030000u, 0x03040000u, 0x010c0000u, 0x0c010000u, - }, - { - 0xa0a00000u, 0xf0f00000u, 0x00000000u, 0x50500000u, 0xf0a00000u, 0xa0f00000u, 0xf0b00000u, 0xb0f00000u, - 0xf0e00000u, 0xe0f00000u, 0xb0b00000u, 0xe0e00000u, 0xd0f00000u, 0xb0a00000u, 0x50a00000u, 0xa0e00000u, - 0x70f00000u, 0xe0a00000u, 0xa0b00000u, 0xf0700000u, 0xf0d00000u, 0xa0500000u, 0x50f00000u, 0xf0500000u, - 0xd0d00000u, 0x70700000u, 0x60600000u, 0x90900000u, 0x20a00000u, 0x80a00000u, 0xa0200000u, 0x50000000u, - 0x00500000u, 0xa0800000u, 0x10100000u, 0x90a00000u, 0x40400000u, 0x30f00000u, 0xa0600000u, 0xa0900000u, - 0xc0f00000u, 0xb0e00000u, 0xf0c00000u, 0xf0300000u, 0x60a00000u, 0xe0b00000u, 0x70e00000u, 0xe0700000u, - 0xd0b00000u, 0xb0d00000u, 0x70a00000u, 0xa0700000u, 0xd0a00000u, 0x00f00000u, 0xa0d00000u, 0x50700000u, - 0xd0500000u, 0x00a00000u, 0x50d00000u, 0x70500000u, 0x20f00000u, 0x60e00000u, 0xf0000000u, 0x80f00000u, - 0xf0800000u, 0xe0600000u, 0x30d00000u, 0xf0200000u, 0xb0900000u, 0x20500000u, 0x70c00000u, 0x90b00000u, - 0x30b00000u, 0x80500000u, 0xc0e00000u, 0xe0c00000u, 0x50800000u, 0xb0300000u, 0xd0300000u, 0xa0000000u, - 0x50200000u, 0xd0e00000u, 0x70b00000u, 0x20b00000u, 0xb0700000u, 0x50e00000u, 0xc0700000u, 0xe0d00000u, - 0x50b00000u, 0xb0200000u, 0x80e00000u, 0xc0c00000u, 0x60f00000u, 0x10900000u, 0xf0600000u, 0x90f00000u, - 0x60400000u, 0xe0800000u, 0xe0500000u, 0x20900000u, 0xf0900000u, 0x30300000u, 0x40600000u, 0x20200000u, - 0xb0500000u, 0xd0700000u, 0x20d00000u, 0x70800000u, 0x50600000u, 0x80600000u, 0x80800000u, 0x60800000u, - 0x90100000u, 0x90500000u, 0x90200000u, 0xd0200000u, 0x80700000u, 0x70d00000u, 0x70600000u, 0x60700000u, - 0x90d00000u, 0x50900000u, 0x60500000u, 0xd0900000u, 0x10500000u, 0x30700000u, 0x90300000u, 0x50c00000u, - 0xc0600000u, 0x30500000u, 0x60c00000u, 0xc0d00000u, 0x30900000u, 0x40500000u, 0xd0c00000u, 0x50400000u, - 0x70300000u, 0x50100000u, 0x50300000u, 0xc0500000u, 0x20e00000u, 0x80b00000u, 0x80d00000u, 0x20700000u, - 0xe0200000u, 0x10f00000u, 0xf0400000u, 0x10d00000u, 0xd0800000u, 0xf0100000u, 0x70200000u, 0xa0300000u, - 0x40f00000u, 0x70400000u, 0xb0800000u, 0xc0a00000u, 0x30a00000u, 0xa0c00000u, 0xd0100000u, 0x80900000u, - 0x40700000u, 0x20600000u, 0x60200000u, 0x90800000u, 0x70000000u, 0x00d00000u, 0xa0100000u, 0x10a00000u, - 0x40a00000u, 0x60b00000u, 0x10b00000u, 0xd0000000u, 0xa0400000u, 0xe0900000u, 0x00700000u, 0xb0100000u, - 0x90e00000u, 0xb0600000u, 0xe0400000u, 0x40e00000u, 0xb0c00000u, 0xe0300000u, 0x30e00000u, 0xc0b00000u, - 0x80200000u, 0x30100000u, 0x00200000u, 0x20800000u, 0x40c00000u, 0x10300000u, 0xc0400000u, 0x20000000u, - 0x00e00000u, 0x00b00000u, 0x00800000u, 0x90600000u, 0x80000000u, 0xe0000000u, 0x00900000u, 0xb0000000u, - 0x60900000u, 0x60000000u, 0x00600000u, 0x90000000u, 0x20300000u, 0x90700000u, 0x80c00000u, 0xd0600000u, - 0x20100000u, 0x60d00000u, 0x70900000u, 0x30200000u, 0xc0800000u, 0x40800000u, 0x80400000u, 0x10700000u, - 0x10200000u, 0xd0400000u, 0x40d00000u, 0x70100000u, 0x00100000u, 0x30600000u, 0x60300000u, 0x90c00000u, - 0xc0900000u, 0x40000000u, 0x00400000u, 0x10000000u, 0xe0100000u, 0x60100000u, 0x90400000u, 0x40900000u, - 0x40b00000u, 0x10e00000u, 0xb0400000u, 0x10600000u, 0x00300000u, 0x00c00000u, 0xc0000000u, 0x40200000u, - 0x80100000u, 0x10800000u, 0x30000000u, 0x20400000u, 0xc0300000u, 0x30c00000u, 0xc0200000u, 0x10400000u, - 0x40100000u, 0x80300000u, 0x20c00000u, 0x30800000u, 0x40300000u, 0x30400000u, 0x10c00000u, 0xc0100000u, - }, -}; - #include "bcpack_tables_bcn.inl" +#include "bcpack_tables_extra.inl" } // namespace x2w_bcpack diff --git a/src/startup_stubs/bcpack_tables_extra.inl b/src/startup_stubs/bcpack_tables_extra.inl new file mode 100644 index 0000000000..6fcce900d0 --- /dev/null +++ b/src/startup_stubs/bcpack_tables_extra.inl @@ -0,0 +1,1470 @@ +// BCPack format constants reconstructed with synthetic lane streams. +// No SDK binaries or title data are embedded. See docs/experiments/bcpack-standalone.md. +// BC6H wire descriptors adapt the MIT-licensed Microsoft DirectXTex BC6HBC7.cpp. +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +struct Bc1FullState { uint8_t ep[6]; uint8_t ix[16]; }; +struct Bc2State { uint8_t alpha[16]; uint8_t ep[6]; uint8_t ix[16]; }; +struct Bc6State { uint16_t ep[4][3]; uint16_t ix[16]; }; +struct Bc6WireBit { uint8_t field; uint8_t bit; }; + +inline constexpr uint8_t BC1_POSITION_RANK[256][4] = { + { 1, 1, 1, 1 }, + { 2, 2, 2, 2 }, + { 0, 0, 0, 0 }, + { 3, 3, 3, 3 }, + { 1, 1, 2, 2 }, + { 2, 2, 1, 1 }, + { 2, 1, 2, 2 }, + { 2, 2, 2, 1 }, + { 1, 2, 2, 2 }, + { 2, 2, 1, 2 }, + { 2, 1, 2, 1 }, + { 1, 2, 1, 2 }, + { 2, 2, 3, 2 }, + { 1, 1, 2, 1 }, + { 1, 1, 3, 3 }, + { 1, 2, 1, 1 }, + { 2, 2, 2, 3 }, + { 1, 1, 1, 2 }, + { 2, 1, 1, 1 }, + { 2, 3, 2, 2 }, + { 3, 2, 2, 2 }, + { 3, 3, 1, 1 }, + { 2, 2, 3, 3 }, + { 3, 3, 2, 2 }, + { 3, 2, 3, 2 }, + { 2, 3, 2, 3 }, + { 1, 3, 1, 3 }, + { 3, 1, 3, 1 }, + { 1, 1, 1, 0 }, + { 1, 1, 0, 1 }, + { 1, 0, 1, 1 }, + { 0, 0, 3, 3 }, + { 3, 3, 0, 0 }, + { 0, 1, 1, 1 }, + { 3, 0, 3, 0 }, + { 1, 1, 3, 1 }, + { 0, 3, 0, 3 }, + { 2, 2, 2, 0 }, + { 1, 3, 1, 1 }, + { 3, 1, 1, 1 }, + { 2, 2, 0, 2 }, + { 1, 2, 2, 1 }, + { 0, 2, 2, 2 }, + { 2, 0, 2, 2 }, + { 1, 1, 1, 3 }, + { 2, 1, 1, 2 }, + { 1, 2, 2, 3 }, + { 2, 3, 1, 2 }, + { 2, 1, 3, 2 }, + { 3, 2, 2, 1 }, + { 1, 1, 2, 3 }, + { 2, 3, 1, 1 }, + { 1, 1, 3, 2 }, + { 2, 2, 0, 0 }, + { 3, 2, 1, 1 }, + { 2, 3, 3, 3 }, + { 3, 3, 3, 2 }, + { 1, 1, 0, 0 }, + { 3, 2, 3, 3 }, + { 3, 3, 2, 3 }, + { 2, 2, 1, 0 }, + { 1, 2, 1, 3 }, + { 0, 0, 2, 2 }, + { 2, 2, 0, 1 }, + { 0, 1, 2, 2 }, + { 1, 3, 1, 2 }, + { 3, 2, 2, 0 }, + { 1, 0, 2, 2 }, + { 3, 1, 2, 1 }, + { 3, 3, 1, 0 }, + { 0, 2, 2, 3 }, + { 2, 1, 3, 1 }, + { 2, 1, 2, 0 }, + { 3, 3, 0, 1 }, + { 1, 2, 0, 2 }, + { 0, 2, 1, 2 }, + { 0, 1, 3, 3 }, + { 2, 0, 2, 1 }, + { 2, 0, 3, 2 }, + { 0, 0, 1, 1 }, + { 1, 0, 3, 3 }, + { 1, 2, 3, 2 }, + { 2, 1, 2, 3 }, + { 2, 1, 1, 0 }, + { 2, 3, 2, 1 }, + { 1, 2, 3, 3 }, + { 2, 3, 0, 2 }, + { 3, 2, 1, 2 }, + { 2, 1, 3, 3 }, + { 1, 0, 2, 1 }, + { 1, 2, 0, 1 }, + { 0, 2, 0, 2 }, + { 2, 2, 1, 3 }, + { 3, 1, 3, 0 }, + { 1, 3, 2, 2 }, + { 2, 2, 3, 1 }, + { 0, 3, 1, 3 }, + { 0, 1, 1, 2 }, + { 3, 3, 1, 2 }, + { 3, 1, 1, 0 }, + { 3, 1, 2, 2 }, + { 2, 0, 2, 0 }, + { 1, 3, 0, 3 }, + { 1, 0, 1, 0 }, + { 3, 3, 2, 1 }, + { 2, 3, 3, 2 }, + { 3, 2, 1, 0 }, + { 0, 1, 2, 3 }, + { 1, 3, 3, 3 }, + { 1, 3, 0, 1 }, + { 0, 1, 0, 1 }, + { 0, 1, 1, 3 }, + { 3, 0, 3, 1 }, + { 3, 3, 3, 1 }, + { 1, 0, 3, 1 }, + { 1, 0, 3, 2 }, + { 2, 3, 0, 1 }, + { 3, 2, 2, 3 }, + { 1, 3, 2, 3 }, + { 2, 3, 1, 3 }, + { 3, 2, 3, 1 }, + { 3, 1, 3, 3 }, + { 3, 3, 1, 3 }, + { 3, 1, 3, 2 }, + { 3, 3, 3, 0 }, + { 2, 3, 2, 0 }, + { 2, 0, 3, 1 }, + { 0, 2, 3, 3 }, + { 1, 3, 0, 2 }, + { 3, 3, 2, 0 }, + { 0, 2, 1, 3 }, + { 3, 2, 0, 2 }, + { 3, 1, 2, 0 }, + { 3, 3, 0, 3 }, + { 0, 2, 3, 2 }, + { 0, 3, 3, 3 }, + { 2, 0, 2, 3 }, + { 3, 0, 3, 3 }, + { 2, 0, 3, 3 }, + { 3, 3, 0, 2 }, + { 1, 2, 1, 0 }, + { 2, 1, 0, 1 }, + { 3, 2, 0, 1 }, + { 2, 3, 1, 0 }, + { 1, 0, 1, 2 }, + { 2, 2, 3, 0 }, + { 0, 3, 2, 2 }, + { 3, 2, 3, 0 }, + { 0, 1, 3, 2 }, + { 3, 0, 2, 2 }, + { 1, 0, 2, 3 }, + { 2, 0, 1, 1 }, + { 2, 2, 0, 3 }, + { 0, 3, 2, 3 }, + { 0, 1, 2, 1 }, + { 1, 1, 0, 2 }, + { 1, 1, 2, 0 }, + { 0, 2, 1, 1 }, + { 3, 0, 3, 2 }, + { 3, 1, 0, 1 }, + { 2, 3, 0, 3 }, + { 1, 3, 1, 0 }, + { 1, 0, 1, 3 }, + { 0, 1, 3, 1 }, + { 0, 0, 2, 3 }, + { 3, 2, 0, 0 }, + { 3, 0, 1, 1 }, + { 1, 1, 3, 0 }, + { 1, 1, 0, 3 }, + { 2, 1, 1, 3 }, + { 2, 1, 3, 0 }, + { 0, 0, 3, 2 }, + { 0, 3, 1, 1 }, + { 3, 1, 1, 2 }, + { 2, 3, 0, 0 }, + { 3, 0, 2, 1 }, + { 1, 2, 3, 1 }, + { 1, 3, 2, 1 }, + { 0, 3, 1, 2 }, + { 1, 2, 0, 3 }, + { 0, 2, 2, 1 }, + { 2, 0, 1, 2 }, + { 1, 2, 2, 0 }, + { 2, 1, 0, 2 }, + { 1, 0, 0, 1 }, + { 3, 0, 2, 0 }, + { 1, 0, 0, 0 }, + { 0, 1, 1, 0 }, + { 0, 2, 0, 3 }, + { 2, 0, 3, 0 }, + { 0, 3, 0, 2 }, + { 0, 0, 1, 0 }, + { 1, 2, 0, 0 }, + { 2, 1, 0, 0 }, + { 0, 1, 0, 0 }, + { 1, 3, 3, 1 }, + { 0, 0, 0, 1 }, + { 0, 0, 1, 2 }, + { 3, 1, 0, 0 }, + { 0, 0, 2, 1 }, + { 3, 1, 1, 3 }, + { 0, 0, 1, 3 }, + { 1, 3, 0, 0 }, + { 0, 0, 3, 1 }, + { 2, 0, 1, 0 }, + { 2, 3, 3, 1 }, + { 0, 2, 0, 1 }, + { 1, 3, 3, 2 }, + { 3, 0, 1, 0 }, + { 3, 2, 1, 3 }, + { 3, 1, 2, 3 }, + { 1, 0, 2, 0 }, + { 0, 1, 0, 2 }, + { 0, 1, 0, 3 }, + { 0, 3, 0, 1 }, + { 2, 3, 3, 0 }, + { 1, 0, 3, 0 }, + { 0, 3, 3, 2 }, + { 3, 2, 0, 3 }, + { 3, 0, 2, 3 }, + { 3, 0, 0, 0 }, + { 1, 3, 2, 0 }, + { 2, 0, 1, 3 }, + { 0, 2, 3, 1 }, + { 3, 1, 0, 2 }, + { 0, 0, 0, 3 }, + { 0, 3, 0, 0 }, + { 0, 0, 3, 0 }, + { 3, 0, 1, 2 }, + { 1, 3, 3, 0 }, + { 0, 3, 3, 1 }, + { 3, 1, 0, 3 }, + { 2, 1, 0, 3 }, + { 1, 2, 3, 0 }, + { 0, 3, 2, 1 }, + { 3, 0, 1, 3 }, + { 2, 0, 0, 0 }, + { 0, 2, 0, 0 }, + { 0, 0, 0, 2 }, + { 1, 0, 0, 3 }, + { 3, 0, 0, 1 }, + { 0, 1, 3, 0 }, + { 0, 0, 2, 0 }, + { 0, 3, 1, 0 }, + { 2, 0, 0, 2 }, + { 0, 2, 2, 0 }, + { 1, 0, 0, 2 }, + { 3, 0, 0, 3 }, + { 0, 3, 3, 0 }, + { 2, 0, 0, 1 }, + { 0, 2, 1, 0 }, + { 0, 1, 2, 0 }, + { 2, 0, 0, 3 }, + { 0, 3, 2, 0 }, + { 0, 2, 3, 0 }, + { 3, 0, 0, 2 }, +}; + +inline constexpr Bc1FullState BC1_FULL_DICTIONARY[255] = { + { { 0, 0, 1, 0, 0, 0 }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } }, + { { 17, 27, 31, 15, 34, 31 }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 4, 9, 4, 2, 4, 2 }, { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 } }, + { { 3, 6, 3, 2, 4, 2 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { { 4, 8, 4, 3, 6, 3 }, { 1, 0, 3, 3, 1, 1, 0, 3, 1, 1, 0, 3, 0, 1, 0, 0 } }, + { { 2, 4, 1, 1, 2, 1 }, { 1, 0, 3, 3, 1, 1, 0, 3, 1, 1, 1, 1, 0, 1, 1, 1 } }, + { { 3, 6, 3, 1, 2, 1 }, { 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 3, 0, 0, 3, 3 } }, + { { 4, 8, 4, 1, 1, 1 }, { 3, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1 } }, + { { 5, 11, 5, 3, 6, 3 }, { 3, 3, 0, 1, 3, 3, 3, 0, 3, 2, 2, 3, 3, 2, 2, 3 } }, + { { 2, 4, 2, 0, 0, 1 }, { 3, 2, 2, 3, 0, 3, 3, 3, 1, 1, 0, 3, 0, 0, 0, 3 } }, + { { 7, 15, 7, 4, 8, 4 }, { 3, 0, 1, 1, 3, 0, 1, 1, 3, 0, 1, 1, 3, 0, 1, 1 } }, + { { 5, 11, 6, 4, 9, 4 }, { 3, 2, 2, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { { 7, 14, 7, 3, 6, 3 }, { 3, 0, 0, 3, 0, 0, 0, 3, 1, 1, 0, 3, 0, 0, 0, 3 } }, + { { 16, 31, 31, 16, 32, 31 }, { 3, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 3, 0, 0, 3, 3 } }, + { { 8, 17, 8, 3, 6, 3 }, { 0, 0, 0, 3, 0, 1, 0, 3, 0, 1, 0, 3, 0, 0, 0, 0 } }, + { { 5, 11, 5, 1, 2, 1 }, { 1, 0, 3, 3, 0, 3, 3, 3, 3, 2, 2, 3, 3, 2, 2, 3 } }, + { { 7, 12, 5, 4, 7, 3 }, { 3, 3, 0, 1, 3, 3, 3, 0, 3, 3, 3, 3, 0, 0, 3, 3 } }, + { { 6, 12, 6, 2, 4, 2 }, { 3, 3, 0, 1, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 9, 18, 8, 5, 10, 5 }, { 1, 1, 0, 3, 1, 1, 0, 3, 0, 1, 0, 3, 3, 0, 0, 3 } }, + { { 5, 9, 3, 4, 7, 2 }, { 0, 0, 0, 3, 0, 1, 0, 3, 0, 1, 0, 3, 0, 0, 0, 3 } }, + { { 9, 18, 8, 4, 8, 4 }, { 3, 2, 3, 3, 3, 3, 3, 0, 3, 3, 0, 1, 3, 0, 0, 0 } }, + { { 8, 14, 5, 5, 9, 3 }, { 1, 0, 3, 3, 1, 0, 3, 3, 1, 0, 3, 3, 1, 0, 0, 0 } }, + { { 7, 16, 7, 5, 10, 5 }, { 3, 3, 3, 3, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 } }, + { { 16, 34, 16, 15, 29, 15 }, { 3, 3, 2, 3, 0, 0, 3, 3, 1, 1, 0, 3, 0, 0, 0, 0 } }, + { { 8, 16, 7, 2, 4, 2 }, { 3, 2, 2, 3, 3, 3, 2, 3, 0, 3, 3, 3, 1, 0, 0, 3 } }, + { { 6, 11, 4, 0, 1, 0 }, { 1, 1, 0, 3, 1, 1, 0, 3, 1, 1, 0, 3, 1, 0, 0, 3 } }, + { { 6, 11, 4, 3, 4, 1 }, { 3, 0, 1, 1, 3, 0, 1, 1, 3, 3, 0, 0, 3, 3, 0, 0 } }, + { { 9, 19, 9, 2, 4, 2 }, { 3, 3, 0, 1, 3, 3, 0, 1, 3, 0, 0, 0, 0, 0, 0, 0 } }, + { { 8, 15, 7, 6, 12, 6 }, { 1, 0, 3, 3, 1, 1, 3, 3, 1, 1, 3, 3, 1, 1, 3, 3 } }, + { { 7, 10, 3, 6, 8, 3 }, { 3, 3, 3, 3, 0, 0, 3, 3, 0, 1, 0, 3, 0, 0, 0, 3 } }, + { { 10, 20, 10, 3, 6, 3 }, { 3, 3, 0, 1, 3, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0 } }, + { { 8, 17, 8, 1, 2, 1 }, { 3, 2, 2, 3, 3, 3, 3, 3, 0, 1, 0, 3, 0, 0, 0, 0 } }, + { { 8, 15, 5, 4, 6, 2 }, { 1, 1, 0, 3, 0, 3, 3, 3, 3, 2, 2, 3, 2, 2, 2, 3 } }, + { { 10, 20, 10, 5, 10, 5 }, { 3, 3, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0 } }, + { { 7, 14, 7, 1, 2, 1 }, { 0, 0, 0, 3, 1, 1, 0, 3, 1, 1, 0, 3, 0, 0, 0, 3 } }, + { { 9, 17, 7, 5, 9, 3 }, { 1, 1, 1, 1, 0, 0, 1, 1, 3, 3, 0, 1, 3, 3, 0, 1 } }, + { { 10, 20, 9, 4, 8, 4 }, { 3, 3, 3, 3, 3, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 } }, + { { 4, 7, 2, 3, 4, 1 }, { 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0 } }, + { { 7, 14, 6, 0, 1, 0 }, { 3, 0, 1, 1, 3, 0, 0, 0, 3, 3, 3, 3, 3, 3, 2, 2 } }, + { { 6, 13, 6, 5, 11, 5 }, { 3, 0, 0, 3, 3, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1 } }, + { { 9, 18, 8, 6, 13, 6 }, { 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 3, 0, 0, 0, 3 } }, + { { 14, 30, 14, 11, 22, 11 }, { 3, 3, 0, 1, 3, 2, 3, 0, 3, 3, 3, 3, 0, 0, 0, 3 } }, + { { 10, 21, 10, 9, 19, 9 }, { 1, 1, 0, 3, 1, 1, 0, 3, 0, 0, 0, 3, 3, 3, 3, 3 } }, + { { 9, 16, 6, 6, 10, 4 }, { 3, 3, 3, 3, 3, 3, 3, 3, 0, 1, 0, 0, 0, 0, 0, 0 } }, + { { 8, 14, 5, 2, 4, 1 }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 3, 0, 1, 1 } }, + { { 11, 22, 10, 1, 2, 0 }, { 1, 0, 3, 3, 1, 0, 3, 3, 1, 0, 3, 3, 1, 0, 3, 3 } }, + { { 11, 22, 11, 4, 9, 4 }, { 1, 1, 1, 1, 0, 3, 3, 3, 3, 3, 2, 3, 0, 3, 3, 3 } }, + { { 16, 32, 16, 10, 21, 10 }, { 1, 0, 3, 3, 1, 0, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3 } }, + { { 11, 23, 11, 3, 6, 3 }, { 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { { 14, 29, 14, 13, 25, 12 }, { 3, 3, 0, 1, 3, 3, 0, 1, 3, 3, 0, 1, 3, 0, 0, 1 } }, + { { 16, 31, 15, 14, 27, 13 }, { 3, 3, 0, 0, 3, 3, 0, 1, 3, 3, 0, 1, 0, 0, 0, 0 } }, + { { 15, 31, 15, 4, 9, 4 }, { 1, 0, 3, 3, 0, 0, 3, 3, 0, 3, 3, 3, 0, 0, 0, 0 } }, + { { 16, 33, 16, 0, 1, 0 }, { 3, 0, 0, 3, 3, 1, 1, 0, 3, 1, 1, 0, 3, 0, 0, 0 } }, + { { 11, 24, 11, 2, 4, 2 }, { 3, 2, 0, 1, 3, 2, 3, 0, 3, 3, 3, 0, 0, 0, 0, 0 } }, + { { 17, 35, 16, 9, 18, 9 }, { 3, 3, 3, 3, 3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 } }, + { { 15, 30, 14, 9, 19, 9 }, { 3, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { { 9, 18, 7, 6, 11, 4 }, { 3, 0, 0, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 3 } }, + { { 12, 25, 12, 4, 8, 4 }, { 3, 3, 0, 3, 3, 3, 0, 0, 3, 3, 0, 1, 3, 3, 3, 0 } }, + { { 18, 37, 18, 13, 27, 13 }, { 1, 0, 3, 3, 1, 0, 3, 3, 0, 0, 3, 3, 0, 0, 3, 3 } }, + { { 18, 36, 17, 11, 22, 10 }, { 3, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 3, 0, 0, 0, 0 } }, + { { 13, 27, 13, 8, 18, 8 }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 3, 0, 1, 0 } }, + { { 16, 33, 16, 7, 15, 7 }, { 3, 3, 3, 3, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1 } }, + { { 16, 35, 31, 15, 25, 31 }, { 3, 3, 3, 3, 0, 3, 3, 3, 1, 0, 3, 3, 1, 0, 3, 3 } }, + { { 16, 34, 16, 6, 12, 5 }, { 1, 0, 0, 3, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 11, 23, 11, 5, 11, 5 }, { 3, 3, 0, 3, 3, 3, 3, 3, 0, 3, 3, 3, 0, 0, 0, 0 } }, + { { 12, 25, 12, 5, 10, 5 }, { 3, 2, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { { 13, 26, 12, 12, 23, 11 }, { 3, 3, 3, 3, 3, 0, 0, 0, 3, 3, 1, 1, 3, 3, 0, 0 } }, + { { 13, 27, 12, 3, 6, 3 }, { 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 1, 0, 3, 3 } }, + { { 16, 32, 15, 2, 4, 2 }, { 1, 1, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 2, 2, 3 } }, + { { 9, 20, 9, 0, 1, 0 }, { 3, 3, 0, 3, 0, 0, 0, 3, 1, 1, 0, 0, 1, 0, 0, 0 } }, + { { 13, 27, 13, 10, 20, 10 }, { 3, 3, 0, 3, 3, 0, 0, 3, 3, 3, 0, 3, 3, 0, 0, 0 } }, + { { 15, 30, 15, 8, 16, 8 }, { 3, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 16, 34, 17, 11, 25, 12 }, { 0, 0, 0, 0, 0, 0, 3, 3, 1, 0, 3, 3, 1, 0, 3, 3 } }, + { { 10, 20, 7, 4, 6, 2 }, { 3, 3, 0, 1, 3, 3, 0, 1, 3, 3, 0, 1, 0, 0, 0, 0 } }, + { { 14, 28, 13, 5, 10, 4 }, { 3, 2, 3, 3, 2, 2, 3, 0, 3, 3, 0, 1, 3, 0, 0, 1 } }, + { { 9, 19, 8, 7, 14, 6 }, { 3, 2, 2, 3, 0, 3, 3, 3, 1, 1, 1, 0, 1, 1, 1, 1 } }, + { { 12, 24, 11, 9, 19, 9 }, { 3, 0, 1, 1, 3, 3, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 15, 31, 15, 6, 13, 6 }, { 0, 0, 0, 3, 3, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 13, 28, 13, 4, 9, 4 }, { 3, 3, 2, 3, 0, 0, 3, 3, 1, 1, 1, 0, 1, 1, 1, 1 } }, + { { 16, 34, 16, 3, 7, 3 }, { 3, 3, 2, 3, 0, 3, 3, 3, 1, 0, 0, 0, 0, 0, 0, 0 } }, + { { 8, 13, 4, 7, 11, 4 }, { 1, 0, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 2, 2, 3, 3 } }, + { { 9, 16, 6, 8, 13, 5 }, { 3, 0, 0, 0, 3, 0, 1, 0, 3, 0, 0, 0, 3, 0, 0, 0 } }, + { { 12, 26, 12, 1, 2, 1 }, { 3, 0, 0, 0, 3, 0, 0, 0, 3, 3, 0, 0, 2, 3, 0, 0 } }, + { { 19, 38, 18, 5, 11, 5 }, { 3, 3, 3, 3, 0, 0, 3, 3, 1, 1, 3, 3, 0, 0, 0, 3 } }, + { { 14, 30, 14, 3, 6, 3 }, { 1, 1, 0, 3, 0, 0, 0, 0, 3, 3, 0, 0, 3, 3, 0, 0 } }, + { { 14, 28, 13, 2, 4, 1 }, { 0, 0, 0, 3, 0, 0, 3, 3, 0, 0, 3, 3, 0, 0, 0, 0 } }, + { { 10, 17, 7, 3, 4, 1 }, { 3, 2, 0, 1, 3, 2, 0, 1, 3, 3, 0, 1, 3, 3, 0, 1 } }, + { { 9, 18, 8, 8, 16, 7 }, { 1, 0, 0, 1, 0, 3, 3, 0, 0, 3, 3, 3, 0, 0, 0, 0 } }, + { { 8, 16, 8, 7, 14, 7 }, { 1, 1, 1, 1, 0, 0, 0, 0, 3, 3, 0, 0, 3, 0, 0, 0 } }, + { { 14, 29, 13, 1, 1, 0 }, { 3, 0, 0, 3, 3, 0, 0, 3, 3, 3, 0, 3, 3, 0, 0, 0 } }, + { { 21, 42, 19, 15, 31, 14 }, { 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 0, 3, 3, 0, 1, 0 } }, + { { 10, 20, 9, 8, 17, 8 }, { 3, 2, 2, 2, 3, 2, 2, 3, 3, 3, 3, 3, 0, 0, 0, 0 } }, + { { 12, 22, 9, 5, 8, 3 }, { 3, 0, 0, 1, 3, 3, 0, 1, 3, 3, 3, 0, 3, 3, 3, 3 } }, + { { 14, 29, 14, 7, 15, 7 }, { 1, 1, 1, 1, 0, 0, 0, 0, 3, 3, 3, 3, 2, 2, 2, 2 } }, + { { 11, 23, 11, 8, 17, 8 }, { 0, 0, 0, 3, 0, 0, 0, 3, 0, 3, 3, 3, 0, 3, 2, 3 } }, + { { 19, 40, 19, 11, 24, 11 }, { 3, 3, 0, 1, 3, 3, 0, 1, 3, 3, 0, 0, 3, 3, 0, 0 } }, + { { 10, 19, 7, 5, 9, 3 }, { 3, 3, 0, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { { 9, 15, 4, 8, 13, 4 }, { 3, 0, 0, 3, 0, 1, 0, 3, 0, 1, 0, 3, 3, 0, 3, 3 } }, + { { 13, 27, 13, 6, 12, 6 }, { 0, 0, 1, 1, 3, 0, 1, 1, 3, 3, 0, 0, 2, 2, 3, 0 } }, + { { 17, 36, 17, 7, 14, 7 }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 3, 3 } }, + { { 11, 23, 11, 10, 21, 10 }, { 3, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 3 } }, + { { 16, 35, 17, 4, 10, 4 }, { 3, 0, 1, 1, 3, 0, 1, 1, 3, 3, 0, 1, 3, 0, 0, 1 } }, + { { 19, 38, 18, 8, 17, 8 }, { 3, 3, 3, 3, 0, 0, 3, 3, 1, 1, 3, 3, 0, 0, 3, 3 } }, + { { 18, 38, 18, 4, 7, 3 }, { 1, 0, 3, 3, 0, 0, 3, 3, 0, 3, 2, 3, 3, 2, 2, 3 } }, + { { 13, 24, 10, 11, 20, 8 }, { 1, 1, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 2, 2, 3, 3 } }, + { { 3, 9, 6, 2, 8, 5 }, { 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 3, 3, 0, 0, 3, 3 } }, + { { 20, 41, 19, 7, 14, 7 }, { 3, 2, 3, 3, 0, 3, 3, 3, 1, 0, 3, 3, 1, 0, 3, 3 } }, + { { 10, 20, 9, 6, 12, 5 }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 0, 1 } }, + { { 17, 36, 17, 2, 4, 2 }, { 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 3, 3, 3, 3 } }, + { { 21, 43, 20, 13, 27, 12 }, { 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 3, 3, 1, 0, 0, 3 } }, + { { 9, 19, 9, 7, 15, 7 }, { 0, 0, 0, 3, 1, 0, 3, 3, 1, 0, 3, 3, 0, 0, 3, 0 } }, + { { 17, 33, 15, 13, 24, 11 }, { 3, 3, 3, 3, 3, 2, 2, 3, 3, 2, 2, 3, 2, 2, 2, 3 } }, + { { 7, 15, 7, 8, 18, 9 }, { 3, 2, 2, 3, 3, 2, 2, 3, 3, 3, 3, 0, 3, 0, 0, 1 } }, + { { 11, 21, 9, 2, 4, 1 }, { 1, 0, 3, 3, 1, 0, 3, 3, 1, 0, 2, 3, 1, 0, 3, 3 } }, + { { 12, 25, 12, 8, 17, 8 }, { 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { { 12, 23, 10, 9, 17, 7 }, { 3, 0, 0, 1, 3, 3, 3, 0, 3, 3, 0, 0, 0, 0, 0, 1 } }, + { { 18, 37, 18, 16, 32, 16 }, { 0, 0, 0, 3, 1, 1, 0, 3, 1, 1, 0, 0, 0, 0, 0, 0 } }, + { { 27, 3, 1, 26, 1, 0 }, { 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 1, 0, 3, 3 } }, + { { 10, 21, 10, 7, 15, 7 }, { 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 0, 0, 0, 0, 1, 1 } }, + { { 11, 22, 11, 6, 12, 6 }, { 3, 2, 2, 3, 0, 3, 2, 3, 1, 0, 3, 3, 1, 0, 3, 3 } }, + { { 16, 31, 13, 9, 17, 7 }, { 3, 0, 1, 1, 3, 0, 0, 0, 3, 3, 3, 3, 2, 2, 2, 2 } }, + { { 3, 8, 3, 5, 11, 5 }, { 0, 0, 0, 3, 0, 0, 3, 3, 0, 3, 3, 3, 0, 0, 3, 3 } }, + { { 21, 43, 20, 9, 18, 8 }, { 2, 2, 3, 3, 2, 2, 3, 0, 2, 2, 3, 0, 2, 2, 3, 0 } }, + { { 15, 29, 12, 11, 20, 8 }, { 3, 3, 0, 1, 3, 3, 0, 0, 3, 3, 0, 0, 3, 0, 0, 0 } }, + { { 10, 21, 10, 6, 13, 6 }, { 3, 2, 2, 3, 3, 3, 3, 0, 0, 0, 0, 1, 0, 0, 0, 1 } }, + { { 10, 20, 9, 7, 13, 6 }, { 0, 3, 2, 3, 0, 3, 3, 3, 0, 0, 0, 0, 0, 0, 1, 1 } }, + { { 21, 43, 20, 5, 11, 5 }, { 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 0, 0, 0, 0, 1 } }, + { { 19, 33, 31, 12, 31, 31 }, { 3, 0, 0, 0, 3, 0, 1, 0, 3, 3, 0, 0, 3, 2, 3, 3 } }, + { { 11, 20, 8, 9, 17, 7 }, { 3, 0, 1, 1, 3, 3, 0, 0, 3, 3, 3, 3, 2, 2, 3, 3 } }, + { { 10, 17, 7, 8, 13, 5 }, { 1, 0, 3, 3, 1, 0, 3, 3, 0, 0, 0, 0, 0, 0, 1, 1 } }, + { { 21, 42, 20, 3, 7, 3 }, { 0, 0, 0, 1, 0, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 7, 14, 2, 6, 12, 2 }, { 3, 3, 3, 3, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0 } }, + { { 19, 39, 19, 9, 20, 10 }, { 3, 2, 3, 0, 3, 3, 0, 1, 3, 3, 1, 1, 0, 0, 0, 1 } }, + { { 13, 26, 11, 5, 8, 3 }, { 3, 3, 0, 0, 3, 3, 0, 0, 3, 3, 0, 0, 3, 0, 1, 1 } }, + { { 31, 62, 30, 31, 61, 29 }, { 3, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 3 } }, + { { 22, 45, 21, 11, 22, 10 }, { 3, 3, 0, 0, 3, 3, 0, 1, 3, 0, 1, 1, 0, 0, 1, 1 } }, + { { 23, 48, 23, 4, 9, 4 }, { 3, 3, 0, 0, 3, 3, 3, 3, 3, 3, 3, 0, 3, 2, 3, 0 } }, + { { 15, 42, 31, 11, 22, 30 }, { 3, 0, 1, 1, 3, 0, 0, 0, 0, 0, 3, 3, 0, 0, 3, 3 } }, + { { 15, 33, 16, 8, 18, 9 }, { 3, 2, 2, 2, 0, 3, 2, 3, 0, 3, 2, 2, 0, 0, 2, 2 } }, + { { 13, 27, 13, 7, 15, 7 }, { 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 0, 0, 0, 0 } }, + { { 19, 35, 14, 16, 29, 12 }, { 3, 0, 0, 3, 0, 0, 1, 0, 3, 0, 0, 3, 3, 3, 3, 2 } }, + { { 1, 2, 1, 7, 13, 6 }, { 3, 0, 0, 3, 0, 0, 0, 0, 3, 3, 3, 0, 3, 2, 2, 3 } }, + { { 11, 21, 9, 8, 15, 6 }, { 1, 0, 3, 3, 1, 0, 3, 3, 0, 3, 2, 3, 3, 3, 2, 3 } }, + { { 14, 28, 12, 8, 16, 6 }, { 3, 3, 3, 3, 0, 3, 3, 3, 1, 3, 3, 3, 1, 0, 3, 3 } }, + { { 20, 41, 19, 1, 3, 1 }, { 3, 0, 0, 1, 3, 3, 0, 1, 3, 3, 3, 0, 3, 2, 2, 3 } }, + { { 14, 26, 11, 10, 18, 7 }, { 1, 0, 3, 3, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 11, 32, 30, 11, 31, 30 }, { 3, 0, 0, 0, 3, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 23, 47, 22, 7, 14, 6 }, { 3, 3, 0, 1, 3, 3, 0, 0, 3, 3, 3, 3, 0, 0, 3, 3 } }, + { { 12, 24, 12, 6, 12, 6 }, { 3, 2, 3, 3, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 3 } }, + { { 16, 29, 11, 13, 23, 9 }, { 1, 1, 1, 1, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 11, 22, 9, 6, 11, 4 }, { 0, 0, 3, 3, 0, 0, 3, 3, 0, 1, 0, 3, 0, 0, 0, 3 } }, + { { 1, 2, 1, 3, 7, 3 }, { 3, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { { 4, 10, 4, 8, 17, 7 }, { 1, 1, 1, 1, 0, 0, 1, 1, 3, 0, 0, 1, 3, 3, 0, 0 } }, + { { 18, 33, 13, 11, 21, 8 }, { 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 3, 0, 0, 0 } }, + { { 23, 47, 22, 16, 32, 15 }, { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { { 13, 25, 11, 8, 16, 7 }, { 0, 0, 0, 3, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 17, 45, 30, 15, 33, 31 }, { 3, 2, 3, 3, 3, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1 } }, + { { 18, 37, 17, 1, 1, 0 }, { 3, 0, 0, 1, 3, 3, 0, 0, 3, 3, 0, 0, 2, 3, 0, 0 } }, + { { 8, 16, 7, 12, 25, 11 }, { 1, 1, 0, 3, 0, 1, 1, 0, 3, 0, 1, 1, 3, 3, 0, 1 } }, + { { 14, 27, 12, 7, 13, 5 }, { 0, 0, 0, 3, 3, 0, 0, 3, 3, 3, 3, 3, 3, 0, 0, 0 } }, + { { 10, 17, 6, 9, 15, 6 }, { 3, 0, 0, 3, 3, 0, 0, 3, 3, 0, 0, 3, 3, 0, 0, 3 } }, + { { 21, 43, 20, 18, 37, 17 }, { 3, 3, 2, 3, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 18, 35, 15, 8, 15, 5 }, { 1, 1, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 3, 3, 0, 0 } }, + { { 19, 32, 30, 15, 43, 31 }, { 1, 1, 1, 1, 1, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3 } }, + { { 18, 15, 30, 15, 33, 31 }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0 } }, + { { 12, 22, 9, 8, 15, 6 }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 3, 0 } }, + { { 16, 22, 31, 12, 40, 31 }, { 3, 3, 3, 3, 3, 0, 0, 3, 3, 1, 0, 3, 3, 0, 0, 3 } }, + { { 17, 35, 31, 14, 14, 29 }, { 1, 1, 0, 3, 0, 0, 0, 3, 3, 0, 0, 3, 0, 0, 0, 3 } }, + { { 11, 20, 8, 8, 14, 5 }, { 3, 3, 3, 3, 3, 3, 0, 0, 3, 3, 0, 1, 3, 3, 0, 1 } }, + { { 22, 46, 21, 1, 3, 1 }, { 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 3, 3 } }, + { { 10, 18, 6, 1, 1, 0 }, { 3, 0, 0, 1, 3, 3, 0, 1, 3, 3, 3, 0, 2, 2, 2, 3 } }, + { { 1, 2, 1, 10, 21, 9 }, { 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 3, 3 } }, + { { 7, 8, 2, 5, 5, 1 }, { 1, 0, 0, 0, 3, 3, 3, 0, 3, 3, 3, 0, 0, 0, 0, 0 } }, + { { 20, 10, 31, 13, 10, 31 }, { 3, 3, 0, 3, 3, 2, 3, 0, 3, 3, 3, 0, 0, 0, 0, 0 } }, + { { 17, 33, 12, 14, 27, 9 }, { 1, 0, 0, 3, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { { 24, 50, 24, 18, 37, 18 }, { 3, 3, 0, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 24, 49, 23, 13, 28, 12 }, { 3, 0, 0, 0, 3, 0, 0, 0, 3, 3, 3, 3, 2, 2, 2, 3 } }, + { { 18, 27, 12, 16, 22, 10 }, { 1, 1, 0, 3, 1, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 2 } }, + { { 3, 12, 7, 4, 16, 8 }, { 1, 1, 0, 1, 0, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 24, 50, 24, 9, 19, 8 }, { 3, 2, 3, 0, 3, 2, 2, 3, 3, 2, 3, 3, 2, 2, 2, 3 } }, + { { 22, 41, 30, 18, 23, 30 }, { 0, 3, 2, 3, 1, 0, 3, 3, 1, 0, 3, 3, 1, 0, 3, 3 } }, + { { 16, 31, 12, 4, 8, 2 }, { 3, 2, 3, 3, 3, 3, 0, 0, 3, 0, 1, 1, 3, 0, 0, 1 } }, + { { 20, 39, 16, 11, 20, 8 }, { 3, 2, 2, 2, 3, 3, 3, 3, 0, 0, 0, 0, 1, 1, 1, 1 } }, + { { 11, 21, 7, 7, 13, 4 }, { 0, 0, 3, 3, 0, 3, 3, 3, 0, 3, 3, 3, 0, 0, 0, 3 } }, + { { 13, 25, 11, 6, 11, 4 }, { 3, 3, 3, 3, 0, 3, 3, 3, 1, 0, 0, 0, 1, 1, 1, 1 } }, + { { 18, 35, 15, 5, 9, 3 }, { 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 3, 3, 0, 1 } }, + { { 20, 38, 16, 13, 25, 10 }, { 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 2, 2, 2, 3 } }, + { { 16, 29, 13, 7, 13, 5 }, { 3, 2, 2, 3, 3, 3, 3, 3, 3, 0, 0, 0, 3, 0, 1, 1 } }, + { { 5, 9, 3, 12, 24, 10 }, { 3, 2, 3, 3, 3, 2, 3, 0, 3, 3, 3, 0, 3, 0, 0, 1 } }, + { { 13, 25, 8, 3, 6, 1 }, { 3, 0, 3, 3, 3, 1, 3, 3, 3, 1, 3, 3, 3, 0, 3, 3 } }, + { { 6, 11, 4, 16, 31, 13 }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 1, 1 } }, + { { 25, 50, 24, 21, 43, 20 }, { 3, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 19, 22, 30, 16, 23, 31 }, { 3, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1 } }, + { { 22, 45, 30, 9, 15, 30 }, { 3, 0, 0, 3, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 } }, + { { 1, 2, 1, 14, 28, 12 }, { 1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3, 0, 3, 2, 3 } }, + { { 16, 22, 9, 13, 17, 7 }, { 3, 3, 3, 1, 3, 3, 3, 1, 3, 3, 3, 1, 0, 3, 0, 1 } }, + { { 11, 19, 8, 6, 9, 4 }, { 3, 3, 3, 3, 3, 0, 0, 3, 3, 0, 0, 0, 3, 0, 0, 0 } }, + { { 28, 58, 26, 15, 32, 14 }, { 1, 0, 0, 3, 1, 0, 0, 3, 1, 0, 0, 0, 0, 0, 0, 0 } }, + { { 9, 20, 10, 5, 13, 7 }, { 3, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 0, 3 } }, + { { 28, 56, 26, 4, 7, 3 }, { 1, 0, 2, 3, 0, 0, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0 } }, + { { 14, 18, 6, 11, 14, 4 }, { 1, 0, 0, 3, 0, 3, 3, 3, 0, 3, 3, 3, 0, 0, 0, 3 } }, + { { 15, 9, 30, 7, 9, 30 }, { 1, 0, 0, 3, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0 } }, + { { 30, 50, 3, 29, 46, 2 }, { 3, 0, 1, 1, 3, 0, 0, 0, 3, 0, 0, 3, 0, 0, 0, 0 } }, + { { 10, 19, 5, 11, 21, 6 }, { 0, 0, 1, 1, 0, 0, 0, 0, 3, 3, 3, 3, 3, 2, 2, 3 } }, + { { 21, 31, 30, 22, 31, 30 }, { 3, 3, 0, 0, 3, 3, 0, 1, 3, 3, 3, 0, 3, 3, 3, 3 } }, + { { 19, 27, 31, 11, 19, 30 }, { 3, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3 } }, + { { 26, 53, 25, 6, 13, 6 }, { 3, 2, 2, 3, 3, 2, 3, 3, 3, 3, 0, 0, 3, 0, 1, 1 } }, + { { 12, 24, 10, 7, 13, 5 }, { 3, 3, 3, 3, 3, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0 } }, + { { 9, 20, 10, 4, 10, 5 }, { 0, 0, 0, 3, 1, 1, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0 } }, + { { 19, 29, 30, 14, 55, 28 }, { 3, 2, 3, 3, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 } }, + { { 12, 19, 8, 11, 16, 7 }, { 0, 0, 3, 3, 1, 0, 3, 3, 1, 0, 3, 3, 0, 0, 3, 3 } }, + { { 11, 30, 31, 7, 15, 29 }, { 1, 0, 3, 3, 1, 3, 3, 3, 1, 3, 3, 3, 1, 0, 3, 3 } }, + { { 25, 50, 24, 2, 4, 1 }, { 3, 3, 2, 3, 0, 0, 0, 3, 3, 3, 0, 0, 3, 2, 3, 3 } }, + { { 18, 30, 31, 10, 44, 30 }, { 0, 3, 2, 3, 0, 3, 2, 3, 0, 3, 3, 3, 0, 3, 3, 3 } }, + { { 10, 22, 11, 8, 18, 9 }, { 3, 2, 3, 0, 3, 2, 3, 3, 0, 3, 2, 3, 0, 0, 3, 3 } }, + { { 22, 18, 30, 19, 41, 30 }, { 3, 0, 0, 1, 3, 3, 0, 1, 3, 3, 3, 0, 3, 2, 3, 0 } }, + { { 17, 32, 12, 6, 11, 4 }, { 3, 2, 3, 0, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 11, 25, 13, 8, 19, 10 }, { 3, 0, 0, 3, 3, 0, 0, 0, 0, 3, 3, 3, 0, 0, 3, 3 } }, + { { 18, 50, 29, 15, 10, 29 }, { 3, 0, 0, 3, 3, 3, 0, 0, 3, 3, 3, 0, 0, 3, 3, 3 } }, + { { 13, 17, 5, 9, 10, 3 }, { 3, 0, 0, 3, 3, 0, 0, 0, 3, 3, 0, 1, 3, 3, 0, 0 } }, + { { 13, 29, 15, 8, 20, 11 }, { 0, 0, 0, 0, 0, 1, 1, 0, 3, 0, 0, 0, 2, 3, 3, 3 } }, + { { 29, 57, 27, 27, 52, 25 }, { 3, 3, 2, 3, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0 } }, + { { 14, 15, 30, 9, 31, 30 }, { 3, 3, 0, 3, 3, 3, 0, 0, 3, 3, 0, 1, 3, 0, 1, 1 } }, + { { 2, 3, 1, 19, 37, 16 }, { 3, 0, 0, 3, 3, 0, 0, 3, 3, 3, 0, 0, 3, 0, 1, 1 } }, + { { 14, 51, 30, 9, 34, 30 }, { 3, 0, 0, 3, 0, 3, 3, 3, 1, 0, 3, 3, 0, 0, 3, 3 } }, + { { 18, 52, 30, 14, 22, 30 }, { 3, 3, 0, 3, 3, 3, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 11, 24, 10, 6, 13, 5 }, { 1, 1, 0, 3, 1, 1, 0, 3, 1, 0, 3, 3, 0, 3, 2, 2 } }, + { { 16, 23, 10, 10, 14, 6 }, { 1, 1, 0, 3, 1, 1, 0, 3, 1, 1, 0, 3, 0, 0, 3, 3 } }, + { { 23, 49, 30, 20, 36, 30 }, { 3, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 0, 0, 1, 1 } }, + { { 26, 54, 24, 12, 24, 10 }, { 0, 1, 1, 1, 0, 1, 1, 1, 3, 0, 1, 1, 2, 3, 0, 1 } }, + { { 17, 31, 11, 1, 2, 1 }, { 3, 0, 0, 0, 3, 0, 0, 0, 3, 3, 0, 1, 2, 2, 0, 0 } }, + { { 29, 60, 29, 6, 13, 6 }, { 3, 2, 3, 3, 3, 2, 3, 3, 0, 0, 0, 0, 1, 1, 1, 1 } }, + { { 11, 24, 12, 4, 11, 6 }, { 1, 3, 2, 3, 0, 3, 2, 3, 3, 3, 3, 3, 0, 0, 0, 3 } }, + { { 19, 27, 10, 12, 15, 5 }, { 3, 0, 0, 3, 3, 0, 0, 0, 3, 3, 0, 3, 3, 3, 3, 3 } }, + { { 12, 25, 13, 10, 22, 12 }, { 1, 0, 2, 3, 0, 0, 3, 3, 3, 0, 0, 0, 3, 0, 0, 0 } }, + { { 16, 23, 30, 14, 6, 26 }, { 1, 0, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3 } }, + { { 10, 12, 4, 8, 8, 2 }, { 3, 3, 3, 3, 3, 3, 0, 0, 3, 3, 0, 1, 2, 2, 3, 0 } }, + { { 10, 24, 30, 6, 45, 30 }, { 0, 0, 0, 3, 0, 0, 0, 0, 1, 0, 0, 3, 0, 0, 0, 3 } }, + { { 8, 44, 30, 6, 26, 30 }, { 1, 1, 1, 1, 0, 1, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 23, 32, 30, 17, 12, 29 }, { 3, 0, 0, 0, 3, 0, 0, 1, 3, 3, 0, 1, 3, 2, 3, 1 } }, + { { 11, 20, 8, 16, 31, 14 }, { 3, 3, 0, 0, 3, 3, 3, 0, 3, 3, 3, 0, 3, 0, 0, 0 } }, + { { 13, 28, 8, 5, 11, 3 }, { 0, 0, 0, 3, 0, 0, 0, 3, 1, 1, 3, 3, 0, 0, 3, 3 } }, + { { 12, 25, 12, 7, 16, 7 }, { 0, 0, 1, 1, 0, 0, 1, 1, 3, 3, 0, 0, 3, 2, 2, 3 } }, + { { 17, 22, 7, 10, 11, 3 }, { 1, 0, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 11, 22, 11, 7, 15, 7 }, { 3, 0, 0, 0, 3, 0, 0, 1, 3, 3, 0, 1, 3, 2, 3, 0 } }, + { { 23, 5, 30, 9, 5, 30 }, { 3, 3, 0, 3, 3, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1 } }, + { { 14, 23, 8, 1, 2, 1 }, { 3, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 3, 2, 3, 3 } }, + { { 22, 36, 15, 20, 32, 14 }, { 3, 3, 0, 1, 3, 3, 0, 1, 3, 3, 0, 1, 3, 3, 0, 1 } }, + { { 12, 26, 12, 7, 14, 7 }, { 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 2, 2, 2, 2 } }, + { { 12, 24, 11, 7, 14, 6 }, { 3, 3, 3, 3, 0, 1, 0, 0, 0, 1, 1, 0, 3, 3, 3, 3 } }, + { { 10, 22, 11, 6, 14, 7 }, { 3, 3, 3, 3, 0, 0, 3, 3, 1, 0, 3, 3, 3, 3, 3, 3 } }, + { { 12, 27, 13, 6, 12, 6 }, { 0, 0, 3, 3, 1, 1, 3, 3, 1, 1, 3, 3, 3, 0, 3, 3 } }, + { { 20, 38, 14, 3, 5, 2 }, { 3, 0, 0, 3, 0, 0, 0, 3, 3, 3, 0, 3, 3, 2, 3, 3 } }, + { { 15, 29, 15, 16, 36, 17 }, { 3, 3, 0, 3, 0, 0, 0, 0, 3, 3, 3, 0, 3, 2, 3, 0 } }, + { { 7, 29, 6, 8, 30, 7 }, { 3, 3, 0, 1, 3, 3, 0, 1, 3, 3, 0, 1, 2, 2, 3, 0 } }, +}; + +inline constexpr uint8_t BC2_POSITION_RANK[256][4] = { + { 1, 1, 1, 1 }, + { 3, 3, 3, 3 }, + { 2, 2, 2, 2 }, + { 0, 0, 0, 0 }, + { 3, 3, 0, 0 }, + { 0, 0, 3, 3 }, + { 3, 3, 1, 1 }, + { 0, 0, 2, 2 }, + { 2, 2, 0, 0 }, + { 1, 1, 3, 3 }, + { 1, 1, 2, 2 }, + { 2, 2, 1, 1 }, + { 3, 3, 2, 2 }, + { 1, 2, 1, 1 }, + { 1, 1, 1, 2 }, + { 2, 1, 1, 1 }, + { 1, 1, 2, 1 }, + { 1, 1, 0, 0 }, + { 2, 2, 3, 3 }, + { 0, 0, 1, 1 }, + { 3, 3, 3, 2 }, + { 3, 3, 2, 3 }, + { 3, 2, 3, 3 }, + { 2, 3, 3, 3 }, + { 1, 1, 0, 1 }, + { 1, 1, 1, 0 }, + { 1, 2, 1, 2 }, + { 1, 0, 1, 1 }, + { 3, 2, 1, 0 }, + { 0, 1, 1, 1 }, + { 3, 3, 2, 1 }, + { 2, 1, 2, 1 }, + { 1, 2, 2, 2 }, + { 0, 1, 2, 3 }, + { 2, 2, 1, 2 }, + { 2, 2, 2, 1 }, + { 1, 0, 3, 2 }, + { 2, 3, 0, 1 }, + { 2, 1, 2, 2 }, + { 3, 3, 1, 0 }, + { 3, 3, 0, 1 }, + { 1, 3, 1, 3 }, + { 3, 1, 3, 1 }, + { 3, 3, 1, 2 }, + { 1, 0, 3, 3 }, + { 1, 2, 3, 3 }, + { 2, 1, 3, 3 }, + { 0, 2, 0, 2 }, + { 0, 1, 3, 3 }, + { 2, 3, 0, 0 }, + { 0, 0, 2, 3 }, + { 3, 2, 3, 2 }, + { 0, 0, 3, 2 }, + { 1, 2, 2, 1 }, + { 3, 2, 0, 0 }, + { 0, 2, 2, 3 }, + { 3, 2, 2, 0 }, + { 0, 0, 1, 2 }, + { 2, 3, 2, 2 }, + { 1, 0, 2, 2 }, + { 2, 1, 0, 0 }, + { 2, 0, 2, 0 }, + { 1, 1, 2, 3 }, + { 2, 3, 1, 1 }, + { 2, 3, 2, 3 }, + { 2, 1, 1, 2 }, + { 1, 2, 0, 0 }, + { 1, 1, 3, 2 }, + { 3, 2, 2, 2 }, + { 3, 2, 1, 1 }, + { 0, 1, 2, 2 }, + { 2, 2, 0, 1 }, + { 2, 2, 2, 3 }, + { 2, 2, 1, 0 }, + { 0, 0, 2, 1 }, + { 2, 3, 0, 2 }, + { 2, 2, 3, 2 }, + { 0, 3, 0, 3 }, + { 2, 0, 3, 2 }, + { 3, 1, 1, 0 }, + { 0, 1, 1, 3 }, + { 0, 2, 1, 3 }, + { 3, 3, 3, 1 }, + { 3, 0, 3, 3 }, + { 1, 3, 3, 3 }, + { 3, 1, 2, 0 }, + { 3, 3, 3, 0 }, + { 3, 3, 0, 3 }, + { 1, 3, 0, 1 }, + { 3, 1, 3, 3 }, + { 0, 3, 3, 3 }, + { 3, 3, 1, 3 }, + { 1, 0, 3, 1 }, + { 0, 1, 1, 2 }, + { 1, 0, 2, 1 }, + { 3, 0, 3, 0 }, + { 2, 1, 1, 0 }, + { 1, 2, 0, 1 }, + { 0, 0, 0, 1 }, + { 1, 0, 0, 0 }, + { 0, 1, 0, 0 }, + { 3, 2, 2, 1 }, + { 1, 2, 2, 3 }, + { 3, 2, 3, 1 }, + { 1, 3, 2, 3 }, + { 2, 3, 1, 2 }, + { 2, 1, 3, 2 }, + { 1, 3, 1, 1 }, + { 0, 0, 1, 0 }, + { 1, 1, 1, 3 }, + { 2, 0, 3, 1 }, + { 1, 3, 0, 2 }, + { 3, 1, 1, 1 }, + { 3, 3, 0, 2 }, + { 3, 1, 3, 2 }, + { 0, 1, 0, 1 }, + { 1, 1, 3, 1 }, + { 2, 3, 1, 3 }, + { 3, 3, 2, 0 }, + { 1, 0, 1, 2 }, + { 1, 0, 1, 0 }, + { 2, 1, 0, 1 }, + { 0, 1, 2, 1 }, + { 2, 0, 3, 3 }, + { 1, 2, 1, 0 }, + { 0, 2, 3, 3 }, + { 0, 2, 2, 2 }, + { 2, 2, 2, 0 }, + { 0, 0, 0, 2 }, + { 2, 2, 0, 2 }, + { 0, 1, 0, 2 }, + { 1, 0, 2, 3 }, + { 2, 0, 2, 2 }, + { 2, 3, 1, 0 }, + { 2, 0, 0, 0 }, + { 1, 2, 0, 2 }, + { 0, 2, 0, 0 }, + { 3, 2, 0, 1 }, + { 0, 2, 1, 2 }, + { 0, 1, 3, 2 }, + { 2, 1, 2, 0 }, + { 3, 2, 2, 3 }, + { 0, 0, 2, 0 }, + { 2, 0, 1, 0 }, + { 2, 3, 3, 2 }, + { 1, 1, 0, 2 }, + { 3, 1, 0, 0 }, + { 2, 0, 2, 1 }, + { 2, 3, 2, 1 }, + { 3, 2, 3, 0 }, + { 1, 2, 1, 3 }, + { 1, 3, 0, 0 }, + { 0, 2, 0, 1 }, + { 1, 2, 3, 2 }, + { 3, 1, 2, 1 }, + { 1, 0, 2, 0 }, + { 0, 0, 1, 3 }, + { 2, 1, 2, 3 }, + { 1, 3, 1, 2 }, + { 0, 0, 3, 1 }, + { 2, 0, 1, 1 }, + { 3, 2, 1, 2 }, + { 0, 3, 2, 3 }, + { 2, 1, 3, 1 }, + { 1, 1, 2, 0 }, + { 0, 2, 1, 1 }, + { 3, 0, 3, 2 }, + { 2, 3, 0, 3 }, + { 0, 1, 3, 1 }, + { 3, 1, 3, 0 }, + { 1, 0, 0, 1 }, + { 1, 3, 2, 2 }, + { 0, 3, 1, 3 }, + { 1, 0, 1, 3 }, + { 0, 1, 1, 0 }, + { 3, 1, 0, 1 }, + { 1, 3, 1, 0 }, + { 0, 2, 0, 3 }, + { 2, 2, 3, 1 }, + { 3, 0, 0, 0 }, + { 2, 2, 1, 3 }, + { 1, 3, 0, 3 }, + { 0, 3, 0, 0 }, + { 3, 1, 2, 2 }, + { 0, 0, 0, 3 }, + { 3, 0, 3, 1 }, + { 3, 0, 2, 0 }, + { 0, 0, 3, 0 }, + { 2, 1, 0, 2 }, + { 2, 3, 2, 0 }, + { 2, 0, 2, 3 }, + { 2, 0, 1, 2 }, + { 0, 2, 2, 1 }, + { 3, 2, 0, 2 }, + { 0, 3, 0, 2 }, + { 0, 2, 3, 2 }, + { 1, 2, 2, 0 }, + { 0, 3, 2, 2 }, + { 3, 0, 1, 1 }, + { 1, 3, 2, 1 }, + { 1, 1, 0, 3 }, + { 2, 0, 3, 0 }, + { 2, 2, 3, 0 }, + { 0, 1, 0, 3 }, + { 3, 0, 1, 0 }, + { 1, 2, 3, 1 }, + { 3, 0, 2, 2 }, + { 2, 2, 0, 3 }, + { 3, 1, 1, 2 }, + { 0, 3, 1, 1 }, + { 2, 1, 1, 3 }, + { 1, 1, 3, 0 }, + { 0, 3, 1, 2 }, + { 0, 3, 0, 1 }, + { 2, 1, 3, 0 }, + { 1, 2, 0, 3 }, + { 1, 0, 3, 0 }, + { 3, 0, 2, 1 }, + { 1, 3, 3, 2 }, + { 2, 3, 3, 1 }, + { 0, 3, 3, 2 }, + { 3, 0, 2, 3 }, + { 2, 0, 0, 1 }, + { 1, 0, 0, 2 }, + { 3, 2, 1, 3 }, + { 3, 1, 2, 3 }, + { 3, 2, 0, 3 }, + { 1, 2, 3, 0 }, + { 2, 3, 3, 0 }, + { 0, 1, 2, 0 }, + { 0, 3, 2, 1 }, + { 0, 2, 3, 1 }, + { 1, 3, 2, 0 }, + { 2, 0, 0, 2 }, + { 0, 2, 1, 0 }, + { 2, 0, 1, 3 }, + { 3, 0, 1, 2 }, + { 2, 1, 0, 3 }, + { 3, 0, 0, 1 }, + { 3, 1, 0, 2 }, + { 1, 0, 0, 3 }, + { 0, 2, 2, 0 }, + { 1, 3, 3, 1 }, + { 0, 1, 3, 0 }, + { 3, 1, 1, 3 }, + { 0, 3, 1, 0 }, + { 0, 3, 3, 0 }, + { 3, 0, 0, 3 }, + { 3, 0, 0, 2 }, + { 2, 0, 0, 3 }, + { 1, 3, 3, 0 }, + { 0, 3, 2, 0 }, + { 0, 2, 3, 0 }, + { 0, 3, 3, 1 }, + { 3, 0, 1, 3 }, + { 3, 1, 0, 3 }, +}; + +inline constexpr Bc2State BC2_FULL_DICTIONARY[255] = { + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 0, 0, 1, 0, 0, 0 }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 3, 15, 10, 2, 14, 10 }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 12, 25, 12, 11, 22, 11 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { { 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15 }, { 16, 33, 16, 15, 31, 15 }, { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 10, 29, 31, 9, 28, 31 }, { 1, 1, 1, 1, 0, 0, 0, 0, 3, 3, 3, 3, 2, 2, 2, 2 } }, + { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 21, 32, 5, 20, 31, 5 }, { 3, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 6, 11, 5, 4, 9, 4 }, { 2, 2, 2, 2, 3, 3, 3, 3, 0, 0, 0, 0, 1, 1, 1, 1 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 3, 5, 2, 1, 2, 1 }, { 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 3, 0, 0, 3, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 21, 15, 8, 20, 15, 7 }, { 1, 1, 0, 3, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 31, 63, 31, 0, 0, 0 }, { 3, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 1, 2, 1, 0, 1, 0 }, { 3, 0, 1, 1, 3, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 10, 21, 10, 9, 18, 9 }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 } }, + { { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, { 30, 61, 30, 29, 60, 29 }, { 1, 0, 3, 3, 0, 3, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 30, 49, 15, 29, 49, 15 }, { 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 3, 3, 0, 0 } }, + { { 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15 }, { 2, 63, 15, 1, 62, 15 }, { 0, 0, 0, 3, 1, 1, 0, 3, 1, 1, 0, 3, 0, 0, 3, 3 } }, + { { 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15 }, { 8, 62, 15, 6, 62, 16 }, { 3, 3, 0, 1, 2, 2, 3, 3, 2, 2, 2, 3, 2, 2, 2, 2 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 5, 10, 5, 4, 8, 4 }, { 1, 0, 3, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 0, 3, 2 } }, + { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 16, 31, 16, 15, 34, 16 }, { 1, 1, 0, 3, 1, 0, 3, 2, 0, 3, 2, 2, 3, 2, 2, 2 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 31, 63, 31, 0, 0, 0 }, { 1, 1, 0, 3, 1, 1, 0, 3, 1, 1, 0, 3, 1, 0, 3, 2 } }, + { { 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13 }, { 21, 49, 17, 21, 48, 20 }, { 3, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 3, 0, 0, 3, 3 } }, + { { 0, 15, 15, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 31, 32, 31, 31, 30, 31 }, { 3, 3, 0, 1, 3, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0 } }, + { { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, { 23, 48, 23, 22, 47, 23 }, { 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 0, 0, 0, 0, 1, 1 } }, + { { 15, 15, 0, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15 }, { 12, 62, 15, 10, 62, 15 }, { 3, 2, 2, 3, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 29, 18, 8, 28, 18, 8 }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 5, 8, 2, 4, 6, 2 }, { 3, 2, 2, 2, 0, 0, 0, 3, 3, 3, 3, 3, 2, 2, 2, 2 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 11, 21, 10, 9, 17, 8 }, { 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 0, 0, 0, 0 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 7, 13, 6, 1, 1, 1 }, { 3, 3, 0, 0, 3, 0, 0, 3, 3, 1, 0, 3, 0, 0, 3, 3 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 16, 13, 8, 13, 10, 6 }, { 1, 1, 0, 3, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 18, 37, 17, 1, 2, 4 }, { 3, 2, 2, 2, 3, 2, 2, 2, 0, 3, 2, 2, 0, 0, 2, 2 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 21, 41, 20, 19, 36, 18 }, { 2, 2, 3, 3, 2, 2, 3, 0, 3, 3, 0, 1, 3, 0, 1, 1 } }, + { { 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15 }, { 18, 62, 15, 13, 62, 15 }, { 1, 1, 0, 0, 0, 0, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2 } }, + { { 15, 15, 15, 0, 15, 15, 0, 0, 15, 15, 0, 0, 15, 15, 0, 0 }, { 8, 62, 15, 6, 62, 16 }, { 3, 0, 1, 1, 3, 0, 1, 1, 3, 0, 1, 1, 3, 0, 1, 1 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 30, 60, 29, 1, 2, 1 }, { 1, 1, 1, 1, 1, 1, 1, 1, 0, 3, 0, 0, 0, 0, 0, 0 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 30, 55, 19, 30, 54, 18 }, { 1, 0, 3, 3, 1, 0, 3, 2, 1, 0, 3, 2, 0, 0, 3, 2 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 24, 48, 24, 22, 43, 22 }, { 1, 1, 1, 1, 1, 1, 1, 1, 0, 3, 0, 0, 0, 3, 0, 0 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 15, 31, 14, 12, 24, 12 }, { 3, 3, 0, 1, 3, 3, 0, 1, 3, 3, 0, 0, 3, 0, 0, 0 } }, + { { 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12 }, { 19, 43, 17, 18, 41, 16 }, { 3, 0, 1, 1, 3, 0, 1, 1, 3, 3, 1, 1, 3, 0, 0, 0 } }, + { { 0, 0, 15, 15, 0, 0, 15, 15, 0, 0, 15, 15, 0, 0, 15, 15 }, { 8, 62, 15, 6, 62, 16 }, { 1, 1, 1, 1, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2 } }, + { { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, { 16, 32, 31, 15, 31, 31 }, { 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 2, 2, 2, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 9, 15, 4, 8, 12, 3 }, { 3, 3, 2, 3, 3, 3, 3, 3, 0, 1, 0, 3, 0, 0, 0, 0 } }, + { { 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11 }, { 17, 31, 31, 15, 31, 31 }, { 1, 1, 0, 3, 1, 1, 0, 3, 0, 1, 1, 0, 0, 0, 0, 0 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 7, 20, 9, 5, 18, 9 }, { 3, 0, 0, 3, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1 } }, + { { 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11 }, { 26, 54, 26, 25, 50, 25 }, { 0, 0, 0, 3, 0, 1, 0, 3, 0, 1, 0, 3, 0, 0, 0, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 2, 5, 5, 1, 2, 2 }, { 3, 3, 3, 3, 3, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 16, 32, 31, 15, 31, 31 }, { 2, 2, 3, 0, 2, 3, 0, 1, 3, 0, 1, 1, 0, 0, 1, 1 } }, + { { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 24, 43, 20, 23, 41, 19 }, { 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 2, 2, 2, 2 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 23, 43, 20, 1, 6, 1 }, { 0, 0, 1, 1, 3, 3, 0, 0, 2, 3, 3, 3, 2, 2, 2, 2 } }, + { { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }, { 27, 53, 24, 26, 50, 23 }, { 3, 2, 2, 2, 3, 2, 2, 3, 0, 3, 3, 3, 1, 1, 1, 1 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 21, 40, 17, 15, 30, 14 }, { 0, 0, 0, 3, 0, 0, 0, 3, 1, 1, 0, 3, 0, 0, 3, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 19, 39, 20, 16, 34, 17 }, { 1, 1, 1, 1, 0, 0, 1, 1, 3, 3, 1, 1, 3, 3, 0, 1 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 11, 23, 11, 7, 14, 7 }, { 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 0, 1, 1 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 7, 14, 7, 3, 6, 3 }, { 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 0, 0, 0, 0, 0, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 22, 45, 22, 15, 30, 15 }, { 3, 3, 0, 3, 2, 2, 3, 3, 3, 2, 2, 3, 2, 2, 2, 2 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 19, 38, 16, 15, 32, 14 }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2 } }, + { { 0, 0, 15, 15, 0, 0, 15, 15, 0, 0, 15, 15, 0, 0, 15, 15 }, { 14, 62, 15, 9, 62, 15 }, { 3, 3, 3, 3, 3, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 23, 41, 18, 22, 39, 18 }, { 1, 1, 1, 1, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 15, 26, 12, 13, 24, 11 }, { 3, 2, 2, 2, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 22, 43, 18, 19, 37, 16 }, { 3, 2, 2, 3, 3, 3, 3, 3, 1, 1, 0, 3, 0, 0, 0, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 8, 8, 1, 1, 1, 0 }, { 3, 2, 2, 3, 3, 3, 3, 3, 0, 1, 1, 0, 0, 0, 0, 0 } }, + { { 15, 0, 0, 0, 15, 15, 0, 0, 15, 15, 15, 0, 15, 15, 15, 15 }, { 9, 62, 15, 6, 62, 15 }, { 3, 0, 0, 3, 3, 0, 0, 0, 3, 3, 3, 3, 3, 2, 2, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 23, 48, 24, 21, 44, 23 }, { 1, 0, 3, 3, 1, 1, 3, 3, 1, 1, 3, 3, 1, 0, 3, 3 } }, + { { 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 0, 15, 0, 0, 0, 0 }, { 10, 62, 15, 7, 62, 15 }, { 2, 2, 2, 3, 3, 3, 3, 0, 0, 0, 0, 1, 0, 1, 1, 1 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 11, 21, 10, 1, 2, 1 }, { 1, 0, 0, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 15, 15, 0, 0, 15, 15, 0, 0, 15, 15, 0, 0, 15, 15, 0, 0 }, { 14, 62, 15, 8, 61, 15 }, { 0, 0, 3, 2, 1, 0, 3, 2, 1, 1, 0, 3, 1, 1, 0, 0 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 27, 56, 27, 26, 53, 26 }, { 3, 3, 3, 3, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 9, 15, 4, 5, 8, 2 }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 3, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 4, 15, 9, 3, 14, 8 }, { 1, 1, 1, 1, 1, 0, 0, 0, 0, 3, 3, 3, 3, 3, 2, 2 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 19, 34, 15, 17, 31, 14 }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 23, 48, 23, 1, 2, 1 }, { 3, 3, 3, 3, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 3 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 5, 10, 5, 1, 2, 1 }, { 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 1, 1, 1, 1 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 19, 38, 18, 7, 14, 7 }, { 2, 2, 2, 2, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 11, 20, 8, 9, 16, 6 }, { 2, 2, 2, 2, 3, 3, 2, 2, 0, 0, 3, 3, 1, 1, 0, 0 } }, + { { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9 }, { 2, 5, 2, 1, 3, 1 }, { 3, 3, 3, 3, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 17, 34, 16, 14, 29, 14 }, { 3, 3, 3, 3, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 17, 36, 17, 10, 21, 10 }, { 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 1, 1 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 5, 17, 2, 4, 15, 1 }, { 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 3, 3, 3, 3 } }, + { { 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12 }, { 22, 46, 21, 20, 43, 19 }, { 1, 0, 0, 3, 0, 3, 3, 3, 3, 3, 3, 3, 2, 2, 3, 3 } }, + { { 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5 }, { 29, 59, 29, 27, 56, 27 }, { 3, 2, 2, 3, 3, 2, 3, 3, 3, 2, 3, 0, 2, 2, 3, 0 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 11, 22, 10, 6, 12, 6 }, { 3, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0 } }, + { { 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 5, 6, 6, 6, 6 }, { 29, 59, 29, 27, 56, 27 }, { 3, 3, 0, 1, 0, 3, 3, 0, 1, 1, 0, 0, 0, 0, 0, 0 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 15, 30, 14, 1, 2, 1 }, { 1, 0, 3, 3, 1, 0, 3, 3, 1, 0, 3, 3, 1, 0, 0, 0 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 11, 28, 15, 7, 21, 11 }, { 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 14, 15, 0, 1, 14, 15, 0, 1, 14, 15, 0, 1, 14, 15, 0, 0 }, { 11, 62, 15, 7, 60, 15 }, { 3, 3, 3, 3, 0, 1, 1, 0, 3, 3, 3, 3, 2, 2, 2, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 27, 49, 22, 26, 47, 22 }, { 3, 0, 0, 1, 3, 3, 0, 1, 3, 3, 3, 0, 3, 3, 3, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 28, 57, 26, 2, 3, 1 }, { 3, 2, 3, 3, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 31, 62, 31, 26, 52, 26 }, { 3, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 0, 20, 13, 0, 15, 11 }, { 3, 0, 0, 1, 3, 3, 3, 3, 2, 2, 2, 3, 2, 2, 2, 2 } }, + { { 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15 }, { 25, 62, 15, 17, 62, 15 }, { 3, 0, 0, 3, 3, 0, 0, 0, 3, 3, 0, 0, 2, 2, 3, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 23, 46, 23, 12, 24, 12 }, { 3, 3, 0, 1, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 24, 49, 24, 19, 38, 19 }, { 3, 3, 2, 2, 0, 0, 3, 3, 1, 1, 0, 0, 1, 1, 1, 1 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 26, 53, 26, 9, 19, 9 }, { 1, 1, 1, 1, 0, 0, 1, 1, 3, 3, 0, 0, 2, 2, 3, 0 } }, + { { 0, 0, 15, 15, 0, 0, 15, 15, 0, 0, 15, 15, 0, 0, 15, 15 }, { 2, 61, 18, 0, 61, 18 }, { 2, 2, 3, 3, 3, 3, 0, 0, 3, 0, 1, 1, 0, 1, 1, 1 } }, + { { 15, 15, 0, 1, 15, 15, 0, 1, 15, 15, 0, 1, 15, 0, 0, 1 }, { 2, 62, 17, 1, 61, 15 }, { 3, 3, 3, 3, 3, 2, 2, 3, 3, 3, 3, 3, 1, 1, 1, 1 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 0, 28, 16, 0, 21, 14 }, { 3, 2, 2, 3, 3, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 13, 26, 13, 6, 11, 5 }, { 3, 3, 0, 1, 3, 3, 3, 0, 3, 2, 3, 3, 3, 2, 2, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 30, 62, 30, 22, 46, 23 }, { 3, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0 } }, + { { 0, 0, 15, 14, 1, 0, 15, 14, 1, 0, 15, 14, 1, 0, 15, 14 }, { 11, 60, 15, 7, 60, 15 }, { 1, 1, 1, 1, 0, 0, 1, 1, 3, 0, 0, 0, 3, 0, 0, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 24, 43, 17, 22, 39, 16 }, { 0, 0, 3, 3, 0, 0, 3, 3, 0, 0, 3, 3, 0, 0, 0, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 25, 50, 23, 22, 44, 20 }, { 1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3, 1, 0, 3, 3 } }, + { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 21, 32, 14, 19, 29, 12 }, { 3, 0, 0, 3, 3, 3, 0, 0, 3, 3, 3, 3, 3, 3, 2, 2 } }, + { { 0, 0, 15, 15, 0, 0, 15, 15, 0, 0, 15, 14, 0, 0, 15, 14 }, { 2, 61, 15, 1, 61, 13 }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 3, 3, 0, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 25, 47, 19, 18, 37, 15 }, { 3, 3, 0, 0, 3, 3, 0, 0, 3, 3, 0, 0, 3, 0, 0, 3 } }, + { { 4, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 }, { 29, 58, 28, 27, 54, 26 }, { 3, 3, 3, 3, 3, 3, 0, 1, 3, 3, 0, 1, 3, 0, 0, 0 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 9, 18, 7, 2, 4, 1 }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0 } }, + { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 18, 32, 13, 17, 31, 13 }, { 3, 2, 0, 1, 3, 2, 0, 1, 3, 3, 0, 1, 3, 3, 0, 1 } }, + { { 0, 0, 0, 15, 0, 0, 15, 15, 0, 15, 15, 15, 15, 15, 15, 15 }, { 8, 61, 15, 5, 61, 15 }, { 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 20, 33, 12, 16, 25, 9 }, { 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { { 5, 5, 5, 4, 5, 5, 4, 4, 5, 5, 4, 4, 5, 5, 4, 4 }, { 28, 56, 28, 25, 51, 25 }, { 1, 1, 1, 1, 1, 1, 1, 0, 0, 3, 3, 3, 3, 3, 3, 3 } }, + { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 3, 60, 11, 1, 57, 8 }, { 3, 0, 1, 1, 3, 0, 0, 0, 3, 3, 0, 0, 3, 3, 0, 0 } }, + { { 15, 15, 0, 0, 15, 15, 0, 0, 15, 15, 0, 0, 15, 15, 0, 0 }, { 18, 62, 15, 15, 61, 16 }, { 1, 0, 0, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 13, 22, 9, 8, 11, 4 }, { 3, 2, 2, 2, 3, 2, 2, 2, 0, 3, 2, 2, 1, 0, 3, 2 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 2, 12, 9, 0, 2, 2 }, { 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 0, 0, 3, 3 } }, + { { 14, 15, 15, 0, 14, 15, 15, 0, 14, 15, 0, 0, 14, 15, 0, 0 }, { 17, 31, 31, 14, 31, 31 }, { 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0 } }, + { { 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3 }, { 24, 48, 23, 21, 43, 21 }, { 3, 2, 2, 2, 0, 3, 3, 3, 1, 0, 3, 3, 1, 0, 0, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 0, 13, 10, 0, 6, 8 }, { 1, 1, 1, 1, 0, 0, 1, 1, 0, 3, 3, 3, 3, 3, 2, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 7, 5, 9, 6, 4, 8 }, { 2, 2, 2, 2, 2, 2, 2, 3, 0, 0, 0, 0, 1, 1, 1, 1 } }, + { { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0 }, { 2, 61, 19, 1, 60, 19 }, { 3, 3, 0, 1, 2, 3, 0, 1, 2, 2, 3, 0, 2, 2, 2, 3 } }, + { { 10, 10, 10, 11, 10, 10, 10, 11, 10, 10, 10, 11, 10, 10, 10, 11 }, { 17, 35, 17, 16, 34, 16 }, { 3, 3, 3, 3, 2, 2, 2, 3, 3, 3, 3, 3, 0, 0, 0, 3 } }, + { { 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 15, 0 }, { 2, 61, 17, 1, 61, 16 }, { 2, 3, 0, 1, 2, 3, 0, 1, 3, 0, 1, 1, 3, 0, 1, 1 } }, + { { 9, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9 }, { 3, 6, 3, 1, 2, 1 }, { 1, 1, 1, 0, 1, 1, 0, 3, 1, 0, 3, 2, 0, 3, 2, 2 } }, + { { 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15 }, { 27, 56, 26, 26, 53, 25 }, { 1, 1, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0 } }, + { { 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 4, 3, 3, 3, 3 }, { 26, 53, 26, 23, 47, 23 }, { 1, 1, 0, 3, 0, 0, 0, 0, 3, 3, 0, 0, 3, 3, 0, 0 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 19, 38, 18, 13, 25, 12 }, { 3, 3, 3, 3, 3, 2, 2, 3, 3, 3, 3, 3, 0, 0, 0, 0 } }, + { { 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, { 20, 40, 20, 18, 36, 18 }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3 } }, + { { 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 24, 44, 19, 22, 40, 17 }, { 1, 1, 0, 0, 1, 1, 0, 3, 1, 0, 3, 2, 1, 0, 3, 2 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 31, 63, 0, 31, 62, 31 }, { 1, 1, 0, 0, 1, 0, 0, 3, 0, 3, 3, 3, 3, 2, 2, 2 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 10, 25, 6, 10, 24, 5 }, { 3, 2, 2, 3, 2, 2, 2, 3, 3, 3, 0, 0, 0, 0, 0, 0 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 23, 44, 18, 14, 30, 12 }, { 3, 0, 0, 3, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1, 1 } }, + { { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 9, 10, 10, 10, 10 }, { 3, 7, 3, 1, 2, 1 }, { 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 14, 28, 12, 4, 8, 3 }, { 1, 0, 2, 3, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 } }, + { { 1, 0, 15, 14, 2, 0, 15, 14, 2, 1, 15, 14, 1, 1, 15, 14 }, { 2, 60, 17, 1, 60, 16 }, { 0, 0, 3, 3, 0, 0, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3 } }, + { { 0, 0, 15, 15, 1, 0, 15, 15, 1, 1, 0, 15, 1, 1, 0, 0 }, { 2, 61, 15, 1, 61, 13 }, { 3, 3, 3, 3, 3, 3, 0, 0, 3, 3, 0, 1, 0, 0, 0, 0 } }, + { { 15, 15, 15, 15, 15, 15, 15, 15, 0, 15, 15, 15, 15, 15, 15, 15 }, { 18, 37, 18, 14, 28, 14 }, { 1, 1, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 2, 2, 2, 2 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 29, 58, 28, 16, 33, 16 }, { 1, 1, 0, 3, 0, 1, 1, 0, 3, 3, 0, 1, 3, 3, 0, 0 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 28, 49, 17, 24, 41, 14 }, { 1, 1, 0, 3, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 22, 38, 12, 16, 25, 7 }, { 3, 0, 0, 1, 3, 0, 0, 1, 0, 3, 3, 3, 0, 0, 3, 3 } }, + { { 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3 }, { 25, 44, 19, 22, 40, 17 }, { 2, 2, 2, 3, 2, 2, 2, 3, 2, 2, 3, 0, 2, 2, 3, 1 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 21, 48, 27, 19, 43, 26 }, { 3, 3, 3, 3, 3, 3, 0, 0, 3, 0, 1, 1, 0, 0, 1, 1 } }, + { { 15, 15, 14, 13, 15, 15, 14, 13, 15, 14, 14, 13, 15, 14, 14, 13 }, { 18, 32, 31, 14, 31, 31 }, { 3, 2, 2, 3, 0, 3, 3, 3, 1, 3, 3, 3, 1, 0, 0, 3 } }, + { { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 24, 41, 16, 23, 39, 15 }, { 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { { 0, 0, 15, 15, 0, 0, 15, 15, 0, 0, 15, 15, 0, 0, 15, 15 }, { 19, 61, 14, 14, 60, 13 }, { 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { { 2, 1, 15, 14, 2, 1, 15, 13, 2, 1, 14, 13, 1, 1, 15, 14 }, { 12, 58, 14, 7, 58, 15 }, { 1, 0, 3, 2, 1, 1, 0, 3, 1, 1, 0, 0, 0, 0, 0, 0 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 17, 29, 11, 9, 14, 4 }, { 3, 3, 2, 2, 0, 3, 3, 2, 1, 0, 3, 3, 1, 0, 0, 0 } }, + { { 15, 15, 15, 0, 15, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1 }, { 2, 61, 17, 1, 60, 16 }, { 3, 3, 3, 3, 3, 3, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0 }, { 17, 53, 15, 2, 45, 12 }, { 3, 2, 2, 3, 3, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 29, 59, 29, 7, 14, 7 }, { 3, 0, 0, 3, 3, 0, 0, 3, 3, 0, 0, 3, 0, 0, 3, 3 } }, + { { 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11 }, { 23, 46, 21, 18, 39, 18 }, { 2, 2, 2, 2, 3, 3, 3, 3, 0, 0, 0, 0, 1, 1, 0, 0 } }, + { { 0, 0, 1, 1, 15, 0, 0, 1, 14, 15, 0, 0, 14, 14, 15, 0 }, { 15, 59, 14, 8, 58, 15 }, { 3, 2, 2, 2, 0, 0, 0, 0, 1, 1, 1, 0, 3, 3, 3, 3 } }, + { { 15, 15, 0, 1, 15, 15, 0, 1, 15, 15, 0, 1, 15, 0, 0, 1 }, { 31, 62, 16, 28, 57, 16 }, { 3, 0, 0, 3, 3, 0, 3, 3, 0, 1, 3, 2, 0, 0, 3, 3 } }, + { { 12, 12, 11, 11, 12, 12, 11, 11, 12, 12, 11, 11, 12, 12, 11, 11 }, { 21, 43, 20, 18, 38, 18 }, { 3, 3, 0, 0, 3, 3, 0, 0, 2, 3, 0, 1, 2, 3, 0, 1 } }, + { { 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 12, 12, 13, 13 }, { 22, 46, 21, 19, 41, 18 }, { 3, 3, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 25, 50, 25, 18, 36, 18 }, { 1, 0, 2, 3, 1, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 0 } }, + { { 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 17, 56, 11, 5, 53, 7 }, { 3, 3, 0, 1, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 0, 15, 14, 14, 0, 0, 15, 15, 0, 0, 0, 15, 0, 1, 0, 0 }, { 16, 59, 14, 7, 58, 14 }, { 3, 3, 3, 3, 0, 0, 3, 3, 1, 1, 0, 3, 0, 0, 0, 3 } }, + { { 11, 11, 11, 11, 11, 11, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11 }, { 16, 32, 21, 15, 31, 20 }, { 3, 0, 0, 1, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 1, 1 } }, + { { 15, 14, 15, 15, 15, 15, 15, 0, 15, 0, 0, 1, 0, 0, 1, 1 }, { 16, 59, 15, 9, 58, 15 }, { 3, 0, 1, 1, 3, 0, 0, 1, 3, 3, 0, 1, 2, 2, 3, 1 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 29, 57, 26, 20, 39, 16 }, { 3, 0, 0, 3, 3, 0, 0, 0, 3, 3, 3, 3, 2, 2, 2, 2 } }, + { { 1, 1, 0, 15, 1, 1, 15, 14, 1, 0, 15, 14, 0, 15, 14, 14 }, { 15, 58, 15, 7, 58, 14 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3 } }, + { { 0, 1, 0, 0, 0, 0, 0, 15, 15, 15, 15, 15, 15, 15, 14, 15 }, { 18, 58, 15, 8, 58, 13 }, { 3, 0, 1, 1, 3, 3, 0, 0, 3, 3, 3, 3, 3, 3, 2, 3 } }, + { { 13, 13, 13, 13, 12, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, 12 }, { 17, 32, 31, 14, 33, 30 }, { 3, 2, 2, 2, 3, 3, 3, 3, 1, 1, 1, 1, 0, 0, 0, 0 } }, + { { 3, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4 }, { 27, 55, 27, 23, 46, 23 }, { 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15 }, { 31, 62, 14, 27, 57, 9 }, { 3, 2, 2, 3, 0, 3, 3, 3, 1, 1, 3, 2, 0, 0, 3, 3 } }, + { { 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 15, 15, 1, 0, 15, 14 }, { 2, 60, 17, 1, 60, 18 }, { 1, 0, 3, 3, 1, 0, 0, 3, 1, 1, 0, 0, 1, 1, 1, 1 } }, + { { 3, 3, 4, 4, 2, 3, 4, 4, 2, 3, 4, 4, 2, 3, 3, 4 }, { 27, 54, 26, 23, 46, 22 }, { 0, 0, 1, 1, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 15, 15, 15, 15, 15, 15, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 17, 33, 16, 15, 31, 15 }, { 0, 0, 1, 1, 3, 3, 0, 0, 3, 3, 3, 3, 2, 2, 3, 3 } }, + { { 9, 9, 9, 9, 9, 9, 9, 9, 10, 9, 9, 9, 10, 9, 9, 9 }, { 3, 5, 3, 1, 1, 1 }, { 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 0, 0, 3, 3 } }, + { { 9, 9, 9, 10, 9, 9, 9, 10, 9, 9, 10, 10, 9, 9, 10, 10 }, { 4, 8, 4, 1, 2, 1 }, { 1, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 1 } }, + { { 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 }, { 21, 34, 15, 19, 30, 13 }, { 3, 0, 0, 3, 3, 3, 3, 3, 0, 3, 3, 3, 1, 0, 3, 0 } }, + { { 14, 14, 0, 1, 14, 14, 0, 1, 14, 15, 1, 2, 15, 0, 1, 2 }, { 16, 59, 15, 9, 57, 15 }, { 3, 0, 0, 3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 } }, + { { 3, 2, 2, 1, 3, 3, 2, 2, 3, 3, 2, 2, 3, 3, 3, 2 }, { 25, 50, 24, 21, 42, 20 }, { 0, 0, 3, 3, 0, 3, 3, 3, 0, 3, 3, 0, 0, 3, 0, 1 } }, + { { 14, 15, 0, 2, 13, 15, 1, 2, 13, 14, 1, 2, 14, 15, 0, 2 }, { 3, 60, 16, 2, 58, 17 }, { 1, 1, 1, 1, 0, 0, 0, 1, 3, 3, 3, 0, 2, 2, 2, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 0, 24, 15, 0, 10, 9 }, { 2, 2, 3, 3, 2, 2, 3, 0, 2, 3, 0, 1, 2, 3, 0, 1 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 16, 25, 8, 3, 4, 1 }, { 0, 0, 1, 1, 3, 0, 1, 1, 2, 3, 0, 0, 2, 2, 3, 0 } }, + { { 0, 0, 0, 0, 15, 0, 0, 0, 15, 0, 0, 1, 15, 0, 0, 0 }, { 18, 35, 17, 16, 33, 16 }, { 1, 1, 0, 0, 1, 0, 0, 3, 0, 0, 3, 2, 3, 3, 2, 2 } }, + { { 14, 15, 1, 2, 14, 14, 1, 2, 13, 14, 1, 2, 13, 14, 0, 1 }, { 16, 59, 15, 8, 56, 15 }, { 1, 0, 3, 3, 0, 0, 3, 3, 0, 3, 3, 3, 0, 0, 0, 3 } }, + { { 14, 15, 0, 1, 14, 15, 0, 1, 14, 14, 0, 1, 14, 14, 15, 0 }, { 21, 54, 16, 4, 51, 16 }, { 1, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15 }, { 10, 60, 16, 9, 57, 22 }, { 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 3, 0, 3, 3, 0, 1 } }, + { { 15, 0, 1, 1, 15, 0, 1, 1, 14, 15, 0, 1, 14, 14, 15, 1 }, { 2, 61, 17, 1, 60, 16 }, { 1, 1, 0, 3, 1, 1, 0, 0, 0, 3, 0, 3, 3, 3, 3, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 16, 27, 9, 13, 21, 7 }, { 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3 } }, + { { 2, 1, 14, 12, 3, 1, 14, 12, 3, 2, 14, 12, 3, 2, 14, 13 }, { 10, 57, 16, 5, 57, 16 }, { 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 1, 35, 19, 0, 30, 17 }, { 0, 3, 2, 2, 3, 2, 2, 2, 3, 2, 2, 3, 2, 2, 2, 3 } }, + { { 15, 15, 15, 0, 15, 15, 0, 0, 15, 0, 0, 1, 15, 0, 1, 1 }, { 25, 58, 12, 11, 54, 10 }, { 1, 1, 0, 0, 1, 1, 0, 0, 3, 3, 0, 0, 2, 2, 3, 3 } }, + { { 10, 11, 11, 12, 10, 10, 11, 11, 10, 10, 10, 11, 9, 10, 10, 10 }, { 8, 16, 8, 2, 5, 3 }, { 3, 3, 3, 0, 3, 3, 0, 0, 3, 3, 0, 0, 2, 3, 0, 0 } }, + { { 0, 0, 1, 1, 15, 0, 0, 1, 15, 15, 0, 0, 14, 15, 15, 0 }, { 26, 59, 13, 13, 54, 11 }, { 0, 0, 0, 0, 1, 1, 1, 0, 3, 3, 3, 3, 2, 2, 2, 2 } }, + { { 13, 13, 14, 13, 12, 12, 13, 12, 12, 11, 11, 12, 11, 11, 11, 11 }, { 13, 26, 13, 5, 10, 5 }, { 3, 0, 0, 0, 3, 0, 0, 0, 3, 3, 0, 1, 3, 0, 0, 1 } }, + { { 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 }, { 19, 39, 19, 15, 30, 15 }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 0, 0, 0 } }, + { { 9, 9, 9, 9, 9, 9, 9, 9, 11, 10, 9, 9, 13, 11, 10, 10 }, { 21, 42, 18, 14, 33, 15 }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 0, 1 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 15, 23, 3, 7, 11, 1 }, { 1, 1, 0, 3, 1, 0, 0, 3, 0, 0, 3, 3, 0, 0, 0, 3 } }, + { { 11, 11, 12, 12, 11, 11, 11, 12, 11, 11, 12, 13, 11, 11, 12, 12 }, { 23, 47, 22, 18, 40, 19 }, { 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 1, 1 } }, + { { 15, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2 }, { 21, 42, 21, 15, 30, 15 }, { 3, 3, 3, 3, 3, 3, 0, 0, 3, 3, 0, 0, 0, 0, 0, 1 } }, + { { 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12 }, { 9, 18, 9, 3, 6, 3 }, { 3, 0, 0, 3, 3, 0, 0, 1, 3, 3, 3, 0, 3, 3, 3, 3 } }, + { { 0, 1, 2, 3, 1, 1, 2, 3, 2, 2, 3, 4, 3, 3, 4, 4 }, { 26, 54, 26, 22, 44, 22 }, { 0, 0, 1, 1, 3, 0, 0, 1, 3, 3, 3, 0, 2, 2, 2, 3 } }, + { { 12, 11, 11, 11, 12, 12, 12, 12, 14, 14, 14, 14, 15, 15, 15, 15 }, { 15, 30, 15, 6, 12, 6 }, { 3, 3, 0, 1, 3, 3, 0, 0, 3, 0, 0, 3, 3, 0, 0, 3 } }, + { { 0, 0, 0, 15, 15, 15, 15, 14, 13, 13, 13, 13, 13, 12, 12, 12 }, { 18, 36, 18, 8, 18, 9 }, { 3, 0, 0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0 } }, + { { 12, 12, 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10 }, { 9, 18, 9, 3, 7, 3 }, { 3, 3, 0, 3, 3, 3, 0, 3, 3, 3, 0, 3, 3, 3, 3, 3 } }, + { { 0, 0, 0, 0, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14 }, { 17, 33, 16, 12, 25, 12 }, { 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0 } }, + { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 15 }, { 21, 32, 4, 21, 30, 4 }, { 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 0, 1, 3, 3, 0, 0 } }, + { { 3, 3, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 0, 0 }, { 23, 47, 23, 17, 34, 17 }, { 3, 0, 0, 1, 3, 3, 0, 1, 2, 2, 3, 0, 2, 2, 3, 0 } }, + { { 2, 3, 3, 3, 2, 2, 3, 3, 1, 1, 2, 2, 0, 0, 1, 1 }, { 24, 49, 24, 18, 37, 18 }, { 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 0, 3, 3, 3, 0 } }, + { { 14, 13, 13, 13, 14, 14, 14, 14, 15, 14, 14, 14, 15, 15, 15, 15 }, { 15, 30, 15, 10, 20, 10 }, { 3, 3, 2, 3, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 17, 38, 23, 9, 25, 17 }, { 0, 0, 1, 1, 0, 0, 0, 0, 3, 3, 3, 3, 2, 2, 2, 2 } }, + { { 0, 15, 14, 14, 0, 15, 14, 14, 0, 0, 15, 14, 0, 0, 15, 15 }, { 18, 53, 17, 3, 53, 17 }, { 1, 1, 0, 3, 0, 0, 1, 0, 3, 3, 0, 1, 3, 3, 3, 0 } }, + { { 10, 10, 11, 13, 9, 10, 11, 11, 9, 9, 10, 10, 9, 9, 9, 10 }, { 23, 45, 18, 14, 34, 15 }, { 3, 3, 2, 3, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 1, 1 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 28, 54, 23, 13, 23, 8 }, { 3, 2, 3, 3, 3, 3, 3, 0, 3, 3, 0, 0, 0, 0, 0, 0 } }, + { { 14, 15, 0, 1, 14, 15, 0, 2, 14, 15, 0, 2, 14, 15, 0, 1 }, { 25, 60, 15, 15, 57, 14 }, { 3, 3, 3, 3, 3, 3, 3, 3, 0, 1, 1, 0, 0, 0, 0, 0 } }, + { { 3, 2, 1, 0, 4, 3, 1, 0, 4, 3, 2, 1, 4, 4, 3, 2 }, { 26, 54, 26, 22, 45, 23 }, { 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 1, 1, 1, 1 } }, + { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 3, 53, 23, 1, 55, 23 }, { 1, 1, 1, 1, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2 } }, + { { 11, 10, 10, 10, 11, 11, 10, 10, 12, 11, 10, 10, 12, 11, 11, 10 }, { 9, 18, 9, 3, 6, 3 }, { 3, 3, 3, 0, 2, 3, 0, 0, 3, 0, 1, 0, 3, 0, 0, 0 } }, + { { 2, 2, 2, 3, 2, 2, 3, 3, 2, 2, 3, 3, 2, 2, 3, 3 }, { 25, 50, 24, 18, 39, 19 }, { 3, 0, 0, 3, 0, 0, 0, 3, 0, 3, 3, 3, 3, 3, 2, 2 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 1, 18, 17, 0, 2, 2 }, { 1, 1, 1, 1, 0, 3, 3, 0, 1, 1, 0, 1, 1, 1, 1, 1 } }, + { { 11, 11, 11, 11, 11, 11, 11, 10, 11, 11, 10, 10, 11, 11, 10, 10 }, { 8, 15, 8, 3, 7, 3 }, { 1, 0, 2, 3, 1, 0, 3, 0, 0, 3, 0, 0, 3, 0, 0, 1 } }, + { { 13, 13, 12, 12, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12 }, { 5, 0, 0, 3, 0, 0 }, { 1, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 3 } }, + { { 12, 12, 12, 12, 13, 13, 12, 12, 14, 14, 14, 14, 14, 14, 14, 14 }, { 17, 27, 30, 14, 26, 30 }, { 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 3, 3, 3, 3 } }, + { { 10, 10, 10, 11, 10, 10, 11, 11, 10, 11, 11, 12, 11, 11, 12, 13 }, { 10, 20, 10, 3, 7, 4 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 3 } }, + { { 0, 0, 15, 15, 0, 15, 15, 15, 15, 15, 14, 14, 15, 14, 14, 14 }, { 15, 54, 19, 6, 55, 19 }, { 3, 3, 0, 3, 3, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 10, 11, 12, 12, 10, 11, 12, 12, 10, 11, 12, 12, 10, 11, 12, 12 }, { 9, 32, 30, 4, 30, 28 }, { 3, 2, 3, 0, 3, 2, 3, 0, 3, 3, 0, 0, 3, 3, 0, 0 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 24, 48, 23, 12, 24, 11 }, { 1, 0, 3, 3, 0, 0, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3 } }, + { { 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11 }, { 7, 14, 7, 4, 8, 4 }, { 3, 0, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 4, 4, 3, 2, 4, 4, 2, 2, 4, 3, 2, 1, 3, 3, 2, 1 }, { 27, 54, 26, 22, 45, 22 }, { 3, 3, 0, 1, 3, 2, 3, 0, 3, 3, 3, 3, 0, 0, 0, 0 } }, + { { 13, 12, 12, 11, 13, 12, 11, 11, 12, 11, 11, 10, 12, 11, 11, 11 }, { 11, 23, 11, 4, 9, 5 }, { 3, 2, 3, 1, 3, 2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 0 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 19, 43, 26, 3, 6, 3 }, { 3, 0, 0, 3, 0, 0, 3, 3, 1, 0, 3, 3, 1, 0, 3, 3 } }, + { { 7, 3, 13, 8, 7, 3, 12, 8, 7, 3, 11, 8, 7, 3, 12, 8 }, { 14, 31, 11, 2, 8, 3 }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 3, 0, 1, 1 } }, + { { 1, 15, 14, 14, 2, 0, 14, 14, 2, 1, 15, 14, 2, 1, 0, 15 }, { 13, 57, 14, 6, 56, 14 }, { 3, 3, 2, 3, 3, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 12, 14, 1, 3, 12, 13, 1, 3, 12, 13, 2, 3, 13, 14, 1, 3 }, { 13, 59, 15, 8, 53, 15 }, { 3, 3, 0, 1, 3, 3, 0, 0, 3, 3, 3, 3, 0, 0, 0, 3 } }, + { { 11, 11, 10, 10, 12, 11, 10, 10, 14, 13, 11, 10, 0, 13, 12, 11 }, { 16, 32, 14, 5, 12, 6 }, { 3, 2, 2, 2, 3, 3, 3, 3, 3, 0, 0, 0, 3, 3, 0, 3 } }, + { { 3, 3, 3, 3, 2, 2, 2, 2, 1, 0, 1, 0, 0, 15, 15, 15 }, { 26, 53, 27, 22, 45, 23 }, { 3, 3, 2, 2, 3, 3, 3, 2, 0, 3, 3, 3, 0, 0, 0, 0 } }, + { { 14, 14, 13, 13, 14, 14, 14, 14, 0, 15, 15, 15, 0, 0, 15, 15 }, { 18, 37, 18, 9, 17, 9 }, { 3, 0, 0, 3, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 0, 14, 14, 14, 0, 15, 15, 14, 1, 1, 0, 15, 2, 2, 1, 0 }, { 3, 59, 17, 2, 58, 17 }, { 3, 3, 0, 0, 3, 3, 0, 1, 3, 3, 0, 0, 0, 0, 0, 0 } }, + { { 8, 11, 1, 7, 8, 12, 1, 7, 8, 13, 2, 7, 8, 13, 3, 7 }, { 14, 29, 10, 1, 4, 2 }, { 3, 3, 0, 3, 3, 0, 0, 3, 3, 0, 0, 3, 3, 0, 0, 3 } }, + { { 15, 15, 0, 0, 14, 14, 15, 15, 12, 12, 13, 13, 11, 11, 12, 12 }, { 19, 38, 18, 7, 16, 8 }, { 0, 3, 2, 2, 0, 3, 2, 2, 1, 0, 3, 2, 1, 0, 3, 2 } }, + { { 14, 14, 15, 0, 14, 15, 0, 1, 15, 0, 1, 2, 0, 1, 2, 2 }, { 2, 60, 17, 1, 58, 17 }, { 0, 0, 0, 3, 0, 0, 0, 0, 3, 3, 0, 0, 3, 3, 0, 0 } }, + { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, { 18, 37, 17, 3, 6, 3 }, { 3, 0, 0, 3, 0, 0, 3, 3, 0, 3, 3, 3, 3, 2, 2, 3 } }, + { { 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 14, 14, 13, 14, 15, 15 }, { 16, 31, 15, 5, 11, 6 }, { 3, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 3, 0, 1, 1 } }, + { { 14, 13, 12, 12, 15, 14, 12, 12, 15, 14, 13, 12, 14, 14, 13, 12 }, { 16, 33, 16, 6, 13, 6 }, { 0, 3, 2, 2, 1, 0, 3, 2, 1, 0, 3, 3, 1, 0, 0, 3 } }, + { { 0, 15, 15, 0, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 4, 4 }, { 27, 54, 27, 22, 45, 22 }, { 1, 1, 0, 3, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 15, 0, 1, 2, 14, 15, 0, 2, 13, 13, 15, 0, 12, 12, 14, 15 }, { 23, 49, 23, 19, 40, 20 }, { 3, 0, 0, 3, 0, 0, 3, 3, 1, 3, 3, 3, 0, 3, 3, 0 } }, + { { 0, 1, 2, 3, 15, 0, 3, 3, 15, 1, 3, 3, 0, 1, 2, 3 }, { 26, 54, 26, 22, 46, 23 }, { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 3 } }, + { { 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15 }, { 21, 49, 22, 3, 50, 20 }, { 3, 0, 3, 3, 0, 0, 3, 3, 0, 3, 3, 3, 3, 2, 3, 3 } }, + { { 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 11, 11 }, { 7, 15, 7, 5, 10, 5 }, { 3, 0, 0, 3, 3, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 14, 14, 15, 0, 14, 14, 15, 0, 14, 15, 15, 0, 15, 15, 0, 0 }, { 21, 52, 20, 4, 51, 19 }, { 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 } }, + { { 13, 12, 11, 11, 14, 13, 12, 12, 0, 15, 14, 13, 2, 2, 0, 15 }, { 23, 47, 22, 18, 37, 18 }, { 0, 0, 0, 0, 0, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { { 14, 15, 15, 0, 14, 14, 15, 15, 13, 14, 15, 15, 13, 14, 14, 15 }, { 17, 34, 17, 9, 19, 10 }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 1, 3, 3, 0, 1 } }, + { { 0, 13, 12, 12, 14, 13, 12, 11, 13, 12, 11, 11, 12, 12, 11, 11 }, { 17, 34, 16, 5, 11, 5 }, { 3, 3, 3, 3, 0, 3, 3, 3, 0, 3, 2, 3, 0, 3, 2, 3 } }, + { { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, { 29, 56, 21, 5, 7, 1 }, { 3, 0, 0, 3, 3, 0, 0, 0, 3, 3, 0, 1, 2, 2, 0, 1 } }, + { { 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 11, 10, 11, 12, 13 }, { 21, 42, 19, 15, 33, 15 }, { 3, 2, 2, 2, 0, 0, 0, 0, 3, 3, 0, 3, 3, 3, 3, 3 } }, + { { 11, 12, 13, 15, 10, 11, 12, 13, 10, 10, 12, 12, 10, 10, 11, 11 }, { 13, 26, 12, 4, 8, 4 }, { 0, 0, 0, 3, 0, 0, 3, 3, 3, 3, 3, 3, 2, 2, 2, 3 } }, + { { 7, 7, 7, 6, 2, 2, 1, 0, 15, 14, 13, 12, 9, 9, 8, 8 }, { 20, 41, 18, 5, 11, 6 }, { 0, 3, 3, 3, 0, 3, 3, 0, 0, 3, 3, 0, 3, 3, 0, 0 } }, + { { 11, 11, 13, 14, 11, 12, 14, 15, 12, 13, 15, 1, 13, 14, 0, 2 }, { 23, 47, 22, 17, 37, 18 }, { 1, 0, 2, 3, 0, 3, 3, 3, 3, 3, 3, 0, 3, 0, 0, 0 } }, + { { 12, 12, 12, 11, 14, 15, 14, 14, 1, 1, 1, 0, 2, 3, 3, 2 }, { 18, 37, 17, 5, 12, 7 }, { 3, 2, 3, 3, 2, 2, 3, 0, 3, 3, 3, 0, 3, 3, 0, 1 } }, + { { 10, 10, 11, 12, 10, 10, 12, 13, 10, 11, 13, 14, 11, 12, 13, 1 }, { 17, 36, 16, 5, 9, 5 }, { 1, 0, 0, 1, 0, 3, 3, 0, 0, 3, 3, 3, 0, 0, 0, 0 } }, + { { 0, 15, 14, 13, 1, 0, 14, 13, 1, 0, 14, 13, 1, 0, 14, 13 }, { 14, 50, 19, 4, 50, 19 }, { 3, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 2, 3, 0 } }, + { { 5, 5, 3, 0, 4, 3, 1, 15, 0, 15, 13, 11, 14, 12, 9, 9 }, { 16, 33, 14, 7, 17, 9 }, { 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 1, 0, 3, 3 } }, + { { 2, 15, 12, 11, 13, 12, 11, 11, 11, 11, 10, 10, 11, 10, 10, 10 }, { 19, 40, 18, 13, 29, 14 }, { 3, 3, 3, 3, 0, 3, 3, 3, 0, 3, 3, 3, 0, 3, 3, 3 } }, + { { 9, 8, 8, 8, 13, 12, 11, 11, 0, 0, 15, 15, 6, 7, 6, 6 }, { 16, 33, 14, 7, 17, 9 }, { 3, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } }, + { { 3, 3, 2, 2, 3, 2, 2, 2, 3, 2, 2, 2, 3, 3, 2, 2 }, { 15, 31, 15, 14, 30, 15 }, { 0, 0, 0, 3, 0, 1, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0 } }, +}; + +inline constexpr Bc6State BC6_DICTIONARY[255] = { + { { { 32768, 33088, 32768 }, { 32768, 32768, 32768 }, { 32768, 32768, 32768 }, { 32768, 32768, 32768 } }, { 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 } }, + { { { 62592, 62592, 59520 }, { 32768, 32768, 32768 }, { 32768, 32768, 32768 }, { 32768, 32768, 32768 } }, { 32768, 24576, 32768, 24576, 24576, 24576, 24576, 24576, 32768, 24576, 32768, 24576, 24576, 24576, 24576, 24576 } }, + { { { 32768, 33536, 62336 }, { 32768, 32768, 32768 }, { 32768, 32768, 32768 }, { 32768, 32768, 32768 } }, { 32768, 24576, 32768, 24576, 32768, 24576, 32768, 24576, 32768, 24576, 32768, 24576, 32768, 24576, 32768, 24576 } }, + { { { 62144, 32768, 32768 }, { 32768, 32768, 32768 }, { 32768, 32768, 32768 }, { 32768, 32768, 32768 } }, { 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 } }, + { { { 32768, 32768, 32768 }, { 32768, 32768, 63488 }, { 32768, 32768, 32768 }, { 32768, 32768, 63488 } }, { 32768, 0, 24576, 57344, 40960, 8192, 16384, 49152, 49152, 16384, 8192, 40960, 57344, 24576, 0, 32768 } }, + { { { 58176, 58176, 57856 }, { 34816, 36864, 36864 }, { 32768, 32768, 32768 }, { 32768, 32768, 32768 } }, { 32768, 16384, 16384, 40960, 32768, 16384, 16384, 40960, 32768, 16384, 16384, 40960, 40960, 16384, 16384, 40960 } }, + { { { 53760, 52992, 52480 }, { 37888, 43008, 45056 }, { 39936, 47104, 45056 }, { 38912, 43008, 43008 } }, { 40960, 32768, 32768, 24576, 40960, 32768, 32768, 24576, 40960, 32768, 32768, 24576, 40960, 32768, 32768, 24576 } }, + { { { 64128, 64128, 64256 }, { 32768, 32768, 32768 }, { 32768, 32768, 32768 }, { 32768, 32768, 32768 } }, { 49152, 24576, 8192, 32768, 49152, 16384, 8192, 40960, 40960, 8192, 16384, 49152, 32768, 8192, 24576, 49152 } }, + { { { 52864, 54688, 52000 }, { 34816, 36864, 36864 }, { 34816, 36864, 36864 }, { 32768, 36864, 36864 } }, { 32768, 32768, 32768, 32768, 24576, 24576, 24576, 24576, 32768, 32768, 32768, 32768, 24576, 24576, 24576, 24576 } }, + { { { 52608, 54272, 51840 }, { 34816, 40960, 36864 }, { 36864, 36864, 36864 }, { 34816, 36864, 36864 } }, { 32768, 49152, 0, 16384, 40960, 57344, 8192, 24576, 24576, 8192, 57344, 40960, 16384, 0, 49152, 32768 } }, + { { { 63904, 63936, 63968 }, { 34816, 36864, 36864 }, { 34816, 36864, 36864 }, { 32768, 32768, 36864 } }, { 32768, 40960, 24576, 16384, 49152, 57344, 8192, 0, 0, 8192, 57344, 49152, 16384, 24576, 40960, 32768 } }, + { { { 48768, 49024, 51456 }, { 32768, 32768, 32768 }, { 32768, 32768, 32768 }, { 32768, 32768, 32768 } }, { 32768, 16384, 57344, 24576, 32768, 16384, 57344, 24576, 32768, 16384, 57344, 24576, 32768, 16384, 57344, 24576 } }, + { { { 57344, 57344, 55296 }, { 26624, 26624, 25600 }, { 22528, 22528, 21504 }, { 25600, 25600, 25600 } }, { 40960, 32768, 16384, 24576, 57344, 49152, 0, 8192, 8192, 0, 49152, 57344, 24576, 16384, 32768, 40960 } }, + { { { 55936, 55936, 54272 }, { 20480, 22528, 20480 }, { 12288, 16384, 16384 }, { 18432, 20480, 20480 } }, { 32768, 0, 24576, 57344, 40960, 8192, 16384, 49152, 49152, 16384, 8192, 40960, 57344, 24576, 0, 32768 } }, + { { { 51712, 51200, 53248 }, { 38912, 45056, 45056 }, { 36864, 40960, 38912 }, { 37888, 43008, 43008 } }, { 32768, 0, 32768, 24576, 32768, 0, 32768, 24576, 32768, 0, 32768, 24576, 32768, 0, 32768, 24576 } }, + { { { 53600, 54240, 53152 }, { 34816, 36864, 36864 }, { 34816, 36864, 36864 }, { 34816, 36864, 36864 } }, { 32768, 57344, 16384, 16384, 57344, 8192, 16384, 8192, 8192, 16384, 8192, 49152, 16384, 8192, 57344, 32768 } }, + { { { 57088, 56704, 55552 }, { 20480, 20480, 20480 }, { 14336, 16384, 16384 }, { 18432, 20480, 20480 } }, { 32768, 40960, 49152, 57344, 57344, 8192, 16384, 24576, 24576, 16384, 8192, 0, 57344, 49152, 40960, 32768 } }, + { { { 56576, 56320, 54784 }, { 26624, 20480, 20480 }, { 23552, 14336, 16384 }, { 26624, 18432, 20480 } }, { 32768, 49152, 8192, 16384, 57344, 8192, 16384, 8192, 16384, 16384, 0, 49152, 16384, 0, 49152, 32768 } }, + { { { 56064, 56064, 54528 }, { 26624, 20480, 18432 }, { 24576, 14336, 16384 }, { 26624, 18432, 20480 } }, { 57344, 57344, 0, 8192, 57344, 57344, 0, 0, 0, 0, 57344, 57344, 0, 0, 57344, 57344 } }, + { { { 57280, 58944, 55168 }, { 24576, 24576, 24576 }, { 18432, 16384, 12288 }, { 22528, 20480, 20480 } }, { 32768, 16384, 16384, 40960, 40960, 16384, 16384, 40960, 40960, 16384, 16384, 40960, 40960, 16384, 16384, 40960 } }, + { { { 56576, 56448, 55424 }, { 45056, 45056, 43008 }, { 49152, 49152, 47104 }, { 43008, 43008, 43008 } }, { 32768, 40960, 40960, 40960, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 40960, 40960, 40960, 40960 } }, + { { { 55552, 57024, 55296 }, { 40960, 38912, 40960 }, { 45056, 43008, 43008 }, { 40960, 38912, 40960 } }, { 32768, 40960, 40960, 57344, 40960, 49152, 57344, 0, 49152, 0, 8192, 16384, 8192, 16384, 16384, 24576 } }, + { { { 60032, 61056, 59136 }, { 22528, 22528, 20480 }, { 18432, 18432, 14336 }, { 20480, 24576, 20480 } }, { 40960, 57344, 8192, 24576, 32768, 49152, 0, 16384, 16384, 0, 49152, 32768, 24576, 8192, 57344, 40960 } }, + { { { 59520, 59840, 59008 }, { 18432, 18432, 18432 }, { 22528, 22528, 22528 }, { 14336, 20480, 20480 } }, { 49152, 0, 49152, 16384, 40960, 0, 49152, 16384, 40960, 0, 49152, 16384, 40960, 0, 49152, 16384 } }, + { { { 54912, 54656, 53504 }, { 49152, 47104, 49152 }, { 14336, 22528, 24576 }, { 47104, 43008, 43008 } }, { 32768, 40960, 40960, 40960, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 40960, 40960, 40960, 40960 } }, + { { { 60800, 60992, 62656 }, { 45056, 45056, 36864 }, { 40960, 40960, 34816 }, { 38912, 38912, 34816 } }, { 49152, 49152, 40960, 40960, 16384, 16384, 8192, 8192, 8192, 8192, 16384, 16384, 40960, 40960, 40960, 49152 } }, + { { { 63936, 64320, 64640 }, { 38912, 57344, 53248 }, { 38912, 61440, 49152 }, { 36864, 61440, 57344 } }, { 49152, 0, 8192, 16384, 40960, 40960, 49152, 57344, 57344, 49152, 40960, 40960, 16384, 8192, 0, 49152 } }, + { { { 56064, 55808, 55040 }, { 16384, 16384, 16384 }, { 18432, 20480, 22528 }, { 40960, 40960, 36864 } }, { 32768, 40960, 49152, 0, 0, 8192, 16384, 24576, 16384, 16384, 8192, 0, 0, 49152, 40960, 40960 } }, + { { { 56320, 55808, 54272 }, { 24576, 24576, 22528 }, { 26624, 25600, 24576 }, { 24576, 23552, 21504 } }, { 32768, 49152, 0, 16384, 49152, 0, 16384, 16384, 0, 16384, 16384, 0, 16384, 16384, 0, 32768 } }, + { { { 54912, 53952, 51584 }, { 24576, 22528, 24576 }, { 18432, 16384, 20480 }, { 20480, 22528, 24576 } }, { 49152, 40960, 16384, 16384, 0, 57344, 0, 8192, 8192, 0, 49152, 57344, 16384, 16384, 40960, 40960 } }, + { { { 54976, 51200, 50112 }, { 20480, 22528, 22528 }, { 20480, 16384, 18432 }, { 22528, 22528, 22528 } }, { 32768, 40960, 40960, 49152, 40960, 49152, 57344, 8192, 49152, 0, 8192, 16384, 8192, 16384, 16384, 16384 } }, + { { { 54016, 54016, 51968 }, { 38912, 49152, 53248 }, { 27648, 22528, 8192 }, { 36864, 45056, 51200 } }, { 32768, 49152, 0, 16384, 49152, 0, 16384, 16384, 8192, 16384, 16384, 0, 16384, 16384, 57344, 32768 } }, + { { { 52992, 53248, 51456 }, { 25600, 14336, 14336 }, { 26624, 16384, 16384 }, { 35840, 38912, 51200 } }, { 57344, 57344, 49152, 40960, 0, 57344, 57344, 49152, 0, 57344, 57344, 49152, 0, 57344, 57344, 57344 } }, + { { { 59456, 60480, 57152 }, { 38912, 36864, 36864 }, { 40960, 40960, 45056 }, { 38912, 36864, 40960 } }, { 49152, 0, 8192, 16384, 40960, 57344, 8192, 16384, 16384, 0, 49152, 40960, 16384, 8192, 57344, 40960 } }, + { { { 61824, 62080, 60992 }, { 34816, 34816, 24576 }, { 34816, 34816, 18432 }, { 34816, 32768, 24576 } }, { 57344, 40960, 49152, 16384, 0, 40960, 49152, 8192, 8192, 49152, 40960, 57344, 16384, 57344, 40960, 49152 } }, + { { { 55552, 54528, 53760 }, { 27648, 14336, 10240 }, { 37888, 51200, 53248 }, { 36864, 45056, 51200 } }, { 40960, 49152, 0, 24576, 49152, 40960, 49152, 8192, 8192, 49152, 40960, 49152, 24576, 0, 49152, 40960 } }, + { { { 54528, 54528, 53632 }, { 16384, 16384, 14336 }, { 16384, 20480, 20480 }, { 14336, 20480, 18432 } }, { 40960, 49152, 8192, 24576, 49152, 32768, 49152, 8192, 8192, 49152, 32768, 49152, 24576, 8192, 49152, 40960 } }, + { { { 55040, 55040, 53504 }, { 25600, 14336, 14336 }, { 36864, 40960, 43008 }, { 27648, 16384, 16384 } }, { 32768, 8192, 16384, 0, 49152, 16384, 16384, 57344, 8192, 16384, 8192, 40960, 16384, 16384, 0, 32768 } }, + { { { 54272, 54272, 52480 }, { 25600, 14336, 16384 }, { 26624, 18432, 20480 }, { 25600, 14336, 18432 } }, { 32768, 49152, 0, 16384, 40960, 57344, 8192, 16384, 49152, 0, 16384, 57344, 57344, 8192, 16384, 40960 } }, + { { { 62272, 32768, 61440 }, { 32768, 32768, 34816 }, { 32768, 32768, 38912 }, { 32768, 32768, 36864 } }, { 57344, 8192, 16384, 16384, 40960, 49152, 0, 8192, 40960, 40960, 49152, 0, 16384, 57344, 40960, 40960 } }, + { { { 52736, 51712, 51200 }, { 37888, 38912, 37888 }, { 44032, 46080, 44032 }, { 38912, 39936, 38912 } }, { 57344, 16384, 57344, 40960, 57344, 8192, 57344, 40960, 49152, 0, 0, 40960, 40960, 0, 8192, 49152 } }, + { { { 59232, 59296, 55744 }, { 36864, 40960, 40960 }, { 36864, 45056, 40960 }, { 34816, 40960, 40960 } }, { 57344, 49152, 32768, 32768, 57344, 57344, 32768, 32768, 57344, 57344, 32768, 32768, 0, 57344, 40960, 32768 } }, + { { { 56704, 57536, 55488 }, { 22528, 20480, 16384 }, { 26624, 24576, 20480 }, { 26624, 24576, 24576 } }, { 32768, 40960, 49152, 57344, 49152, 57344, 8192, 16384, 8192, 16384, 16384, 16384, 16384, 16384, 57344, 40960 } }, + { { { 59552, 32800, 32800 }, { 59392, 32768, 32768 }, { 59392, 32768, 32768 }, { 57344, 32768, 32768 } }, { 32768, 0, 16384, 16384, 8192, 16384, 16384, 8192, 16384, 8192, 57344, 49152, 57344, 49152, 40960, 40960 } }, + { { { 57600, 57856, 56448 }, { 40960, 40960, 43008 }, { 43008, 43008, 45056 }, { 40960, 40960, 43008 } }, { 57344, 49152, 40960, 40960, 8192, 0, 57344, 57344, 16384, 16384, 8192, 8192, 16384, 8192, 49152, 40960 } }, + { { { 40960, 38912, 36864 }, { 38912, 36864, 37888 }, { 38912, 35840, 34816 }, { 38912, 36864, 35840 } }, { 57344, 16384, 49152, 16384, 49152, 8192, 49152, 8192, 40960, 8192, 40960, 0, 40960, 0, 40960, 49152 } }, + { { { 57856, 57856, 56320 }, { 18432, 17408, 15360 }, { 16384, 14336, 13312 }, { 19456, 18432, 16384 } }, { 32768, 49152, 8192, 16384, 40960, 49152, 0, 16384, 40960, 57344, 0, 16384, 40960, 8192, 8192, 16384 } }, + { { { 41984, 37888, 36864 }, { 39936, 35840, 35840 }, { 39936, 35840, 34816 }, { 40960, 36864, 36864 } }, { 32768, 16384, 16384, 16384, 49152, 0, 8192, 8192, 8192, 49152, 49152, 49152, 16384, 40960, 40960, 40960 } }, + { { { 57600, 57344, 55552 }, { 18432, 16384, 17408 }, { 18432, 18432, 17408 }, { 18432, 18432, 17408 } }, { 32768, 16384, 49152, 40960, 0, 16384, 49152, 40960, 16384, 16384, 49152, 40960, 16384, 8192, 49152, 40960 } }, + { { { 47104, 46080, 41984 }, { 51200, 50176, 45056 }, { 54272, 52224, 50176 }, { 52224, 50176, 44032 } }, { 32768, 40960, 0, 16384, 40960, 49152, 8192, 16384, 40960, 0, 16384, 8192, 57344, 8192, 16384, 40960 } }, + { { { 62144, 62592, 63488 }, { 45056, 43008, 43008 }, { 43008, 43008, 43008 }, { 38912, 38912, 38912 } }, { 32768, 8192, 16384, 8192, 16384, 16384, 8192, 57344, 16384, 0, 49152, 40960, 0, 57344, 40960, 40960 } }, + { { { 49664, 49664, 48128 }, { 23552, 23552, 22528 }, { 23552, 24576, 23552 }, { 43008, 38912, 39936 } }, { 32768, 57344, 16384, 16384, 16384, 16384, 8192, 8192, 49152, 49152, 49152, 49152, 40960, 40960, 40960, 40960 } }, + { { { 59008, 58752, 58240 }, { 18432, 20480, 18432 }, { 45056, 38912, 38912 }, { 18432, 22528, 22528 } }, { 32768, 40960, 40960, 40960, 49152, 57344, 57344, 57344, 16384, 16384, 16384, 16384, 16384, 8192, 49152, 40960 } }, + { { { 49664, 46592, 47104 }, { 37888, 36864, 36864 }, { 38912, 38912, 37888 }, { 36864, 35840, 34816 } }, { 32768, 40960, 40960, 57344, 40960, 49152, 0, 8192, 57344, 0, 16384, 16384, 16384, 16384, 0, 40960 } }, + { { { 47104, 45056, 46592 }, { 39936, 38912, 37888 }, { 36864, 35840, 34816 }, { 38912, 37888, 37888 } }, { 32768, 32768, 32768, 40960, 16384, 16384, 16384, 16384, 40960, 40960, 40960, 40960, 16384, 16384, 24576, 24576 } }, + { { { 58112, 57536, 56768 }, { 47104, 45056, 47104 }, { 18432, 20480, 16384 }, { 18432, 20480, 18432 } }, { 32768, 49152, 57344, 8192, 16384, 49152, 0, 16384, 16384, 0, 57344, 16384, 8192, 0, 49152, 40960 } }, + { { { 59392, 59712, 59776 }, { 16384, 18432, 12288 }, { 16384, 20480, 20480 }, { 14336, 26624, 36864 } }, { 57344, 40960, 57344, 16384, 8192, 49152, 49152, 16384, 16384, 49152, 40960, 0, 16384, 57344, 40960, 49152 } }, + { { { 544, 1408, 2112 }, { 20480, 16384, 16384 }, { 22528, 16384, 12288 }, { 22528, 16384, 16384 } }, { 32768, 16384, 8192, 57344, 0, 16384, 0, 49152, 16384, 8192, 57344, 40960, 16384, 0, 49152, 32768 } }, + { { { 32768, 32768, 58752 }, { 34816, 32768, 53248 }, { 34816, 32768, 53248 }, { 34816, 32768, 49152 } }, { 57344, 40960, 0, 16384, 16384, 8192, 8192, 16384, 57344, 57344, 57344, 0, 49152, 40960, 40960, 40960 } }, + { { { 58304, 58176, 60416 }, { 47104, 43008, 43008 }, { 47104, 43008, 43008 }, { 49152, 36864, 28672 } }, { 57344, 57344, 57344, 57344, 57344, 57344, 57344, 57344, 49152, 57344, 57344, 57344, 49152, 57344, 57344, 57344 } }, + { { { 53760, 53760, 40448 }, { 19456, 22528, 32768 }, { 17408, 16384, 34816 }, { 18432, 20480, 34816 } }, { 57344, 0, 16384, 16384, 40960, 40960, 49152, 49152, 0, 8192, 16384, 16384, 40960, 40960, 49152, 49152 } }, + { { { 53504, 53760, 51712 }, { 38912, 53248, 55296 }, { 36864, 49152, 51200 }, { 28672, 22528, 20480 } }, { 57344, 8192, 16384, 8192, 49152, 57344, 16384, 0, 40960, 57344, 8192, 49152, 40960, 57344, 16384, 40960 } }, + { { { 58304, 57536, 56768 }, { 18432, 18432, 16384 }, { 22528, 20480, 20480 }, { 38912, 38912, 38912 } }, { 32768, 8192, 57344, 40960, 49152, 16384, 57344, 40960, 8192, 16384, 0, 40960, 16384, 16384, 8192, 49152 } }, + { { { 51200, 50176, 51200 }, { 57344, 57344, 57344 }, { 57344, 59392, 58368 }, { 57344, 58368, 57344 } }, { 32768, 16384, 32768, 24576, 32768, 16384, 32768, 24576, 32768, 16384, 32768, 24576, 32768, 16384, 40960, 24576 } }, + { { { 53728, 50624, 50240 }, { 20480, 12288, 16384 }, { 20480, 12288, 12288 }, { 22528, 16384, 16384 } }, { 32768, 49152, 0, 16384, 16384, 8192, 57344, 49152, 16384, 8192, 57344, 40960, 8192, 8192, 57344, 40960 } }, + { { { 53888, 53760, 52864 }, { 16384, 18432, 14336 }, { 43008, 40960, 43008 }, { 16384, 20480, 16384 } }, { 57344, 49152, 49152, 40960, 16384, 16384, 8192, 0, 57344, 49152, 49152, 40960, 16384, 8192, 0, 49152 } }, + { { { 60928, 60928, 61312 }, { 47104, 49152, 45056 }, { 43008, 43008, 40960 }, { 40960, 43008, 40960 } }, { 40960, 40960, 40960, 40960, 49152, 49152, 57344, 49152, 16384, 16384, 16384, 16384, 16384, 0, 49152, 40960 } }, + { { { 49920, 50176, 48640 }, { 39936, 51200, 53248 }, { 35840, 57344, 24576 }, { 39936, 47104, 47104 } }, { 57344, 16384, 57344, 49152, 8192, 16384, 57344, 49152, 16384, 16384, 57344, 40960, 8192, 8192, 49152, 40960 } }, + { { { 59584, 60384, 61888 }, { 4096, 8192, 10240 }, { 4096, 8192, 16384 }, { 0, 4096, 6144 } }, { 57344, 32768, 57344, 40960, 0, 40960, 0, 40960, 8192, 40960, 8192, 49152, 16384, 49152, 16384, 49152 } }, + { { { 49664, 48128, 46592 }, { 38912, 39936, 39936 }, { 35840, 36864, 35840 }, { 40960, 43008, 45056 } }, { 32768, 32768, 32768, 57344, 32768, 32768, 32768, 57344, 32768, 32768, 32768, 0, 32768, 32768, 32768, 8192 } }, + { { { 59136, 60000, 61760 }, { 57344, 53248, 55296 }, { 61440, 57344, 55296 }, { 61440, 53248, 45056 } }, { 32768, 40960, 40960, 16384, 40960, 49152, 0, 16384, 40960, 49152, 8192, 16384, 40960, 49152, 8192, 16384 } }, + { { { 59584, 60160, 60416 }, { 14336, 20480, 12288 }, { 10240, 26624, 36864 }, { 16384, 20480, 20480 } }, { 49152, 0, 8192, 16384, 40960, 49152, 0, 8192, 40960, 49152, 57344, 8192, 40960, 40960, 40960, 49152 } }, + { { { 57472, 56960, 56192 }, { 47104, 45056, 43008 }, { 14336, 18432, 22528 }, { 16384, 18432, 20480 } }, { 32768, 40960, 40960, 40960, 0, 0, 0, 40960, 16384, 16384, 8192, 49152, 16384, 16384, 16384, 49152 } }, + { { { 58048, 57984, 57280 }, { 47104, 45056, 47104 }, { 16384, 22528, 22528 }, { 47104, 43008, 43008 } }, { 49152, 49152, 40960, 40960, 16384, 16384, 8192, 0, 57344, 0, 16384, 16384, 40960, 40960, 49152, 49152 } }, + { { { 32768, 59392, 32768 }, { 34816, 0, 32768 }, { 34816, 0, 32768 }, { 34816, 0, 32768 } }, { 32768, 8192, 16384, 8192, 40960, 8192, 16384, 8192, 40960, 8192, 16384, 8192, 40960, 0, 8192, 40960 } }, + { { { 55552, 55200, 53120 }, { 28672, 8192, 8192 }, { 34816, 36864, 40960 }, { 34816, 36864, 40960 } }, { 32768, 49152, 8192, 16384, 40960, 57344, 8192, 16384, 40960, 57344, 8192, 8192, 40960, 40960, 49152, 40960 } }, + { { { 54912, 54528, 53632 }, { 49152, 49152, 49152 }, { 45056, 43008, 40960 }, { 22528, 22528, 22528 } }, { 32768, 57344, 8192, 16384, 8192, 16384, 16384, 16384, 16384, 8192, 16384, 8192, 40960, 40960, 40960, 40960 } }, + { { { 56576, 56064, 54528 }, { 37888, 47104, 49152 }, { 26624, 12288, 10240 }, { 26624, 18432, 16384 } }, { 57344, 49152, 40960, 49152, 8192, 8192, 8192, 8192, 16384, 8192, 8192, 8192, 0, 57344, 40960, 40960 } }, + { { { 58848, 59712, 62208 }, { 49152, 0, 8192 }, { 53248, 63488, 4096 }, { 53248, 2048, 24576 } }, { 49152, 40960, 40960, 40960, 8192, 57344, 49152, 40960, 16384, 8192, 57344, 40960, 16384, 16384, 8192, 49152 } }, + { { { 44544, 38912, 41728 }, { 59392, 47104, 47104 }, { 57344, 34816, 30720 }, { 57344, 45056, 47104 } }, { 32768, 49152, 16384, 16384, 40960, 49152, 8192, 16384, 49152, 49152, 0, 8192, 16384, 0, 49152, 49152 } }, + { { { 54080, 53952, 52352 }, { 36864, 36864, 36864 }, { 38912, 38912, 38912 }, { 36864, 36864, 36864 } }, { 57344, 49152, 57344, 0, 49152, 49152, 8192, 8192, 49152, 57344, 16384, 16384, 16384, 8192, 57344, 40960 } }, + { { { 52096, 51712, 50688 }, { 49152, 49152, 49152 }, { 55296, 53248, 53248 }, { 47104, 49152, 47104 } }, { 32768, 49152, 0, 16384, 40960, 49152, 0, 16384, 49152, 49152, 57344, 8192, 24576, 57344, 40960, 40960 } }, + { { { 55424, 55424, 54912 }, { 12288, 16384, 16384 }, { 51200, 36864, 30720 }, { 14336, 18432, 16384 } }, { 32768, 49152, 4096, 20480, 36864, 53248, 8192, 20480, 40960, 57344, 12288, 24576, 45056, 61440, 12288, 24576 } }, + { { { 57344, 57344, 56320 }, { 37888, 37888, 39936 }, { 20480, 21504, 21504 }, { 22528, 24576, 22528 } }, { 32768, 49152, 8192, 16384, 40960, 49152, 49152, 57344, 16384, 16384, 16384, 8192, 49152, 49152, 49152, 40960 } }, + { { { 49152, 49152, 48128 }, { 45056, 45056, 46080 }, { 27648, 27648, 26624 }, { 38912, 39936, 38912 } }, { 40960, 57344, 8192, 16384, 16384, 40960, 57344, 8192, 49152, 16384, 40960, 57344, 32768, 57344, 16384, 49152 } }, + { { { 54656, 53632, 52128 }, { 40960, 45056, 45056 }, { 38912, 40960, 45056 }, { 26624, 12288, 28672 } }, { 57344, 8192, 49152, 57344, 49152, 0, 8192, 0, 40960, 49152, 8192, 16384, 40960, 49152, 0, 16384 } }, + { { { 55936, 55488, 54208 }, { 47104, 47104, 47104 }, { 55296, 55296, 55296 }, { 43008, 43008, 43008 } }, { 32768, 49152, 16384, 16384, 40960, 57344, 16384, 0, 40960, 57344, 16384, 49152, 40960, 49152, 16384, 40960 } }, + { { { 1664, 2528, 3264 }, { 43008, 45056, 45056 }, { 40960, 40960, 45056 }, { 38912, 40960, 40960 } }, { 57344, 8192, 16384, 57344, 40960, 8192, 8192, 49152, 49152, 8192, 57344, 40960, 16384, 8192, 57344, 40960 } }, + { { { 51200, 53248, 53248 }, { 52224, 54272, 53248 }, { 33792, 33792, 33792 }, { 39936, 40960, 40960 } }, { 57344, 40960, 40960, 16384, 8192, 57344, 40960, 49152, 16384, 8192, 57344, 40960, 16384, 16384, 8192, 49152 } }, + { { { 58944, 60352, 61248 }, { 47104, 45056, 43008 }, { 47104, 36864, 26624 }, { 47104, 43008, 47104 } }, { 40960, 40960, 40960, 49152, 8192, 16384, 16384, 16384, 16384, 8192, 57344, 40960, 16384, 8192, 57344, 40960 } }, + { { { 63712, 64704, 256 }, { 59392, 61440, 61440 }, { 20480, 4096, 4096 }, { 40960, 49152, 49152 } }, { 49152, 40960, 49152, 8192, 40960, 49152, 57344, 16384, 40960, 0, 8192, 16384, 49152, 0, 8192, 16384 } }, + { { { 54432, 55072, 52512 }, { 34816, 45056, 24576 }, { 34816, 40960, 16384 }, { 34816, 40960, 4096 } }, { 57344, 49152, 40960, 40960, 8192, 0, 57344, 49152, 49152, 8192, 8192, 0, 40960, 0, 16384, 16384 } }, + { { { 56320, 56000, 55104 }, { 47104, 47104, 47104 }, { 43008, 43008, 43008 }, { 24576, 22528, 24576 } }, { 57344, 0, 16384, 8192, 57344, 49152, 8192, 0, 40960, 49152, 49152, 40960, 49152, 16384, 57344, 40960 } }, + { { { 59872, 59776, 59072 }, { 24576, 4096, 61440 }, { 24576, 8192, 61440 }, { 26624, 4096, 57344 } }, { 32768, 40960, 0, 16384, 8192, 8192, 16384, 16384, 49152, 57344, 57344, 0, 40960, 40960, 40960, 49152 } }, + { { { 36352, 24576, 1024 }, { 10240, 6144, 5120 }, { 53248, 57344, 59392 }, { 10240, 7168, 6144 } }, { 32768, 0, 57344, 16384, 49152, 16384, 49152, 8192, 57344, 16384, 40960, 57344, 57344, 16384, 40960, 40960 } }, + { { { 59328, 59776, 59776 }, { 49152, 40960, 47104 }, { 45056, 43008, 47104 }, { 6144, 28672, 36864 } }, { 57344, 49152, 40960, 40960, 40960, 0, 57344, 57344, 49152, 0, 8192, 8192, 8192, 8192, 8192, 16384 } }, + { { { 55168, 55296, 54912 }, { 8192, 10240, 14336 }, { 14336, 18432, 16384 }, { 49152, 36864, 28672 } }, { 57344, 49152, 40960, 49152, 8192, 57344, 57344, 16384, 16384, 0, 0, 8192, 49152, 40960, 49152, 49152 } }, + { { { 57536, 57024, 56256 }, { 49152, 45056, 49152 }, { 47104, 43008, 45056 }, { 22528, 22528, 22528 } }, { 40960, 16384, 49152, 32768, 57344, 40960, 16384, 57344, 8192, 57344, 40960, 16384, 16384, 8192, 0, 49152 } }, + { { { 59840, 60352, 61248 }, { 8192, 18432, 16384 }, { 53248, 36864, 24576 }, { 14336, 22528, 16384 } }, { 32768, 40960, 16384, 57344, 57344, 0, 57344, 49152, 16384, 8192, 49152, 40960, 16384, 16384, 49152, 40960 } }, + { { { 55296, 55296, 53760 }, { 12288, 16384, 12288 }, { 12288, 16384, 16384 }, { 18432, 26624, 34816 } }, { 49152, 40960, 16384, 49152, 0, 49152, 16384, 49152, 8192, 49152, 8192, 40960, 8192, 49152, 8192, 40960 } }, + { { { 47360, 46464, 46336 }, { 51200, 51200, 53248 }, { 45056, 45056, 45056 }, { 47104, 47104, 47104 } }, { 32768, 40960, 40960, 40960, 49152, 49152, 40960, 32768, 16384, 8192, 49152, 40960, 24576, 16384, 57344, 40960 } }, + { { { 58176, 57984, 57792 }, { 16384, 18432, 14336 }, { 53248, 38912, 38912 }, { 18432, 20480, 20480 } }, { 57344, 8192, 8192, 0, 40960, 49152, 57344, 0, 16384, 16384, 8192, 0, 8192, 0, 49152, 40960 } }, + { { { 55136, 54464, 52416 }, { 36864, 40960, 40960 }, { 34816, 40960, 40960 }, { 30720, 49152, 32768 } }, { 32768, 16384, 16384, 16384, 49152, 49152, 0, 0, 8192, 0, 57344, 49152, 16384, 16384, 16384, 40960 } }, + { { { 54784, 54784, 53632 }, { 14336, 18432, 14336 }, { 12288, 28672, 34816 }, { 14336, 16384, 18432 } }, { 32768, 16384, 49152, 40960, 49152, 57344, 8192, 49152, 0, 0, 8192, 16384, 8192, 8192, 8192, 16384 } }, + { { { 59456, 59904, 60288 }, { 51200, 40960, 49152 }, { 10240, 28672, 36864 }, { 45056, 43008, 45056 } }, { 49152, 16384, 57344, 40960, 0, 8192, 8192, 8192, 57344, 8192, 8192, 8192, 49152, 57344, 49152, 40960 } }, + { { { 57216, 57088, 56512 }, { 47104, 47104, 49152 }, { 16384, 24576, 24576 }, { 43008, 43008, 43008 } }, { 32768, 49152, 40960, 49152, 49152, 8192, 8192, 8192, 49152, 0, 16384, 16384, 49152, 57344, 8192, 16384 } }, + { { { 56320, 55680, 55040 }, { 16384, 20480, 14336 }, { 45056, 40960, 45056 }, { 45056, 43008, 49152 } }, { 32768, 57344, 24576, 49152, 32768, 57344, 16384, 40960, 40960, 0, 8192, 40960, 40960, 8192, 8192, 32768 } }, + { { { 62368, 64160, 64032 }, { 32768, 0, 30720 }, { 36864, 45056, 22528 }, { 32768, 57344, 28672 } }, { 32768, 49152, 16384, 16384, 40960, 49152, 16384, 0, 40960, 49152, 16384, 49152, 40960, 49152, 16384, 40960 } }, + { { { 63104, 62816, 63296 }, { 18432, 16384, 40960 }, { 16384, 24576, 36864 }, { 20480, 12288, 36864 } }, { 57344, 8192, 16384, 16384, 49152, 0, 8192, 16384, 40960, 57344, 0, 8192, 40960, 40960, 49152, 40960 } }, + { { { 56512, 56448, 55360 }, { 16384, 20480, 18432 }, { 40960, 38912, 38912 }, { 45056, 43008, 47104 } }, { 49152, 16384, 16384, 8192, 49152, 16384, 16384, 0, 40960, 8192, 8192, 49152, 49152, 16384, 0, 40960 } }, + { { { 52992, 54400, 51968 }, { 30720, 0, 61440 }, { 34816, 36864, 36864 }, { 34816, 36864, 36864 } }, { 57344, 16384, 49152, 49152, 16384, 16384, 0, 0, 0, 0, 49152, 49152, 49152, 49152, 40960, 40960 } }, + { { { 59584, 33024, 44544 }, { 4096, 32768, 36864 }, { 61440, 32768, 38912 }, { 2048, 32768, 36864 } }, { 32768, 8192, 16384, 16384, 40960, 8192, 16384, 16384, 49152, 8192, 8192, 8192, 16384, 57344, 40960, 40960 } }, + { { { 62624, 61504, 61568 }, { 16384, 36864, 28672 }, { 18432, 36864, 36864 }, { 28672, 4096, 12288 } }, { 49152, 0, 16384, 16384, 16384, 40960, 49152, 0, 57344, 0, 8192, 40960, 40960, 49152, 49152, 49152 } }, + { { { 55872, 54080, 52736 }, { 22528, 20480, 20480 }, { 24576, 24576, 20480 }, { 38912, 40960, 45056 } }, { 32768, 49152, 40960, 49152, 16384, 8192, 0, 8192, 16384, 16384, 16384, 16384, 8192, 8192, 8192, 40960 } }, + { { { 54784, 54272, 53248 }, { 26624, 26624, 25600 }, { 40960, 40960, 43008 }, { 41984, 39936, 39936 } }, { 32768, 49152, 8192, 16384, 40960, 0, 8192, 49152, 49152, 8192, 57344, 40960, 16384, 8192, 49152, 40960 } }, + { { { 50176, 49152, 47104 }, { 40960, 41984, 43008 }, { 43008, 45056, 47104 }, { 36864, 36864, 36864 } }, { 32768, 16384, 49152, 40960, 49152, 8192, 49152, 40960, 8192, 0, 40960, 40960, 16384, 0, 40960, 40960 } }, + { { { 55232, 54752, 52992 }, { 40960, 45056, 45056 }, { 24576, 16384, 16384 }, { 38912, 40960, 40960 } }, { 49152, 40960, 49152, 0, 16384, 8192, 8192, 0, 0, 16384, 8192, 40960, 49152, 8192, 8192, 40960 } }, + { { { 61088, 61536, 62048 }, { 26624, 20480, 16384 }, { 26624, 16384, 16384 }, { 34816, 40960, 45056 } }, { 53248, 49152, 40960, 40960, 4096, 0, 57344, 49152, 12288, 12288, 4096, 0, 20480, 20480, 16384, 12288 } }, + { { { 41984, 41984, 41984 }, { 34816, 33792, 33792 }, { 56320, 56320, 55296 }, { 53248, 53248, 51200 } }, { 32768, 40960, 57344, 24576, 57344, 40960, 40960, 49152, 8192, 0, 49152, 40960, 16384, 16384, 8192, 49152 } }, + { { { 55552, 55552, 54912 }, { 14336, 16384, 14336 }, { 40960, 38912, 40960 }, { 16384, 18432, 16384 } }, { 57344, 49152, 49152, 16384, 49152, 40960, 49152, 8192, 57344, 57344, 8192, 49152, 8192, 16384, 8192, 40960 } }, + { { { 39936, 39936, 39936 }, { 56320, 56320, 56320 }, { 34816, 33792, 33792 }, { 57344, 57344, 56320 } }, { 57344, 57344, 0, 0, 49152, 57344, 57344, 57344, 32768, 32768, 32768, 40960, 32768, 32768, 32768, 32768 } }, + { { { 48128, 47872, 46080 }, { 38912, 47104, 51200 }, { 37888, 47104, 47104 }, { 29696, 36864, 55296 } }, { 32768, 40960, 40960, 16384, 57344, 57344, 57344, 8192, 8192, 8192, 8192, 49152, 16384, 16384, 16384, 40960 } }, + { { { 59968, 60192, 61184 }, { 57344, 61440, 57344 }, { 57344, 0, 45056 }, { 61440, 0, 10240 } }, { 32768, 40960, 40960, 40960, 57344, 57344, 49152, 49152, 8192, 8192, 8192, 0, 16384, 16384, 16384, 16384 } }, + { { { 63264, 64128, 65376 }, { 40960, 49152, 49152 }, { 45056, 49152, 53248 }, { 26624, 0, 61440 } }, { 32768, 16384, 16384, 0, 40960, 57344, 57344, 49152, 49152, 0, 49152, 40960, 49152, 0, 16384, 40960 } }, + { { { 44800, 41728, 41984 }, { 58368, 45056, 49152 }, { 58368, 47104, 45056 }, { 55296, 34816, 30720 } }, { 49152, 40960, 49152, 24576, 57344, 40960, 40960, 49152, 8192, 57344, 40960, 40960, 16384, 8192, 57344, 40960 } }, + { { { 59648, 59328, 59968 }, { 26624, 36864, 43008 }, { 12288, 36864, 47104 }, { 24576, 34816, 47104 } }, { 32768, 40960, 57344, 57344, 32768, 32768, 57344, 57344, 32768, 32768, 0, 57344, 32768, 32768, 57344, 57344 } }, + { { { 59008, 46336, 56064 }, { 24576, 34816, 38912 }, { 14336, 32768, 43008 }, { 20480, 32768, 40960 } }, { 57344, 49152, 49152, 16384, 16384, 8192, 57344, 57344, 16384, 8192, 57344, 49152, 57344, 57344, 40960, 40960 } }, + { { { 45056, 44800, 41472 }, { 57344, 49152, 47104 }, { 13312, 26624, 30720 }, { 55296, 43008, 45056 } }, { 32768, 57344, 8192, 8192, 8192, 8192, 16384, 16384, 49152, 49152, 49152, 49152, 8192, 16384, 0, 49152 } }, + { { { 58112, 58048, 57536 }, { 18432, 20480, 20480 }, { 22528, 22528, 22528 }, { 43008, 36864, 38912 } }, { 32768, 40960, 49152, 49152, 16384, 57344, 0, 57344, 49152, 0, 8192, 8192, 40960, 49152, 8192, 16384 } }, + { { { 62976, 63744, 64960 }, { 24576, 8192, 12288 }, { 36864, 53248, 57344 }, { 26624, 8192, 8192 } }, { 32768, 49152, 0, 16384, 24576, 8192, 0, 57344, 49152, 49152, 40960, 40960, 40960, 40960, 40960, 40960 } }, + { { { 47616, 47360, 45568 }, { 38912, 47104, 51200 }, { 29696, 36864, 49152 }, { 37888, 47104, 49152 } }, { 40960, 57344, 8192, 24576, 32768, 40960, 49152, 0, 49152, 40960, 40960, 49152, 24576, 57344, 40960, 40960 } }, + { { { 53248, 51712, 48896 }, { 45056, 47104, 44032 }, { 51200, 53248, 52224 }, { 43008, 43008, 40960 } }, { 49152, 40960, 40960, 40960, 0, 57344, 49152, 49152, 40960, 16384, 8192, 0, 16384, 0, 40960, 16384 } }, + { { { 43520, 43008, 44032 }, { 45056, 46080, 44032 }, { 35840, 36864, 35840 }, { 53248, 53248, 51200 } }, { 32768, 49152, 16384, 49152, 57344, 57344, 16384, 49152, 8192, 8192, 16384, 40960, 16384, 8192, 16384, 40960 } }, + { { { 46592, 37376, 40960 }, { 15360, 36864, 36864 }, { 25600, 34816, 36864 }, { 16384, 35840, 38912 } }, { 32768, 16384, 57344, 40960, 40960, 16384, 57344, 40960, 40960, 16384, 57344, 40960, 49152, 16384, 57344, 40960 } }, + { { { 50688, 50176, 48128 }, { 41984, 43008, 45056 }, { 40960, 39936, 44032 }, { 27648, 27648, 25600 } }, { 32768, 16384, 8192, 49152, 40960, 16384, 0, 49152, 49152, 0, 57344, 49152, 16384, 57344, 49152, 40960 } }, + { { { 55808, 49664, 54912 }, { 55296, 40960, 51200 }, { 43008, 38912, 57344 }, { 49152, 34816, 26624 } }, { 32768, 57344, 8192, 8192, 8192, 8192, 8192, 0, 57344, 8192, 16384, 57344, 40960, 49152, 16384, 49152 } }, + { { { 51776, 47424, 48192 }, { 38912, 57344, 53248 }, { 36864, 53248, 53248 }, { 36864, 49152, 49152 } }, { 49152, 8192, 57344, 40960, 40960, 8192, 8192, 57344, 49152, 8192, 8192, 8192, 8192, 8192, 57344, 40960 } }, + { { { 50176, 49152, 48128 }, { 50176, 48128, 48128 }, { 52224, 51200, 51200 }, { 35840, 34816, 33792 } }, { 57344, 8192, 16384, 8192, 40960, 49152, 57344, 49152, 40960, 57344, 0, 49152, 0, 8192, 16384, 49152 } }, + { { { 54432, 51744, 51328 }, { 26624, 20480, 20480 }, { 26624, 20480, 20480 }, { 34816, 45056, 49152 } }, { 32768, 16384, 8192, 57344, 16384, 16384, 57344, 49152, 8192, 57344, 40960, 40960, 49152, 49152, 40960, 40960 } }, + { { { 49664, 49152, 48128 }, { 43008, 44032, 44032 }, { 51200, 53248, 54272 }, { 39936, 40960, 40960 } }, { 57344, 49152, 40960, 49152, 49152, 49152, 49152, 16384, 49152, 49152, 49152, 16384, 16384, 8192, 57344, 40960 } }, + { { { 58880, 57344, 55040 }, { 37888, 34816, 26624 }, { 38912, 34816, 14336 }, { 37888, 34816, 24576 } }, { 32768, 57344, 16384, 16384, 16384, 49152, 49152, 49152, 16384, 49152, 40960, 40960, 0, 49152, 49152, 40960 } }, + { { { 43520, 43264, 38912 }, { 58368, 49152, 47104 }, { 56320, 43008, 45056 }, { 11264, 26624, 30720 } }, { 32768, 40960, 0, 16384, 49152, 57344, 0, 57344, 57344, 0, 8192, 40960, 8192, 16384, 16384, 40960 } }, + { { { 60416, 60352, 31936 }, { 16384, 16384, 32768 }, { 16384, 14336, 32768 }, { 22528, 22528, 32768 } }, { 49152, 16384, 49152, 40960, 0, 49152, 8192, 40960, 8192, 49152, 8192, 49152, 16384, 0, 40960, 57344 } }, + { { { 56768, 56512, 55104 }, { 47104, 47104, 47104 }, { 40960, 40960, 40960 }, { 51200, 51200, 51200 } }, { 32768, 40960, 40960, 49152, 0, 49152, 49152, 0, 16384, 57344, 49152, 16384, 16384, 8192, 0, 49152 } }, + { { { 47104, 46848, 44288 }, { 16384, 14336, 14336 }, { 22528, 36864, 40960 }, { 16384, 14336, 18432 } }, { 49152, 40960, 40960, 40960, 8192, 57344, 49152, 40960, 16384, 8192, 49152, 40960, 16384, 8192, 49152, 40960 } }, + { { { 51200, 50176, 54272 }, { 57344, 57344, 59392 }, { 58368, 58368, 59392 }, { 55296, 55296, 57344 } }, { 32768, 40960, 40960, 40960, 24576, 57344, 49152, 57344, 57344, 57344, 0, 24576, 40960, 40960, 40960, 40960 } }, + { { { 54080, 53760, 52544 }, { 49152, 47104, 47104 }, { 43008, 43008, 43008 }, { 43008, 43008, 43008 } }, { 49152, 49152, 49152, 40960, 40960, 8192, 0, 57344, 0, 49152, 49152, 16384, 16384, 8192, 0, 49152 } }, + { { { 51712, 51200, 49920 }, { 38912, 49152, 51200 }, { 38912, 45056, 47104 }, { 34816, 36864, 26624 } }, { 57344, 0, 8192, 8192, 49152, 57344, 0, 0, 8192, 57344, 49152, 40960, 0, 49152, 40960, 40960 } }, + { { { 61440, 34304, 34176 }, { 36864, 32768, 32768 }, { 36864, 32768, 32768 }, { 34816, 32768, 32768 } }, { 57344, 40960, 57344, 16384, 49152, 8192, 57344, 8192, 40960, 0, 40960, 57344, 40960, 57344, 16384, 49152 } }, + { { { 51456, 45824, 48640 }, { 25600, 40960, 40960 }, { 24576, 43008, 43008 }, { 26624, 40960, 40960 } }, { 32768, 8192, 16384, 16384, 49152, 0, 8192, 16384, 49152, 49152, 57344, 57344, 40960, 40960, 40960, 40960 } }, + { { { 51712, 46592, 43776 }, { 51200, 45056, 43008 }, { 47104, 38912, 36864 }, { 51200, 49152, 54272 } }, { 49152, 49152, 40960, 49152, 0, 8192, 16384, 8192, 40960, 49152, 49152, 57344, 8192, 8192, 16384, 8192 } }, + { { { 50432, 51712, 48896 }, { 25600, 16384, 14336 }, { 34816, 26624, 6144 }, { 25600, 14336, 14336 } }, { 57344, 16384, 49152, 0, 8192, 57344, 49152, 57344, 49152, 57344, 8192, 8192, 57344, 0, 8192, 40960 } }, + { { { 58560, 58560, 57856 }, { 18432, 22528, 12288 }, { 47104, 43008, 51200 }, { 40960, 38912, 40960 } }, { 40960, 40960, 49152, 40960, 49152, 57344, 57344, 57344, 16384, 8192, 16384, 8192, 40960, 8192, 16384, 40960 } }, + { { { 59712, 59392, 60288 }, { 49152, 43008, 57344 }, { 51200, 43008, 51200 }, { 36864, 28672, 24576 } }, { 49152, 40960, 49152, 0, 8192, 49152, 0, 16384, 49152, 49152, 8192, 0, 49152, 57344, 16384, 40960 } }, + { { { 49152, 44032, 41984 }, { 48128, 44032, 38912 }, { 41984, 52224, 33792 }, { 43008, 53248, 36864 } }, { 57344, 0, 49152, 40960, 8192, 0, 49152, 57344, 16384, 57344, 40960, 16384, 8192, 57344, 49152, 49152 } }, + { { { 53760, 53248, 52736 }, { 36864, 36864, 36864 }, { 45056, 46080, 45056 }, { 46080, 47104, 46080 } }, { 32768, 40960, 57344, 16384, 16384, 8192, 57344, 57344, 8192, 0, 49152, 49152, 57344, 49152, 40960, 40960 } }, + { { { 59456, 59328, 60544 }, { 8192, 20480, 14336 }, { 36864, 26624, 22528 }, { 10240, 22528, 18432 } }, { 49152, 8192, 40960, 16384, 49152, 57344, 8192, 57344, 40960, 49152, 0, 40960, 40960, 49152, 0, 16384 } }, + { { { 60224, 60992, 61120 }, { 10240, 22528, 47104 }, { 0, 61440, 43008 }, { 10240, 26624, 40960 } }, { 40960, 40960, 40960, 40960, 40960, 40960, 40960, 49152, 49152, 57344, 8192, 24576, 24576, 0, 40960, 40960 } }, + { { { 45056, 44032, 44032 }, { 43008, 43008, 41984 }, { 50176, 34816, 29696 }, { 43008, 43008, 40960 } }, { 49152, 49152, 49152, 16384, 49152, 57344, 57344, 49152, 49152, 8192, 16384, 49152, 49152, 16384, 16384, 49152 } }, + { { { 60416, 59392, 52224 }, { 60416, 58368, 47104 }, { 59392, 56320, 38912 }, { 59392, 58368, 46080 } }, { 32768, 8192, 57344, 49152, 16384, 8192, 8192, 49152, 49152, 8192, 8192, 49152, 49152, 8192, 8192, 49152 } }, + { { { 53248, 53504, 51200 }, { 25600, 16384, 16384 }, { 24576, 16384, 16384 }, { 28672, 26624, 34816 } }, { 57344, 40960, 40960, 57344, 40960, 57344, 8192, 8192, 8192, 8192, 57344, 49152, 8192, 0, 57344, 40960 } }, + { { { 55296, 48000, 52480 }, { 51200, 43008, 57344 }, { 28672, 34816, 38912 }, { 49152, 40960, 45056 } }, { 32768, 16384, 0, 49152, 8192, 8192, 8192, 57344, 8192, 8192, 8192, 8192, 8192, 57344, 49152, 40960 } }, + { { { 60672, 60864, 61440 }, { 16384, 22528, 16384 }, { 16384, 18432, 14336 }, { 57344, 36864, 24576 } }, { 40960, 40960, 49152, 49152, 16384, 8192, 8192, 8192, 40960, 57344, 8192, 16384, 8192, 8192, 0, 49152 } }, + { { { 45824, 45056, 42496 }, { 56320, 47104, 45056 }, { 56320, 45056, 45056 }, { 11264, 22528, 24576 } }, { 57344, 16384, 16384, 8192, 0, 16384, 8192, 0, 49152, 57344, 49152, 40960, 40960, 40960, 40960, 40960 } }, + { { { 40960, 27392, 46848 }, { 54272, 28672, 49152 }, { 53248, 28672, 47104 }, { 52224, 28672, 43008 } }, { 32768, 16384, 49152, 8192, 0, 57344, 0, 0, 16384, 49152, 8192, 49152, 57344, 57344, 0, 40960 } }, + { { { 60736, 32768, 60000 }, { 57344, 49152, 0 }, { 61440, 49152, 45056 }, { 4096, 49152, 61440 } }, { 57344, 24576, 57344, 49152, 49152, 57344, 49152, 49152, 49152, 49152, 49152, 49152, 16384, 8192, 49152, 40960 } }, + { { { 55680, 55296, 54016 }, { 16384, 20480, 16384 }, { 51200, 49152, 55296 }, { 47104, 43008, 47104 } }, { 40960, 40960, 40960, 40960, 40960, 40960, 40960, 40960, 40960, 40960, 40960, 40960, 40960, 40960, 40960, 40960 } }, + { { { 45056, 44544, 44032 }, { 44032, 44032, 44032 }, { 38912, 38912, 38912 }, { 53248, 54272, 54272 } }, { 32768, 16384, 16384, 8192, 40960, 16384, 8192, 8192, 49152, 8192, 57344, 57344, 40960, 57344, 40960, 40960 } }, + { { { 44032, 43520, 39936 }, { 45056, 39936, 45056 }, { 38912, 39936, 40960 }, { 1024, 29696, 34816 } }, { 32768, 40960, 49152, 57344, 40960, 57344, 8192, 16384, 49152, 8192, 16384, 16384, 40960, 49152, 49152, 49152 } }, + { { { 41984, 36864, 40960 }, { 46080, 36864, 41984 }, { 36864, 32768, 55296 }, { 36864, 32768, 57344 } }, { 40960, 40960, 49152, 16384, 40960, 40960, 49152, 8192, 49152, 49152, 40960, 57344, 8192, 16384, 8192, 49152 } }, + { { { 59776, 60416, 61504 }, { 51200, 43008, 49152 }, { 26624, 36864, 40960 }, { 45056, 40960, 45056 } }, { 32768, 40960, 49152, 16384, 49152, 40960, 40960, 57344, 0, 49152, 40960, 40960, 16384, 0, 40960, 40960 } }, + { { { 50688, 50176, 45568 }, { 21504, 10240, 38912 }, { 38912, 43008, 40960 }, { 22528, 8192, 34816 } }, { 32768, 40960, 49152, 57344, 40960, 49152, 57344, 0, 53248, 57344, 4096, 16384, 0, 8192, 16384, 24576 } }, + { { { 44032, 46336, 41728 }, { 45056, 45056, 45056 }, { 44032, 49152, 45056 }, { 39936, 28672, 34816 } }, { 40960, 0, 8192, 16384, 40960, 57344, 8192, 16384, 49152, 49152, 8192, 16384, 16384, 49152, 57344, 16384 } }, + { { { 44544, 39936, 38912 }, { 40960, 40960, 41984 }, { 29696, 34816, 34816 }, { 38912, 40960, 41984 } }, { 32768, 8192, 16384, 8192, 40960, 49152, 8192, 16384, 57344, 57344, 49152, 0, 8192, 8192, 8192, 40960 } }, + { { { 59200, 59840, 60864 }, { 0, 8192, 14336 }, { 6144, 20480, 16384 }, { 49152, 36864, 24576 } }, { 57344, 49152, 0, 8192, 0, 8192, 16384, 16384, 16384, 16384, 16384, 8192, 8192, 8192, 0, 40960 } }, + { { { 43264, 44800, 40960 }, { 47104, 43008, 47104 }, { 41984, 28672, 36864 }, { 46080, 43008, 47104 } }, { 32768, 49152, 0, 16384, 40960, 57344, 16384, 49152, 49152, 16384, 57344, 40960, 16384, 0, 40960, 40960 } }, + { { { 50432, 50688, 48384 }, { 22528, 14336, 18432 }, { 22528, 12288, 20480 }, { 27648, 32768, 34816 } }, { 32768, 32768, 32768, 32768, 40960, 32768, 32768, 32768, 57344, 57344, 57344, 49152, 0, 57344, 57344, 49152 } }, + { { { 54912, 54784, 54016 }, { 49152, 49152, 49152 }, { 49152, 49152, 47104 }, { 34816, 26624, 24576 } }, { 32768, 0, 8192, 8192, 16384, 0, 8192, 16384, 8192, 49152, 49152, 8192, 0, 40960, 49152, 40960 } }, + { { { 60800, 32832, 59712 }, { 49152, 32768, 16384 }, { 53248, 32768, 36864 }, { 59392, 32768, 47104 } }, { 40960, 8192, 16384, 49152, 49152, 57344, 57344, 57344, 40960, 0, 8192, 8192, 8192, 8192, 8192, 49152 } }, + { { { 53888, 47616, 47968 }, { 10240, 16384, 16384 }, { 51200, 20480, 20480 }, { 55296, 40960, 40960 } }, { 49152, 0, 49152, 57344, 40960, 40960, 49152, 57344, 40960, 49152, 49152, 0, 8192, 8192, 16384, 16384 } }, + { { { 54656, 50048, 52992 }, { 45056, 45056, 53248 }, { 45056, 45056, 45056 }, { 28672, 34816, 40960 } }, { 40960, 40960, 40960, 40960, 40960, 40960, 49152, 57344, 49152, 57344, 16384, 16384, 8192, 16384, 8192, 40960 } }, + { { { 64096, 64160, 63968 }, { 40960, 53248, 24576 }, { 36864, 45056, 24576 }, { 8192, 12288, 34816 } }, { 40960, 16384, 57344, 40960, 40960, 0, 0, 40960, 40960, 49152, 16384, 49152, 40960, 49152, 16384, 57344 } }, + { { { 18432, 18432, 33792 }, { 55296, 53248, 13312 }, { 56320, 51200, 13312 }, { 56320, 54272, 51200 } }, { 32768, 8192, 16384, 16384, 40960, 40960, 40960, 49152, 57344, 57344, 49152, 40960, 16384, 16384, 57344, 49152 } }, + { { { 5120, 62464, 62464 }, { 10240, 62464, 61440 }, { 10240, 62464, 62464 }, { 12288, 62464, 62464 } }, { 32768, 16384, 40960, 40960, 0, 57344, 40960, 8192, 8192, 8192, 0, 57344, 16384, 16384, 8192, 8192 } }, + { { { 59840, 60032, 61120 }, { 40960, 43008, 47104 }, { 40960, 43008, 43008 }, { 28672, 36864, 40960 } }, { 32768, 8192, 40960, 8192, 8192, 8192, 57344, 0, 8192, 8192, 49152, 8192, 57344, 57344, 57344, 0 } }, + { { { 53248, 53248, 51200 }, { 24576, 16384, 14336 }, { 28672, 26624, 36864 }, { 24576, 14336, 20480 } }, { 32768, 40960, 40960, 40960, 40960, 40960, 40960, 40960, 40960, 49152, 49152, 49152, 0, 0, 16384, 24576 } }, + { { { 39360, 58752, 59072 }, { 32768, 20480, 20480 }, { 34816, 16384, 14336 }, { 32768, 22528, 22528 } }, { 32768, 40960, 57344, 16384, 40960, 40960, 57344, 8192, 16384, 16384, 0, 49152, 8192, 8192, 49152, 40960 } }, + { { { 52224, 52480, 50944 }, { 26624, 14336, 14336 }, { 35840, 36864, 26624 }, { 26624, 12288, 12288 } }, { 57344, 40960, 40960, 49152, 0, 49152, 49152, 0, 8192, 0, 0, 8192, 16384, 16384, 16384, 16384 } }, + { { { 48128, 46592, 37376 }, { 23552, 25600, 35840 }, { 18432, 25600, 37888 }, { 16384, 25600, 36864 } }, { 32768, 57344, 8192, 16384, 8192, 49152, 0, 16384, 16384, 8192, 49152, 8192, 8192, 8192, 49152, 40960 } }, + { { { 6656, 14848, 19456 }, { 56320, 8192, 8192 }, { 50176, 13312, 11264 }, { 55296, 52224, 52224 } }, { 57344, 8192, 8192, 0, 16384, 8192, 0, 57344, 0, 57344, 49152, 8192, 49152, 57344, 16384, 40960 } }, + { { { 27392, 49152, 25856 }, { 47104, 26624, 36864 }, { 45056, 20480, 36864 }, { 46080, 12288, 36864 } }, { 40960, 40960, 49152, 16384, 40960, 40960, 49152, 8192, 40960, 40960, 57344, 57344, 40960, 49152, 24576, 40960 } }, + { { { 48128, 36864, 35840 }, { 52224, 35840, 36864 }, { 53248, 36864, 39936 }, { 53248, 36864, 37888 } }, { 32768, 49152, 57344, 16384, 16384, 49152, 57344, 0, 49152, 8192, 16384, 0, 49152, 57344, 49152, 49152 } }, + { { { 58592, 56288, 53536 }, { 26624, 61440, 45056 }, { 26624, 61440, 45056 }, { 34816, 45056, 45056 } }, { 40960, 40960, 40960, 16384, 57344, 57344, 8192, 8192, 8192, 8192, 57344, 57344, 16384, 40960, 40960, 40960 } }, + { { { 57024, 61184, 61632 }, { 45056, 45056, 24576 }, { 40960, 40960, 38912 }, { 45056, 36864, 10240 } }, { 40960, 16384, 49152, 57344, 16384, 57344, 49152, 8192, 40960, 57344, 0, 49152, 16384, 49152, 49152, 49152 } }, + { { { 53248, 53248, 51712 }, { 24576, 24576, 20480 }, { 38912, 38912, 39936 }, { 26624, 25600, 23552 } }, { 32768, 40960, 57344, 16384, 57344, 57344, 8192, 8192, 24576, 49152, 49152, 49152, 40960, 40960, 40960, 40960 } }, + { { { 43008, 39424, 38912 }, { 39936, 41984, 43008 }, { 38912, 39936, 39936 }, { 28672, 34816, 35840 } }, { 57344, 49152, 49152, 8192, 49152, 8192, 8192, 16384, 57344, 8192, 0, 49152, 57344, 49152, 40960, 40960 } }, + { { { 54560, 54400, 52160 }, { 28672, 45056, 40960 }, { 47104, 36864, 36864 }, { 28672, 40960, 40960 } }, { 32768, 49152, 40960, 49152, 8192, 8192, 8192, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384 } }, + { { { 63072, 63680, 64448 }, { 26624, 8192, 4096 }, { 36864, 53248, 61440 }, { 36864, 53248, 53248 } }, { 32768, 8192, 16384, 0, 8192, 0, 49152, 49152, 16384, 8192, 57344, 49152, 0, 8192, 8192, 49152 } }, + { { { 51200, 50944, 45312 }, { 51200, 40960, 43008 }, { 13312, 24576, 36864 }, { 12288, 22528, 49152 } }, { 57344, 16384, 49152, 49152, 57344, 49152, 49152, 57344, 16384, 8192, 49152, 49152, 8192, 16384, 8192, 40960 } }, + { { { 48384, 47616, 44288 }, { 24576, 0, 49152 }, { 25600, 63488, 36864 }, { 35840, 51200, 45056 } }, { 36864, 36864, 36864, 40960, 57344, 57344, 61440, 61440, 12288, 12288, 16384, 16384, 20480, 24576, 24576, 24576 } }, + { { { 33792, 38912, 32768 }, { 33792, 62464, 32768 }, { 32768, 32768, 32768 }, { 32768, 56320, 37888 } }, { 49152, 49152, 57344, 8192, 8192, 49152, 49152, 8192, 49152, 57344, 49152, 0, 40960, 8192, 8192, 8192 } }, + { { { 49152, 50944, 48128 }, { 39936, 51200, 53248 }, { 39936, 47104, 49152 }, { 35840, 26624, 24576 } }, { 40960, 40960, 40960, 40960, 40960, 49152, 49152, 40960, 49152, 8192, 0, 40960, 16384, 16384, 8192, 49152 } }, + { { { 49664, 50688, 47616 }, { 39936, 49152, 49152 }, { 38912, 49152, 49152 }, { 28672, 26624, 34816 } }, { 49152, 4096, 16384, 24576, 45056, 61440, 12288, 20480, 40960, 57344, 12288, 20480, 36864, 49152, 4096, 16384 } }, + { { { 48128, 46592, 46080 }, { 41984, 41984, 43008 }, { 43008, 43008, 40960 }, { 35840, 34816, 29696 } }, { 32768, 16384, 16384, 16384, 8192, 16384, 16384, 16384, 16384, 16384, 16384, 8192, 16384, 16384, 0, 32768 } }, + { { { 60416, 3072, 60416 }, { 62464, 11264, 61440 }, { 62464, 11264, 62464 }, { 62464, 13312, 62464 } }, { 32768, 40960, 40960, 40960, 49152, 57344, 8192, 16384, 24576, 8192, 0, 57344, 49152, 40960, 40960, 40960 } }, + { { { 54528, 48896, 52736 }, { 37888, 47104, 59392 }, { 27648, 55296, 53248 }, { 27648, 36864, 43008 } }, { 49152, 40960, 40960, 40960, 16384, 49152, 40960, 40960, 40960, 8192, 57344, 49152, 0, 49152, 8192, 49152 } }, + { { { 59968, 33280, 59584 }, { 2048, 32768, 63488 }, { 4096, 32768, 16384 }, { 61440, 32768, 12288 } }, { 32768, 16384, 49152, 57344, 49152, 0, 49152, 8192, 57344, 57344, 49152, 8192, 8192, 57344, 49152, 0 } }, + { { { 15872, 18944, 43008 }, { 7168, 12288, 54272 }, { 7168, 11264, 51200 }, { 58368, 51200, 54272 } }, { 40960, 49152, 8192, 8192, 16384, 0, 49152, 40960, 40960, 57344, 8192, 16384, 8192, 0, 49152, 40960 } }, + { { { 57312, 56384, 54816 }, { 38912, 49152, 53248 }, { 26624, 8192, 4096 }, { 26624, 8192, 0 } }, { 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 40960, 32768, 32768, 32768, 16384, 49152, 40960, 32768 } }, + { { { 45056, 40960, 46080 }, { 62464, 60416, 11264 }, { 62464, 60416, 17408 }, { 61440, 59392, 14336 } }, { 32768, 16384, 57344, 49152, 16384, 16384, 8192, 49152, 49152, 0, 8192, 8192, 40960, 40960, 49152, 57344 } }, + { { { 32768, 32768, 32768 }, { 62464, 32768, 32768 }, { 32768, 32768, 32768 }, { 62464, 32768, 32768 } }, { 40960, 8192, 40960, 8192, 40960, 8192, 49152, 8192, 40960, 8192, 8192, 8192, 49152, 8192, 8192, 49152 } }, + { { { 54272, 54272, 53248 }, { 21504, 20480, 20480 }, { 36864, 36864, 36864 }, { 25600, 25600, 24576 } }, { 40960, 40960, 40960, 40960, 16384, 16384, 16384, 0, 40960, 40960, 40960, 40960, 16384, 16384, 0, 49152 } }, + { { { 32768, 64864, 62976 }, { 34816, 49152, 49152 }, { 34816, 61440, 45056 }, { 34816, 57344, 4096 } }, { 32768, 0, 16384, 40960, 49152, 57344, 8192, 0, 0, 57344, 16384, 8192, 8192, 0, 8192, 40960 } }, + { { { 55808, 46080, 39424 }, { 34816, 34816, 52224 }, { 34816, 35840, 49152 }, { 34816, 34816, 51200 } }, { 40960, 40960, 40960, 40960, 16384, 16384, 16384, 16384, 0, 0, 57344, 49152, 49152, 40960, 40960, 40960 } }, + { { { 57472, 57728, 56448 }, { 38912, 22528, 20480 }, { 36864, 22528, 22528 }, { 16384, 34816, 30720 } }, { 32768, 57344, 8192, 57344, 0, 8192, 0, 57344, 16384, 49152, 8192, 8192, 57344, 57344, 8192, 49152 } }, + { { { 64224, 64224, 64032 }, { 49152, 61440, 22528 }, { 20480, 20480, 49152 }, { 4096, 12288, 32768 } }, { 40960, 49152, 16384, 16384, 40960, 49152, 0, 16384, 40960, 40960, 40960, 49152, 40960, 40960, 40960, 40960 } }, + { { { 45568, 44544, 41472 }, { 45056, 41984, 46080 }, { 29696, 29696, 33792 }, { 39936, 39936, 43008 } }, { 32768, 49152, 49152, 57344, 57344, 8192, 16384, 49152, 16384, 49152, 49152, 49152, 16384, 0, 49152, 40960 } }, + { { { 64448, 64256, 64288 }, { 47104, 20480, 12288 }, { 36864, 28672, 57344 }, { 36864, 32768, 4096 } }, { 57344, 0, 61440, 53248, 4096, 4096, 61440, 53248, 12288, 8192, 61440, 53248, 12288, 8192, 61440, 45056 } }, + { { { 62528, 61568, 61728 }, { 24576, 49152, 40960 }, { 38912, 40960, 40960 }, { 24576, 61440, 40960 } }, { 49152, 24576, 49152, 49152, 49152, 57344, 57344, 0, 49152, 40960, 57344, 16384, 49152, 49152, 49152, 49152 } }, + { { { 52736, 48640, 48128 }, { 36864, 35840, 23552 }, { 38912, 36864, 8192 }, { 40960, 36864, 22528 } }, { 40960, 16384, 49152, 57344, 49152, 57344, 49152, 49152, 16384, 8192, 8192, 8192, 57344, 49152, 49152, 40960 } }, + { { { 55040, 54528, 51968 }, { 16384, 12288, 14336 }, { 47104, 47104, 38912 }, { 8192, 10240, 18432 } }, { 49152, 49152, 40960, 49152, 0, 49152, 57344, 0, 57344, 49152, 49152, 8192, 49152, 40960, 57344, 24576 } }, + { { { 53248, 52224, 49152 }, { 23552, 23552, 22528 }, { 28672, 27648, 34816 }, { 20480, 20480, 24576 } }, { 32768, 49152, 57344, 0, 16384, 8192, 49152, 49152, 40960, 49152, 49152, 49152, 8192, 16384, 16384, 8192 } }, + { { { 41472, 42496, 38912 }, { 44032, 40960, 43008 }, { 34816, 29696, 34816 }, { 45056, 40960, 43008 } }, { 32768, 49152, 49152, 16384, 49152, 0, 0, 49152, 49152, 8192, 8192, 57344, 49152, 0, 8192, 16384 } }, + { { { 51712, 51200, 50688 }, { 21504, 23552, 20480 }, { 55296, 34816, 27648 }, { 24576, 23552, 20480 } }, { 40960, 49152, 49152, 16384, 40960, 49152, 57344, 0, 40960, 40960, 57344, 8192, 40960, 40960, 57344, 16384 } }, + { { { 16384, 0, 57344 }, { 58368, 59392, 59392 }, { 56320, 55296, 56320 }, { 56320, 3072, 4096 } }, { 40960, 49152, 49152, 40960, 16384, 8192, 49152, 40960, 16384, 16384, 49152, 49152, 49152, 0, 49152, 40960 } }, + { { { 49664, 43008, 47104 }, { 50176, 35840, 25600 }, { 47104, 37888, 61440 }, { 44032, 38912, 38912 } }, { 32768, 8192, 8192, 0, 16384, 49152, 57344, 8192, 49152, 49152, 57344, 0, 49152, 0, 57344, 49152 } }, + { { { 48896, 40448, 38912 }, { 51200, 40960, 54272 }, { 61440, 34816, 39936 }, { 8192, 34816, 37888 } }, { 49152, 8192, 49152, 8192, 57344, 8192, 57344, 57344, 8192, 49152, 8192, 49152, 8192, 49152, 16384, 40960 } }, + { { { 43520, 43008, 36864 }, { 5120, 25600, 36864 }, { 6144, 25600, 34816 }, { 53248, 35840, 40960 } }, { 36864, 40960, 61440, 20480, 36864, 40960, 57344, 20480, 36864, 40960, 53248, 16384, 40960, 40960, 53248, 16384 } }, + { { { 44544, 36352, 37888 }, { 27648, 36864, 39936 }, { 35840, 38912, 39936 }, { 63488, 35840, 36864 } }, { 40960, 40960, 40960, 49152, 49152, 0, 8192, 16384, 49152, 8192, 8192, 49152, 49152, 16384, 49152, 40960 } }, + { { { 52736, 51712, 48128 }, { 21504, 22528, 20480 }, { 23552, 21504, 18432 }, { 28672, 28672, 35840 } }, { 40960, 40960, 40960, 49152, 49152, 49152, 0, 16384, 16384, 8192, 57344, 49152, 49152, 40960, 40960, 40960 } }, + { { { 50688, 50176, 48640 }, { 41984, 43008, 43008 }, { 53248, 56320, 57344 }, { 50176, 53248, 53248 } }, { 32768, 49152, 49152, 57344, 49152, 0, 16384, 16384, 49152, 49152, 49152, 49152, 8192, 8192, 8192, 49152 } }, + { { { 44032, 43008, 36864 }, { 8192, 26624, 34816 }, { 55296, 36864, 40960 }, { 6144, 27648, 35840 } }, { 32768, 40960, 49152, 16384, 0, 57344, 40960, 40960, 16384, 16384, 0, 57344, 16384, 16384, 16384, 8192 } }, + { { { 47616, 45056, 38912 }, { 46080, 36864, 48128 }, { 8192, 27648, 37888 }, { 8192, 27648, 40960 } }, { 40960, 49152, 49152, 8192, 16384, 8192, 49152, 57344, 57344, 49152, 57344, 49152, 49152, 49152, 16384, 49152 } }, + { { { 45568, 45568, 43008 }, { 56320, 2048, 51200 }, { 38912, 38912, 37888 }, { 37888, 38912, 37888 } }, { 40960, 16384, 49152, 8192, 49152, 16384, 49152, 8192, 57344, 0, 49152, 0, 8192, 49152, 16384, 40960 } }, + { { { 48128, 48128, 46592 }, { 46080, 44032, 47104 }, { 34816, 29696, 28672 }, { 45056, 44032, 43008 } }, { 40960, 49152, 49152, 49152, 49152, 16384, 8192, 49152, 49152, 16384, 16384, 49152, 40960, 49152, 40960, 40960 } }, + { { { 4096, 4096, 13312 }, { 4096, 4096, 15360 }, { 62464, 62464, 62464 }, { 1024, 1024, 9216 } }, { 40960, 40960, 40960, 40960, 49152, 40960, 49152, 24576, 0, 57344, 57344, 49152, 24576, 0, 49152, 40960 } }, + { { { 51712, 52224, 50688 }, { 17408, 22528, 20480 }, { 33792, 28672, 26624 }, { 22528, 23552, 19456 } }, { 32768, 16384, 16384, 16384, 57344, 8192, 24576, 16384, 40960, 0, 16384, 24576, 49152, 0, 16384, 24576 } }, + { { { 48128, 48128, 46080 }, { 45056, 44032, 46080 }, { 43008, 44032, 43008 }, { 33792, 29696, 26624 } }, { 36864, 36864, 36864, 40960, 36864, 36864, 36864, 36864, 36864, 36864, 36864, 40960, 40960, 40960, 40960, 45056 } }, + { { { 41472, 42496, 35840 }, { 47104, 26624, 36864 }, { 49152, 27648, 36864 }, { 46080, 27648, 38912 } }, { 49152, 49152, 49152, 49152, 8192, 16384, 57344, 57344, 40960, 49152, 49152, 16384, 49152, 57344, 49152, 49152 } }, + { { { 32768, 32768, 60288 }, { 32768, 32768, 51200 }, { 32768, 32768, 57344 }, { 32768, 32768, 43008 } }, { 36864, 36864, 36864, 36864, 45056, 45056, 40960, 40960, 0, 61440, 57344, 57344, 20480, 20480, 20480, 16384 } }, + { { { 36352, 59456, 29952 }, { 32768, 18432, 34816 }, { 32768, 12288, 34816 }, { 32768, 12288, 34816 } }, { 40960, 49152, 57344, 16384, 49152, 49152, 49152, 49152, 49152, 49152, 57344, 16384, 57344, 8192, 8192, 40960 } }, + { { { 53248, 40960, 48640 }, { 48128, 37888, 41984 }, { 43008, 34816, 24576 }, { 40960, 34816, 21504 } }, { 40960, 49152, 0, 49152, 40960, 40960, 16384, 49152, 57344, 49152, 8192, 49152, 16384, 0, 49152, 40960 } }, + { { { 53760, 52736, 51200 }, { 27648, 27648, 20480 }, { 43008, 41984, 46080 }, { 48128, 33792, 26624 } }, { 40960, 49152, 40960, 16384, 49152, 49152, 57344, 0, 8192, 57344, 49152, 57344, 8192, 57344, 0, 16384 } }, + { { { 50176, 49664, 48640 }, { 22528, 25600, 20480 }, { 23552, 24576, 18432 }, { 35840, 34816, 26624 } }, { 32768, 49152, 16384, 57344, 49152, 8192, 0, 49152, 16384, 57344, 40960, 40960, 57344, 40960, 40960, 40960 } }, + { { { 45568, 43008, 44032 }, { 49152, 43008, 53248 }, { 41984, 43008, 38912 }, { 29696, 33792, 28672 } }, { 32768, 40960, 57344, 16384, 40960, 40960, 57344, 16384, 57344, 40960, 49152, 57344, 16384, 49152, 40960, 49152 } }, + { { { 52736, 49152, 46080 }, { 34816, 28672, 16384 }, { 43008, 43008, 54272 }, { 40960, 39936, 55296 } }, { 32768, 24576, 49152, 49152, 49152, 40960, 49152, 49152, 8192, 49152, 49152, 40960, 16384, 0, 57344, 40960 } }, + { { { 54016, 52992, 50944 }, { 14336, 12288, 22528 }, { 53248, 51200, 46080 }, { 55296, 55296, 40960 } }, { 32768, 0, 40960, 40960, 16384, 0, 16384, 40960, 16384, 0, 16384, 40960, 16384, 57344, 8192, 16384 } }, + { { { 45568, 42496, 36352 }, { 22528, 28672, 34816 }, { 4096, 36864, 43008 }, { 64512, 35840, 39936 } }, { 32768, 32768, 32768, 40960, 32768, 32768, 32768, 32768, 40960, 32768, 32768, 32768, 24576, 32768, 32768, 32768 } }, + { { { 50176, 49152, 47104 }, { 55296, 38912, 4096 }, { 18432, 27648, 20480 }, { 57344, 35840, 26624 } }, { 49152, 49152, 16384, 8192, 49152, 57344, 49152, 49152, 49152, 24576, 49152, 49152, 57344, 49152, 49152, 49152 } }, + { { { 49664, 47616, 44544 }, { 52224, 38912, 44032 }, { 25600, 27648, 62464 }, { 29696, 34816, 37888 } }, { 40960, 24576, 40960, 16384, 49152, 0, 57344, 8192, 40960, 49152, 49152, 49152, 49152, 49152, 40960, 40960 } }, + { { { 50688, 49664, 49152 }, { 17408, 26624, 20480 }, { 15360, 18432, 20480 }, { 29696, 33792, 27648 } }, { 57344, 49152, 0, 8192, 57344, 8192, 0, 0, 40960, 49152, 0, 49152, 16384, 49152, 57344, 40960 } }, + { { { 53248, 52736, 51200 }, { 19456, 21504, 17408 }, { 29696, 34816, 35840 }, { 18432, 20480, 24576 } }, { 32768, 40960, 8192, 24576, 40960, 49152, 57344, 0, 40960, 0, 49152, 49152, 49152, 16384, 49152, 40960 } }, + { { { 53760, 52736, 50176 }, { 21504, 23552, 25600 }, { 45056, 41984, 44032 }, { 20480, 28672, 34816 } }, { 40960, 40960, 49152, 49152, 40960, 49152, 49152, 57344, 49152, 49152, 57344, 16384, 16384, 57344, 49152, 16384 } }, + { { { 51712, 52224, 48640 }, { 13312, 20480, 18432 }, { 34816, 29696, 36864 }, { 25600, 20480, 24576 } }, { 32768, 40960, 0, 16384, 32768, 40960, 49152, 0, 32768, 32768, 40960, 49152, 32768, 32768, 32768, 40960 } }, + { { { 45056, 40960, 38400 }, { 0, 38912, 45056 }, { 29696, 37888, 36864 }, { 12288, 26624, 45056 } }, { 32768, 24576, 49152, 40960, 49152, 0, 40960, 40960, 8192, 49152, 32768, 40960, 16384, 40960, 40960, 40960 } }, +}; + +inline constexpr uint8_t BC6_ENDPOINT_BITS[15][4] = { + { 0, 0, 0, 0 }, + { 10, 5, 5, 5 }, + { 7, 6, 6, 6 }, + { 11, 5, 4, 4 }, + { 11, 4, 5, 4 }, + { 11, 4, 4, 5 }, + { 9, 5, 5, 5 }, + { 8, 6, 5, 5 }, + { 8, 5, 6, 5 }, + { 8, 5, 5, 6 }, + { 6, 6, 6, 6 }, + { 10, 10, 10, 10 }, + { 11, 9, 9, 9 }, + { 12, 8, 8, 8 }, + { 16, 4, 4, 4 }, +}; + +// 0 = mode bit, 1 = partition bit; 2 + 3 * endpoint + channel = endpoint bit. +inline constexpr Bc6WireBit BC6_WIRE[14][82] = { + { // Mode 1 + { 0, 0 }, { 0, 1 }, { 9, 4 }, { 10, 4 }, { 13, 4 }, { 2, 0 }, { 2, 1 }, { 2, 2 }, { 2, 3 }, { 2, 4 }, + { 2, 5 }, { 2, 6 }, { 2, 7 }, { 2, 8 }, { 2, 9 }, { 3, 0 }, { 3, 1 }, { 3, 2 }, { 3, 3 }, { 3, 4 }, + { 3, 5 }, { 3, 6 }, { 3, 7 }, { 3, 8 }, { 3, 9 }, { 4, 0 }, { 4, 1 }, { 4, 2 }, { 4, 3 }, { 4, 4 }, + { 4, 5 }, { 4, 6 }, { 4, 7 }, { 4, 8 }, { 4, 9 }, { 5, 0 }, { 5, 1 }, { 5, 2 }, { 5, 3 }, { 5, 4 }, + { 12, 4 }, { 9, 0 }, { 9, 1 }, { 9, 2 }, { 9, 3 }, { 6, 0 }, { 6, 1 }, { 6, 2 }, { 6, 3 }, { 6, 4 }, + { 13, 0 }, { 12, 0 }, { 12, 1 }, { 12, 2 }, { 12, 3 }, { 7, 0 }, { 7, 1 }, { 7, 2 }, { 7, 3 }, { 7, 4 }, + { 13, 1 }, { 10, 0 }, { 10, 1 }, { 10, 2 }, { 10, 3 }, { 8, 0 }, { 8, 1 }, { 8, 2 }, { 8, 3 }, { 8, 4 }, + { 13, 2 }, { 11, 0 }, { 11, 1 }, { 11, 2 }, { 11, 3 }, { 11, 4 }, { 13, 3 }, { 1, 0 }, { 1, 1 }, { 1, 2 }, + { 1, 3 }, { 1, 4 }, + }, + { // Mode 2 + { 0, 0 }, { 0, 1 }, { 9, 5 }, { 12, 4 }, { 12, 5 }, { 2, 0 }, { 2, 1 }, { 2, 2 }, { 2, 3 }, { 2, 4 }, + { 2, 5 }, { 2, 6 }, { 13, 0 }, { 13, 1 }, { 10, 4 }, { 3, 0 }, { 3, 1 }, { 3, 2 }, { 3, 3 }, { 3, 4 }, + { 3, 5 }, { 3, 6 }, { 10, 5 }, { 13, 2 }, { 9, 4 }, { 4, 0 }, { 4, 1 }, { 4, 2 }, { 4, 3 }, { 4, 4 }, + { 4, 5 }, { 4, 6 }, { 13, 3 }, { 13, 5 }, { 13, 4 }, { 5, 0 }, { 5, 1 }, { 5, 2 }, { 5, 3 }, { 5, 4 }, + { 5, 5 }, { 9, 0 }, { 9, 1 }, { 9, 2 }, { 9, 3 }, { 6, 0 }, { 6, 1 }, { 6, 2 }, { 6, 3 }, { 6, 4 }, + { 6, 5 }, { 12, 0 }, { 12, 1 }, { 12, 2 }, { 12, 3 }, { 7, 0 }, { 7, 1 }, { 7, 2 }, { 7, 3 }, { 7, 4 }, + { 7, 5 }, { 10, 0 }, { 10, 1 }, { 10, 2 }, { 10, 3 }, { 8, 0 }, { 8, 1 }, { 8, 2 }, { 8, 3 }, { 8, 4 }, + { 8, 5 }, { 11, 0 }, { 11, 1 }, { 11, 2 }, { 11, 3 }, { 11, 4 }, { 11, 5 }, { 1, 0 }, { 1, 1 }, { 1, 2 }, + { 1, 3 }, { 1, 4 }, + }, + { // Mode 3 + { 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 }, { 0, 4 }, { 2, 0 }, { 2, 1 }, { 2, 2 }, { 2, 3 }, { 2, 4 }, + { 2, 5 }, { 2, 6 }, { 2, 7 }, { 2, 8 }, { 2, 9 }, { 3, 0 }, { 3, 1 }, { 3, 2 }, { 3, 3 }, { 3, 4 }, + { 3, 5 }, { 3, 6 }, { 3, 7 }, { 3, 8 }, { 3, 9 }, { 4, 0 }, { 4, 1 }, { 4, 2 }, { 4, 3 }, { 4, 4 }, + { 4, 5 }, { 4, 6 }, { 4, 7 }, { 4, 8 }, { 4, 9 }, { 5, 0 }, { 5, 1 }, { 5, 2 }, { 5, 3 }, { 5, 4 }, + { 2, 10 }, { 9, 0 }, { 9, 1 }, { 9, 2 }, { 9, 3 }, { 6, 0 }, { 6, 1 }, { 6, 2 }, { 6, 3 }, { 3, 10 }, + { 13, 0 }, { 12, 0 }, { 12, 1 }, { 12, 2 }, { 12, 3 }, { 7, 0 }, { 7, 1 }, { 7, 2 }, { 7, 3 }, { 4, 10 }, + { 13, 1 }, { 10, 0 }, { 10, 1 }, { 10, 2 }, { 10, 3 }, { 8, 0 }, { 8, 1 }, { 8, 2 }, { 8, 3 }, { 8, 4 }, + { 13, 2 }, { 11, 0 }, { 11, 1 }, { 11, 2 }, { 11, 3 }, { 11, 4 }, { 13, 3 }, { 1, 0 }, { 1, 1 }, { 1, 2 }, + { 1, 3 }, { 1, 4 }, + }, + { // Mode 4 + { 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 }, { 0, 4 }, { 2, 0 }, { 2, 1 }, { 2, 2 }, { 2, 3 }, { 2, 4 }, + { 2, 5 }, { 2, 6 }, { 2, 7 }, { 2, 8 }, { 2, 9 }, { 3, 0 }, { 3, 1 }, { 3, 2 }, { 3, 3 }, { 3, 4 }, + { 3, 5 }, { 3, 6 }, { 3, 7 }, { 3, 8 }, { 3, 9 }, { 4, 0 }, { 4, 1 }, { 4, 2 }, { 4, 3 }, { 4, 4 }, + { 4, 5 }, { 4, 6 }, { 4, 7 }, { 4, 8 }, { 4, 9 }, { 5, 0 }, { 5, 1 }, { 5, 2 }, { 5, 3 }, { 2, 10 }, + { 12, 4 }, { 9, 0 }, { 9, 1 }, { 9, 2 }, { 9, 3 }, { 6, 0 }, { 6, 1 }, { 6, 2 }, { 6, 3 }, { 6, 4 }, + { 3, 10 }, { 12, 0 }, { 12, 1 }, { 12, 2 }, { 12, 3 }, { 7, 0 }, { 7, 1 }, { 7, 2 }, { 7, 3 }, { 4, 10 }, + { 13, 1 }, { 10, 0 }, { 10, 1 }, { 10, 2 }, { 10, 3 }, { 8, 0 }, { 8, 1 }, { 8, 2 }, { 8, 3 }, { 13, 0 }, + { 13, 2 }, { 11, 0 }, { 11, 1 }, { 11, 2 }, { 11, 3 }, { 9, 4 }, { 13, 3 }, { 1, 0 }, { 1, 1 }, { 1, 2 }, + { 1, 3 }, { 1, 4 }, + }, + { // Mode 5 + { 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 }, { 0, 4 }, { 2, 0 }, { 2, 1 }, { 2, 2 }, { 2, 3 }, { 2, 4 }, + { 2, 5 }, { 2, 6 }, { 2, 7 }, { 2, 8 }, { 2, 9 }, { 3, 0 }, { 3, 1 }, { 3, 2 }, { 3, 3 }, { 3, 4 }, + { 3, 5 }, { 3, 6 }, { 3, 7 }, { 3, 8 }, { 3, 9 }, { 4, 0 }, { 4, 1 }, { 4, 2 }, { 4, 3 }, { 4, 4 }, + { 4, 5 }, { 4, 6 }, { 4, 7 }, { 4, 8 }, { 4, 9 }, { 5, 0 }, { 5, 1 }, { 5, 2 }, { 5, 3 }, { 2, 10 }, + { 10, 4 }, { 9, 0 }, { 9, 1 }, { 9, 2 }, { 9, 3 }, { 6, 0 }, { 6, 1 }, { 6, 2 }, { 6, 3 }, { 3, 10 }, + { 13, 0 }, { 12, 0 }, { 12, 1 }, { 12, 2 }, { 12, 3 }, { 7, 0 }, { 7, 1 }, { 7, 2 }, { 7, 3 }, { 7, 4 }, + { 4, 10 }, { 10, 0 }, { 10, 1 }, { 10, 2 }, { 10, 3 }, { 8, 0 }, { 8, 1 }, { 8, 2 }, { 8, 3 }, { 13, 1 }, + { 13, 2 }, { 11, 0 }, { 11, 1 }, { 11, 2 }, { 11, 3 }, { 13, 4 }, { 13, 3 }, { 1, 0 }, { 1, 1 }, { 1, 2 }, + { 1, 3 }, { 1, 4 }, + }, + { // Mode 6 + { 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 }, { 0, 4 }, { 2, 0 }, { 2, 1 }, { 2, 2 }, { 2, 3 }, { 2, 4 }, + { 2, 5 }, { 2, 6 }, { 2, 7 }, { 2, 8 }, { 10, 4 }, { 3, 0 }, { 3, 1 }, { 3, 2 }, { 3, 3 }, { 3, 4 }, + { 3, 5 }, { 3, 6 }, { 3, 7 }, { 3, 8 }, { 9, 4 }, { 4, 0 }, { 4, 1 }, { 4, 2 }, { 4, 3 }, { 4, 4 }, + { 4, 5 }, { 4, 6 }, { 4, 7 }, { 4, 8 }, { 13, 4 }, { 5, 0 }, { 5, 1 }, { 5, 2 }, { 5, 3 }, { 5, 4 }, + { 12, 4 }, { 9, 0 }, { 9, 1 }, { 9, 2 }, { 9, 3 }, { 6, 0 }, { 6, 1 }, { 6, 2 }, { 6, 3 }, { 6, 4 }, + { 13, 0 }, { 12, 0 }, { 12, 1 }, { 12, 2 }, { 12, 3 }, { 7, 0 }, { 7, 1 }, { 7, 2 }, { 7, 3 }, { 7, 4 }, + { 13, 1 }, { 10, 0 }, { 10, 1 }, { 10, 2 }, { 10, 3 }, { 8, 0 }, { 8, 1 }, { 8, 2 }, { 8, 3 }, { 8, 4 }, + { 13, 2 }, { 11, 0 }, { 11, 1 }, { 11, 2 }, { 11, 3 }, { 11, 4 }, { 13, 3 }, { 1, 0 }, { 1, 1 }, { 1, 2 }, + { 1, 3 }, { 1, 4 }, + }, + { // Mode 7 + { 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 }, { 0, 4 }, { 2, 0 }, { 2, 1 }, { 2, 2 }, { 2, 3 }, { 2, 4 }, + { 2, 5 }, { 2, 6 }, { 2, 7 }, { 12, 4 }, { 10, 4 }, { 3, 0 }, { 3, 1 }, { 3, 2 }, { 3, 3 }, { 3, 4 }, + { 3, 5 }, { 3, 6 }, { 3, 7 }, { 13, 2 }, { 9, 4 }, { 4, 0 }, { 4, 1 }, { 4, 2 }, { 4, 3 }, { 4, 4 }, + { 4, 5 }, { 4, 6 }, { 4, 7 }, { 13, 3 }, { 13, 4 }, { 5, 0 }, { 5, 1 }, { 5, 2 }, { 5, 3 }, { 5, 4 }, + { 5, 5 }, { 9, 0 }, { 9, 1 }, { 9, 2 }, { 9, 3 }, { 6, 0 }, { 6, 1 }, { 6, 2 }, { 6, 3 }, { 6, 4 }, + { 13, 0 }, { 12, 0 }, { 12, 1 }, { 12, 2 }, { 12, 3 }, { 7, 0 }, { 7, 1 }, { 7, 2 }, { 7, 3 }, { 7, 4 }, + { 13, 1 }, { 10, 0 }, { 10, 1 }, { 10, 2 }, { 10, 3 }, { 8, 0 }, { 8, 1 }, { 8, 2 }, { 8, 3 }, { 8, 4 }, + { 8, 5 }, { 11, 0 }, { 11, 1 }, { 11, 2 }, { 11, 3 }, { 11, 4 }, { 11, 5 }, { 1, 0 }, { 1, 1 }, { 1, 2 }, + { 1, 3 }, { 1, 4 }, + }, + { // Mode 8 + { 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 }, { 0, 4 }, { 2, 0 }, { 2, 1 }, { 2, 2 }, { 2, 3 }, { 2, 4 }, + { 2, 5 }, { 2, 6 }, { 2, 7 }, { 13, 0 }, { 10, 4 }, { 3, 0 }, { 3, 1 }, { 3, 2 }, { 3, 3 }, { 3, 4 }, + { 3, 5 }, { 3, 6 }, { 3, 7 }, { 9, 5 }, { 9, 4 }, { 4, 0 }, { 4, 1 }, { 4, 2 }, { 4, 3 }, { 4, 4 }, + { 4, 5 }, { 4, 6 }, { 4, 7 }, { 12, 5 }, { 13, 4 }, { 5, 0 }, { 5, 1 }, { 5, 2 }, { 5, 3 }, { 5, 4 }, + { 12, 4 }, { 9, 0 }, { 9, 1 }, { 9, 2 }, { 9, 3 }, { 6, 0 }, { 6, 1 }, { 6, 2 }, { 6, 3 }, { 6, 4 }, + { 6, 5 }, { 12, 0 }, { 12, 1 }, { 12, 2 }, { 12, 3 }, { 7, 0 }, { 7, 1 }, { 7, 2 }, { 7, 3 }, { 7, 4 }, + { 13, 1 }, { 10, 0 }, { 10, 1 }, { 10, 2 }, { 10, 3 }, { 8, 0 }, { 8, 1 }, { 8, 2 }, { 8, 3 }, { 8, 4 }, + { 13, 2 }, { 11, 0 }, { 11, 1 }, { 11, 2 }, { 11, 3 }, { 11, 4 }, { 13, 3 }, { 1, 0 }, { 1, 1 }, { 1, 2 }, + { 1, 3 }, { 1, 4 }, + }, + { // Mode 9 + { 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 }, { 0, 4 }, { 2, 0 }, { 2, 1 }, { 2, 2 }, { 2, 3 }, { 2, 4 }, + { 2, 5 }, { 2, 6 }, { 2, 7 }, { 13, 1 }, { 10, 4 }, { 3, 0 }, { 3, 1 }, { 3, 2 }, { 3, 3 }, { 3, 4 }, + { 3, 5 }, { 3, 6 }, { 3, 7 }, { 10, 5 }, { 9, 4 }, { 4, 0 }, { 4, 1 }, { 4, 2 }, { 4, 3 }, { 4, 4 }, + { 4, 5 }, { 4, 6 }, { 4, 7 }, { 13, 5 }, { 13, 4 }, { 5, 0 }, { 5, 1 }, { 5, 2 }, { 5, 3 }, { 5, 4 }, + { 12, 4 }, { 9, 0 }, { 9, 1 }, { 9, 2 }, { 9, 3 }, { 6, 0 }, { 6, 1 }, { 6, 2 }, { 6, 3 }, { 6, 4 }, + { 13, 0 }, { 12, 0 }, { 12, 1 }, { 12, 2 }, { 12, 3 }, { 7, 0 }, { 7, 1 }, { 7, 2 }, { 7, 3 }, { 7, 4 }, + { 7, 5 }, { 10, 0 }, { 10, 1 }, { 10, 2 }, { 10, 3 }, { 8, 0 }, { 8, 1 }, { 8, 2 }, { 8, 3 }, { 8, 4 }, + { 13, 2 }, { 11, 0 }, { 11, 1 }, { 11, 2 }, { 11, 3 }, { 11, 4 }, { 13, 3 }, { 1, 0 }, { 1, 1 }, { 1, 2 }, + { 1, 3 }, { 1, 4 }, + }, + { // Mode 10 + { 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 }, { 0, 4 }, { 2, 0 }, { 2, 1 }, { 2, 2 }, { 2, 3 }, { 2, 4 }, + { 2, 5 }, { 12, 4 }, { 13, 0 }, { 13, 1 }, { 10, 4 }, { 3, 0 }, { 3, 1 }, { 3, 2 }, { 3, 3 }, { 3, 4 }, + { 3, 5 }, { 9, 5 }, { 10, 5 }, { 13, 2 }, { 9, 4 }, { 4, 0 }, { 4, 1 }, { 4, 2 }, { 4, 3 }, { 4, 4 }, + { 4, 5 }, { 12, 5 }, { 13, 3 }, { 13, 5 }, { 13, 4 }, { 5, 0 }, { 5, 1 }, { 5, 2 }, { 5, 3 }, { 5, 4 }, + { 5, 5 }, { 9, 0 }, { 9, 1 }, { 9, 2 }, { 9, 3 }, { 6, 0 }, { 6, 1 }, { 6, 2 }, { 6, 3 }, { 6, 4 }, + { 6, 5 }, { 12, 0 }, { 12, 1 }, { 12, 2 }, { 12, 3 }, { 7, 0 }, { 7, 1 }, { 7, 2 }, { 7, 3 }, { 7, 4 }, + { 7, 5 }, { 10, 0 }, { 10, 1 }, { 10, 2 }, { 10, 3 }, { 8, 0 }, { 8, 1 }, { 8, 2 }, { 8, 3 }, { 8, 4 }, + { 8, 5 }, { 11, 0 }, { 11, 1 }, { 11, 2 }, { 11, 3 }, { 11, 4 }, { 11, 5 }, { 1, 0 }, { 1, 1 }, { 1, 2 }, + { 1, 3 }, { 1, 4 }, + }, + { // Mode 11 + { 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 }, { 0, 4 }, { 2, 0 }, { 2, 1 }, { 2, 2 }, { 2, 3 }, { 2, 4 }, + { 2, 5 }, { 2, 6 }, { 2, 7 }, { 2, 8 }, { 2, 9 }, { 3, 0 }, { 3, 1 }, { 3, 2 }, { 3, 3 }, { 3, 4 }, + { 3, 5 }, { 3, 6 }, { 3, 7 }, { 3, 8 }, { 3, 9 }, { 4, 0 }, { 4, 1 }, { 4, 2 }, { 4, 3 }, { 4, 4 }, + { 4, 5 }, { 4, 6 }, { 4, 7 }, { 4, 8 }, { 4, 9 }, { 5, 0 }, { 5, 1 }, { 5, 2 }, { 5, 3 }, { 5, 4 }, + { 5, 5 }, { 5, 6 }, { 5, 7 }, { 5, 8 }, { 5, 9 }, { 6, 0 }, { 6, 1 }, { 6, 2 }, { 6, 3 }, { 6, 4 }, + { 6, 5 }, { 6, 6 }, { 6, 7 }, { 6, 8 }, { 6, 9 }, { 7, 0 }, { 7, 1 }, { 7, 2 }, { 7, 3 }, { 7, 4 }, + { 7, 5 }, { 7, 6 }, { 7, 7 }, { 7, 8 }, { 7, 9 }, + }, + { // Mode 12 + { 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 }, { 0, 4 }, { 2, 0 }, { 2, 1 }, { 2, 2 }, { 2, 3 }, { 2, 4 }, + { 2, 5 }, { 2, 6 }, { 2, 7 }, { 2, 8 }, { 2, 9 }, { 3, 0 }, { 3, 1 }, { 3, 2 }, { 3, 3 }, { 3, 4 }, + { 3, 5 }, { 3, 6 }, { 3, 7 }, { 3, 8 }, { 3, 9 }, { 4, 0 }, { 4, 1 }, { 4, 2 }, { 4, 3 }, { 4, 4 }, + { 4, 5 }, { 4, 6 }, { 4, 7 }, { 4, 8 }, { 4, 9 }, { 5, 0 }, { 5, 1 }, { 5, 2 }, { 5, 3 }, { 5, 4 }, + { 5, 5 }, { 5, 6 }, { 5, 7 }, { 5, 8 }, { 2, 10 }, { 6, 0 }, { 6, 1 }, { 6, 2 }, { 6, 3 }, { 6, 4 }, + { 6, 5 }, { 6, 6 }, { 6, 7 }, { 6, 8 }, { 3, 10 }, { 7, 0 }, { 7, 1 }, { 7, 2 }, { 7, 3 }, { 7, 4 }, + { 7, 5 }, { 7, 6 }, { 7, 7 }, { 7, 8 }, { 4, 10 }, + }, + { // Mode 13 + { 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 }, { 0, 4 }, { 2, 0 }, { 2, 1 }, { 2, 2 }, { 2, 3 }, { 2, 4 }, + { 2, 5 }, { 2, 6 }, { 2, 7 }, { 2, 8 }, { 2, 9 }, { 3, 0 }, { 3, 1 }, { 3, 2 }, { 3, 3 }, { 3, 4 }, + { 3, 5 }, { 3, 6 }, { 3, 7 }, { 3, 8 }, { 3, 9 }, { 4, 0 }, { 4, 1 }, { 4, 2 }, { 4, 3 }, { 4, 4 }, + { 4, 5 }, { 4, 6 }, { 4, 7 }, { 4, 8 }, { 4, 9 }, { 5, 0 }, { 5, 1 }, { 5, 2 }, { 5, 3 }, { 5, 4 }, + { 5, 5 }, { 5, 6 }, { 5, 7 }, { 2, 10 }, { 2, 11 }, { 6, 0 }, { 6, 1 }, { 6, 2 }, { 6, 3 }, { 6, 4 }, + { 6, 5 }, { 6, 6 }, { 6, 7 }, { 3, 10 }, { 3, 11 }, { 7, 0 }, { 7, 1 }, { 7, 2 }, { 7, 3 }, { 7, 4 }, + { 7, 5 }, { 7, 6 }, { 7, 7 }, { 4, 10 }, { 4, 11 }, + }, + { // Mode 14 + { 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 }, { 0, 4 }, { 2, 0 }, { 2, 1 }, { 2, 2 }, { 2, 3 }, { 2, 4 }, + { 2, 5 }, { 2, 6 }, { 2, 7 }, { 2, 8 }, { 2, 9 }, { 3, 0 }, { 3, 1 }, { 3, 2 }, { 3, 3 }, { 3, 4 }, + { 3, 5 }, { 3, 6 }, { 3, 7 }, { 3, 8 }, { 3, 9 }, { 4, 0 }, { 4, 1 }, { 4, 2 }, { 4, 3 }, { 4, 4 }, + { 4, 5 }, { 4, 6 }, { 4, 7 }, { 4, 8 }, { 4, 9 }, { 5, 0 }, { 5, 1 }, { 5, 2 }, { 5, 3 }, { 2, 10 }, + { 2, 11 }, { 2, 12 }, { 2, 13 }, { 2, 14 }, { 2, 15 }, { 6, 0 }, { 6, 1 }, { 6, 2 }, { 6, 3 }, { 3, 10 }, + { 3, 11 }, { 3, 12 }, { 3, 13 }, { 3, 14 }, { 3, 15 }, { 7, 0 }, { 7, 1 }, { 7, 2 }, { 7, 3 }, { 4, 10 }, + { 4, 11 }, { 4, 12 }, { 4, 13 }, { 4, 14 }, { 4, 15 }, + }, +}; diff --git a/src/startup_stubs/xcrdapi.cpp b/src/startup_stubs/xcrdapi.cpp index 42546d249a..7434b69ec4 100644 --- a/src/startup_stubs/xcrdapi.cpp +++ b/src/startup_stubs/xcrdapi.cpp @@ -886,27 +886,18 @@ void execute_request(Object* self, const unsigned char* request, const ULONG_PTR if (input) { bool bcpack_decoded = false; if (data && bcpack) { - if (bcpack == 7 || bcpack == 1 || bcpack == 4 || bcpack == 5 || bcpack == 3) { - std::vector decoded(destination_size); - std::size_t produced = 0; - if (x2w_bcpack::decode_bcpack(data, decode_length, bcpack, decoded.data(), decoded.size(), &produced)) { - output = std::move(decoded); - data = output.data(); - decode_length = produced; - outcome = zlib ? "inflated + bcpack decoded" : "bcpack decoded"; - bcpack_decoded = true; - } else { - outcome = "bcpack failed"; - failure = StorageFailure::bcpack; - data = nullptr; - } - } else { - // shortcut for formats not decoded yet: texels are left zero (a blank texture) so the - // title's loading continues. Counted as bcpack_blank. - output.assign(destination_size, 0); + std::vector decoded(destination_size); + std::size_t produced = 0; + if (x2w_bcpack::decode_bcpack(data, decode_length, bcpack, decoded.data(), decoded.size(), &produced)) { + output = std::move(decoded); data = output.data(); - decode_length = destination_size; - outcome = "BCPack not decoded: zero-filled"; + decode_length = produced; + outcome = zlib ? "inflated + bcpack decoded" : "bcpack decoded"; + bcpack_decoded = true; + } else { + outcome = "bcpack failed"; + failure = StorageFailure::bcpack; + data = nullptr; } } if (data) { diff --git a/tests/bcpack_format_fixtures.h b/tests/bcpack_format_fixtures.h new file mode 100644 index 0000000000..2dbd7fab74 --- /dev/null +++ b/tests/bcpack_format_fixtures.h @@ -0,0 +1,85 @@ +// Synthetic lane inputs, independent of the decoder's predictor and rank tables. +// SPDX-License-Identifier: MIT +#pragma once +#include "bcpack_encoder.h" +#include + +namespace bcpack_fixture { +inline constexpr uint8_t AB[7][16] = { + {7,7,4,5,4,4,5,4,7,7,7,7}, + {3,3,3,3,3,3,3,3,3,3,4,5,4,7,7}, + {3,3,7,5,5,5,5,4,5,4,7,7}, + {7,7,7,7,5,5,5,5,5,5,5,5}, + {3,3,7,7,5,5,5,5,5,5,5,5}, + {3,3,7,7,7,4,4,4,5,5,5,7,7,7,7,4}, + {3,3,7,7,7,7,7,6,6,4,5,7,7,7,7,4}, +}; +inline size_t lanes(unsigned fmt) { return fmt >= 6 ? 16 : fmt == 2 ? 15 : 12; } +inline size_t per(unsigned fmt) { return fmt == 1 || fmt == 4 ? 1 : 2; } +inline size_t block_bytes(unsigned fmt) { return 8 * per(fmt); } + +inline void byte_symbols(std::vector& s, size_t at, unsigned value, size_t p) { + if (p == 1) { s[at] = static_cast(value); return; } + for (unsigned h = 0; h < 2; ++h) { + s[at+h] = 0; + for (unsigned b = 0; b < 4; ++b) s[at+h] |= ((value >> (2*b+h)) & 1) << b; + } +} + +inline std::vector reference_symbols(unsigned fmt, unsigned er, unsigned xr, unsigned mode) { + const size_t p = per(fmt); + std::vector s(lanes(fmt)*p, 0); + const int delta = static_cast((er-xr+128)&255)-128; + byte_symbols(s,0,delta >= 0 ? 2*delta : -2*delta-1,p); + byte_symbols(s,p,xr,p); + if (fmt == 6) { s[30] = static_cast(mode); s[31] = er & 31; } + return s; +} + +inline std::vector random_symbols(unsigned fmt, size_t blocks, uint64_t seed) { + const size_t target = per(fmt)*blocks; + std::vector s(lanes(fmt)*target); + bcpack_test::Rng rng{seed}; + for (size_t l = 0; l < lanes(fmt); ++l) + for (size_t i = 0; i < target; ++i) s[l*target+i] = static_cast(rng.below(1u << (AB[fmt-1][l]+1))); + if (fmt == 6) { + for (size_t i = 0; i < blocks; ++i) { + s[15*target+2*i] = static_cast(i%14); + s[15*target+2*i+1] = static_cast(i%32); + } + } else if (fmt == 7) { + // Choose all mapped controls; expected BC7 bytes still come from the oracle. + std::vector codes; + for (unsigned c = 0; c < 512; ++c) + if (x2w_bcpack::BC7_CONTROL_TABLE[c].valid) codes.push_back(c); + for (size_t i = 0; i < blocks; ++i) { + const unsigned code = codes[i%codes.size()]; + s[15*target+2*i] = code & 31; + s[15*target+2*i+1] = code >> 5; + } + } + return s; +} + +inline bool encode(unsigned fmt, const std::vector& s, size_t blocks, std::vector& stream) { + const size_t target = blocks*per(fmt), n = lanes(fmt); + if (!target || s.size() != n*target) return false; + std::vector> encoded(n); + for (size_t l = 0; l < n; ++l) { + for (size_t at = 0; at < target;) { + const size_t count = std::min(size_t(128),target-at); + bool ok = false; + for (uint8_t q = 0; q < 16 && !ok; ++q) { + std::vector fragment; + if (bcpack_test::encode_fragment(AB[fmt-1][l],0,q,s.data()+l*target+at,count,true,fragment)) { + encoded[l].insert(encoded[l].end(),fragment.begin(),fragment.end()); + ok = true; + } + } + if (!ok) return false; + at += count; + } + } + return bcpack_test::interleave(encoded,AB[fmt-1],n,target,stream); +} +} // namespace bcpack_fixture diff --git a/tests/bcpack_formats_check.cpp b/tests/bcpack_formats_check.cpp new file mode 100644 index 0000000000..5f74f9dc71 --- /dev/null +++ b/tests/bcpack_formats_check.cpp @@ -0,0 +1,120 @@ +// Oracle-derived golden hashes of source-built synthetic streams. No SDK at test/run time. +// Optional --oracle ABSOLUTE_DLL_PATH regenerates hashes using an installed developer oracle. +// See docs/experiments/bcpack-standalone.md for provenance and commands. +// SPDX-License-Identifier: MIT +#define WIN32_LEAN_AND_MEAN +#define NOMINMAX +#include +#include "bcpack_format_fixtures.h" +#include "bcpack_formats_goldens.h" +#include +#include + +namespace { +using Oracle = long (__cdecl*)(size_t,void*,size_t,const void*,size_t); +Oracle oracle = nullptr; +bool mutate = false; +size_t cases = 0; + +uint64_t hash(uint64_t h, const std::vector& bytes) { + for (uint8_t b : bytes) { h ^= b; h *= 1099511628211ull; } + return h; +} + +bool check(unsigned fmt, const std::vector& s, size_t blocks, uint64_t& h) { + std::vector packed; + if (!bcpack_fixture::encode(fmt,s,blocks,packed)) return false; + const size_t size = blocks*bcpack_fixture::block_bytes(fmt); + std::vector expected(size), guarded(size+32,0xa5); + if (oracle) { + if (oracle(fmt,expected.data(),size,packed.data(),packed.size()) < 0) return false; + } else { + bool first = true; + for (int path = 0; path < x2w_bcpack::LANE_PATH_COUNT; ++path) { + if (!x2w_bcpack::lane_path_supported(path)) continue; + x2w_bcpack::lane_path_override = path; + std::fill(guarded.begin(),guarded.end(),0xa5); + size_t produced = 123; + if (!x2w_bcpack::decode_bcpack(packed.data(),packed.size(),fmt,guarded.data()+16,size,&produced) || produced != size) + return false; + for (size_t i = 0; i < 16; ++i) + if (guarded[i] != 0xa5 || guarded[size+16+i] != 0xa5) return false; + if (first) { + std::copy(guarded.begin()+16,guarded.end()-16,expected.begin()); + first = false; + } else if (!std::equal(expected.begin(),expected.end(),guarded.begin()+16)) return false; + } + } + if (mutate && fmt == 2 && cases == 0) expected[0] ^= 1; + h = hash(h,expected); + ++cases; + return true; +} + +bool group(unsigned fmt, int mode, uint64_t expected) { + uint64_t h = 14695981039346656037ull; + cases = 0; + if (mode >= 0) { + for (unsigned r = 0; r < 256; ++r) { + const unsigned ep[] = {r,0,r}, ix[] = {0,r,(r*73+19)&255}; + for (unsigned k = 0; k < 3; ++k) + if (!check(fmt,bcpack_fixture::reference_symbols(fmt,ep[k],ix[k],mode),1,h)) return false; + } + } else { + for (size_t blocks : {size_t(2),size_t(17),size_t(255),size_t(256),size_t(257),size_t(1024)}) + if (!check(fmt,bcpack_fixture::random_symbols(fmt,blocks,0xbc9900+fmt+blocks),blocks,h)) return false; + } + std::printf("BC%u mode %d: %zu cases, %016llx%s\n",fmt,mode,cases, + static_cast(h), oracle || h == expected ? "" : " MISMATCH"); + return oracle || h == expected; +} + +bool failures() { + for (unsigned fmt = 1; fmt <= 7; ++fmt) { + auto s = bcpack_fixture::random_symbols(fmt,17,0x1122+fmt); + std::vector packed; + if (!bcpack_fixture::encode(fmt,s,17,packed)) return false; + const size_t size = 17*bcpack_fixture::block_bytes(fmt); + std::vector out(size+32,0xa5); + auto reject = [&](size_t input_size, size_t output_size, unsigned format) { + size_t produced = 123; + return !x2w_bcpack::decode_bcpack(packed.data(),input_size,format,out.data()+16,output_size,&produced) && produced == 0 && + std::all_of(out.begin(),out.end(),[](uint8_t b){return b == 0xa5;}); + }; + if (!reject(1,size,fmt) || !reject(packed.size(),size-1,fmt) || + !reject(packed.size(),size,0) || !reject(packed.size(),size,8)) return false; + packed.push_back(0xff); + if (!reject(packed.size(),size,fmt)) return false; + } + // A valid entropy stream can still contain an undefined BC6H mode. + std::vector s(32,0); + s[30] = 14; + std::vector packed; + if (!bcpack_fixture::encode(6,s,1,packed)) return false; + uint8_t out[16] = {}; size_t produced = 123; + return !x2w_bcpack::decode_bcpack(packed.data(),packed.size(),6,out,sizeof(out),&produced) && produced == 0; +} +} // namespace + +int main(int argc, char** argv) { + HMODULE library = nullptr; + if (argc == 3 && std::string(argv[1]) == "--oracle") { + library = LoadLibraryExA(argv[2],nullptr,LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); + if (!library) return 2; + oracle = reinterpret_cast(GetProcAddress(library,"BCPackDecompress")); + if (!oracle) { FreeLibrary(library); return 2; } + } else if (argc == 2 && std::string(argv[1]) == "--mutate") mutate = true; + else if (argc != 1) return 2; + bool ok = true; + for (unsigned fmt : {1u,2u,6u}) { + const unsigned modes = fmt == 6 ? 14 : 1; + for (unsigned mode = 0; mode < modes; ++mode) + ok = group(fmt,mode,BCPACK_REFERENCE_GOLDENS[fmt == 1 ? 0 : fmt == 2 ? 1 : mode+2]) && ok; + } + for (unsigned fmt = 1; fmt <= 7; ++fmt) + ok = group(fmt,-1,BCPACK_RANDOM_GOLDENS[fmt-1]) && ok; + if (!oracle) ok = failures() && ok; + if (library) FreeLibrary(library); + std::puts(ok ? "PASS" : "FAIL"); + return ok ? 0 : 1; +} diff --git a/tests/bcpack_formats_goldens.h b/tests/bcpack_formats_goldens.h new file mode 100644 index 0000000000..dce02eb446 --- /dev/null +++ b/tests/bcpack_formats_goldens.h @@ -0,0 +1,32 @@ +// FNV-1a-64 of GDK 1.2603.3.0 output for source-built synthetic streams. +// Generated by bcpack_formats_check --oracle; see docs/experiments/bcpack-standalone.md. +// SPDX-License-Identifier: MIT +#pragma once +#include +inline constexpr uint64_t BCPACK_REFERENCE_GOLDENS[16] = { + 0x34c5c81aac38ab05ull, + 0x3fbe7d532c8a8ee5ull, + 0x3ad5c83091ad36c8ull, + 0xa166156f9d7c2584ull, + 0xf8dcf5a64a9bc914ull, + 0xc793a6b84f33d1f8ull, + 0x878c19433aad5528ull, + 0x323fe930ab1bbb34ull, + 0x7da68746bab3e824ull, + 0xdb039400e610986cull, + 0x057898faa1d59bf4ull, + 0x840acfcd001e5de0ull, + 0x0f6512b21bceaec9ull, + 0xb8a2e7bdf73cad4dull, + 0x48b0f9f1c4216b49ull, + 0x5dfb4aa715489a1dull, +}; +inline constexpr uint64_t BCPACK_RANDOM_GOLDENS[7] = { + 0x1b0b9d7ad64ed0ebull, + 0x80d855e20ab59f94ull, + 0x0c4a4d67b9bea24full, + 0x736c245fee5efa9aull, + 0xd75651737d36c49aull, + 0x8b25e69129e6d691ull, + 0xc498f7502500346dull, +}; diff --git a/tests/bcpack_oracle_bridge.cpp b/tests/bcpack_oracle_bridge.cpp new file mode 100644 index 0000000000..6683875f2d --- /dev/null +++ b/tests/bcpack_oracle_bridge.cpp @@ -0,0 +1,20 @@ +// Synthetic input bridge for the optional development-only constant recovery tool. +// SPDX-License-Identifier: MIT +#include "bcpack_format_fixtures.h" +#include +extern "C" __declspec(dllexport) size_t encode_symbols(unsigned fmt, const uint16_t* symbols, + size_t target, uint8_t* output, size_t capacity) { + if (fmt < 1 || fmt > 7 || !symbols || !output || !target || target%bcpack_fixture::per(fmt)) return 0; + std::vector s(symbols,symbols+target*bcpack_fixture::lanes(fmt)); + std::vector packed; + if (!bcpack_fixture::encode(fmt,s,target/bcpack_fixture::per(fmt),packed) || packed.size() > capacity) return 0; + std::memcpy(output,packed.data(),packed.size()); + return packed.size(); +} +extern "C" __declspec(dllexport) size_t storage_symbols(unsigned fmt, uint16_t* output, size_t capacity) { + if ((fmt != 2 && fmt != 6) || !output) return 0; + auto s = bcpack_fixture::random_symbols(fmt,4,0x7700+fmt); + if (capacity < s.size()) return 0; + std::copy(s.begin(),s.end(),output); + return s.size(); +} diff --git a/tests/bcpack_storage_checks.inl b/tests/bcpack_storage_checks.inl new file mode 100644 index 0000000000..9df107ce77 --- /dev/null +++ b/tests/bcpack_storage_checks.inl @@ -0,0 +1,112 @@ +// Included by the source-built startup consumer after its queue/zlib helpers. +// SPDX-License-Identifier: MIT + +bool bcpack_storage_checks() { + _putenv("X2W_XMEM_PERMISSIVE=1"); + const auto library = LoadLibraryW(L"XCRDAPI.dll"); + if (!library) return false; + const auto get_factory = reinterpret_cast(GetProcAddress(library,"DStorageGetFactory")); + void* factory_ptr = nullptr; + if (!get_factory || get_factory(nullptr,&factory_ptr) != 0 || !factory_ptr) return false; + auto* factory = static_cast(factory_ptr); + for (unsigned fmt : {2u,6u}) { + const auto s = bcpack_fixture::random_symbols(fmt,4,0x7700+fmt); + std::vector packed; + if (!bcpack_fixture::encode(fmt,s,4,packed)) return false; + const auto zipped = make_stored_zlib(packed.data(),packed.size()); + const auto* expected = fmt == 2 ? BC2_STORAGE_EXPECTED : BC6_STORAGE_EXPECTED; + // Memory/file x raw/zlib, linear/page destinations; then failures followed by valid requests. + for (unsigned scenario = 0; scenario < (fmt == 6 ? 14u : 12u); ++scenario) { + const bool file = (scenario & 1) != 0; + const bool zlib = (scenario & 2) != 0; + const bool page = (scenario >= 4 && scenario < 10) || scenario == 13; + const bool invalid = scenario >= 8; + std::vector damaged; + if (scenario >= 12) { + auto bad = s; + bad[15*8+6] = 14; // final block's undefined mode, after three valid blocks + if (!bcpack_fixture::encode(fmt,bad,4,damaged)) return false; + } + const auto& input = scenario >= 12 ? damaged : zlib ? zipped : packed; + void *queue_ptr = nullptr, *status_ptr = nullptr; + uint8_t desc[0x20] = {}; *reinterpret_cast(desc+8) = 16; + if (reinterpret_cast(factory->vtable[10])(factory,desc,nullptr,&queue_ptr) != 0 || !queue_ptr || + reinterpret_cast(factory->vtable[5])(factory,2,"BCPack",nullptr,&status_ptr) != 0 || !status_ptr) + return false; + auto* queue = static_cast(queue_ptr); + auto* status = static_cast(status_ptr); + std::vector linear(96,0xa5), following(64,0xa5); + size_t page_count = 2; + u64 pages[2] = {}; + ULONG_PTR tokens[2] = {}; + void* view = nullptr; + if (page) { + if (!XMemAllocatePhysicalPages(0x20400000ull,&page_count,pages) || page_count != 2) return false; + tokens[0] = pages[0]; tokens[1] = pages[1]; + view = XMemVirtualAlloc(nullptr,131072,0x20402000,0x21,PAGE_READWRITE); + if (!view || XMemMapPhysicalPages(view,2,tokens) != view) return false; + std::memset(view,0xa5,131072); + if (scenario == 8 || scenario == 9) tokens[1] = 0; // missing second page: no partial publication + } + wchar_t temp_dir[MAX_PATH], temp_file[MAX_PATH] = {}; + Object* source_file = nullptr; + if (file) { + if (!GetTempPathW(MAX_PATH,temp_dir) || !GetTempFileNameW(temp_dir,L"bcp",0,temp_file)) return false; + const auto h = CreateFileW(temp_file,GENERIC_WRITE,0,nullptr,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,nullptr); + if (h == INVALID_HANDLE_VALUE) return false; + const uint8_t prefix[13] = {}; + DWORD written = 0; + const bool wrote = WriteFile(h,prefix,sizeof(prefix),&written,nullptr) && written == sizeof(prefix) && + WriteFile(h,input.data(),static_cast(input.size()),&written,nullptr) && written == input.size(); + CloseHandle(h); + void* ptr = nullptr; + if (!wrote || reinterpret_cast(factory->vtable[4])(factory,temp_file,nullptr,&ptr) != 0 || !ptr) return false; + source_file = static_cast(ptr); + } + uint8_t requests[2][0x48] = {}; + for (unsigned k = 0; k < 2; ++k) { + auto* r = requests[k]; + const bool first = k == 0; + const bool use_file = first && file, use_zlib = first && zlib, use_pages = first && page; + const auto& src = first ? input : packed; + unsigned request_format = first && (scenario == 10 || scenario == 11) ? 8 : fmt; + *reinterpret_cast(r) = (request_format << 1) | (use_zlib ? 1 : 0) | + (use_file ? 0 : 0x400000) | (use_pages ? 1ull<<21 : 0); + *reinterpret_cast(r+0x08) = use_pages ? static_cast(tokens) : + first ? static_cast(linear.data()+16) : static_cast(following.data()); + *reinterpret_cast(r+0x10) = use_pages ? 65520 : 0; + *reinterpret_cast(r+0x18) = 64; + *reinterpret_cast(r+0x20) = use_file ? static_cast(source_file) : src.data(); + *reinterpret_cast(r+0x28) = use_file ? 13 : 0; + *reinterpret_cast(r+0x30) = static_cast(src.size()); + *reinterpret_cast(r+0x34) = static_cast(packed.size()); + reinterpret_cast(queue->vtable[3])(queue,r); + reinterpret_cast(queue->vtable[4])(queue,status,k); + } + reinterpret_cast(queue->vtable[6])(queue); + for (int i = 0; i < 200 && !reinterpret_cast(status->vtable[3])(status,1); ++i) Sleep(10); + bool ok = reinterpret_cast(status->vtable[3])(status,1); + const long hr = reinterpret_cast(status->vtable[4])(status,0); + ok = ok && (invalid ? hr != 0 : hr == 0) && + reinterpret_cast(status->vtable[4])(status,1) == 0 && std::memcmp(following.data(),expected,64) == 0; + const auto* destination = page ? static_cast(view) : linear.data(); + const size_t size = page ? 131072 : linear.size(), offset = page ? 65520 : 16; + for (size_t at = 0; at < size; ++at) { + const uint8_t wanted = !invalid && at >= offset && at < offset+64 ? expected[at-offset] : 0xa5; + if (destination[at] != wanted) ok = false; + } + if (source_file) { + reinterpret_cast(source_file->vtable[3])(source_file); + DeleteFileW(temp_file); + } + if (view) { + XMemMapPhysicalPages(view,2,nullptr); + VirtualFree(view,0,MEM_RELEASE); + XMemFreePhysicalPages(2,pages); + } + std::printf("BC%u storage scenario %u: %s\n",fmt,scenario,ok ? "ok" : "FAIL"); + if (!ok) return false; + } + } + return true; +} diff --git a/tests/bcpack_storage_goldens.h b/tests/bcpack_storage_goldens.h new file mode 100644 index 0000000000..4f2f09b16e --- /dev/null +++ b/tests/bcpack_storage_goldens.h @@ -0,0 +1,15 @@ +// GDK 1.2603.3.0 golden BC blocks from random_symbols(fmt,4,0x7700+fmt). +// Entirely synthetic input, no SDK or title bytes. SPDX-License-Identifier: MIT +#pragma once +inline constexpr unsigned char BC2_STORAGE_EXPECTED[64] = { + 0x0a, 0x5a, 0xf0, 0x97, 0x8d, 0x91, 0x11, 0xbb, 0xff, 0xb9, 0x2f, 0x9e, 0xa6, 0x92, 0x7e, 0x8c, + 0x8f, 0x87, 0x8d, 0xb3, 0x65, 0x45, 0x15, 0x89, 0x44, 0x5f, 0x13, 0x7c, 0x57, 0x45, 0xaa, 0xde, + 0xed, 0x54, 0x81, 0xa6, 0x64, 0xcd, 0xd8, 0xbe, 0x91, 0x96, 0x07, 0x79, 0xf2, 0x16, 0xbd, 0xd0, + 0x12, 0x3c, 0xa4, 0x7c, 0xd7, 0x3a, 0xc8, 0x20, 0x92, 0xdc, 0x96, 0x5b, 0x41, 0x6a, 0x48, 0xc0, +}; +inline constexpr unsigned char BC6_STORAGE_EXPECTED[64] = { + 0x3c, 0xb0, 0x9e, 0x26, 0xae, 0xc9, 0x66, 0xae, 0x35, 0x0e, 0x60, 0xb7, 0xb5, 0x77, 0xc3, 0x32, + 0x49, 0x95, 0xfb, 0xad, 0x62, 0x12, 0xe7, 0x49, 0x02, 0x35, 0x44, 0xe2, 0xb5, 0xd3, 0xd9, 0x8d, + 0x02, 0xf3, 0x80, 0x2a, 0xb8, 0x95, 0xa1, 0x7b, 0x10, 0x5e, 0x64, 0x6d, 0x56, 0x72, 0x71, 0x05, + 0xe6, 0xe9, 0xcd, 0xd4, 0xc6, 0xc7, 0xe0, 0x59, 0xca, 0x7d, 0x30, 0x54, 0x5e, 0x09, 0xbc, 0xfe, +}; diff --git a/tests/bcpack_tables_check.py b/tests/bcpack_tables_check.py index 696d1ce81e..fd9f2a0a39 100644 --- a/tests/bcpack_tables_check.py +++ b/tests/bcpack_tables_check.py @@ -43,9 +43,9 @@ class BCPackTablesCheck(unittest.TestCase): @classmethod def setUpClass(cls): content = HEADER.read_text(encoding="utf-8") - inl = ROOT / "src" / "startup_stubs" / "bcpack_tables_bcn.inl" - if inl.exists() and '#include "bcpack_tables_bcn.inl"' in content: - content = content.replace('#include "bcpack_tables_bcn.inl"', inl.read_text(encoding="utf-8")) + for name in ("bcpack_tables_bcn.inl", "bcpack_tables_extra.inl"): + inl = HEADER.parent / name + content = content.replace(f'#include "{name}"', inl.read_text(encoding="utf-8")) cls.text = strip_comments(content) def test_rans_model_tables(self): @@ -96,22 +96,46 @@ def test_bc7_dictionary_structure(self): for b in row: self.assertIn(b, range(256)) - def test_bc1_window_structure(self): - window = extract_array(self.text, "BC1_WINDOW") - self.assertEqual(len(window), 256) - for row in window: - self.assertEqual(len(row), 6) - for b in row: - self.assertIn(b, range(256)) - - def test_bc1_quad_masks_structure(self): - quad_masks = extract_array(self.text, "BC1_QUAD_MASKS") - self.assertEqual(len(quad_masks), 4) - for row in quad_masks: - self.assertEqual(len(row), 256) - for mask in row: - self.assertGreaterEqual(mask, 0) - self.assertLessEqual(mask, 0xFFFFFFFF) + def test_bc1_bc2_exact_tables_structure(self): + for fmt in (1, 2): + ranks = extract_array(self.text, f"BC{fmt}_POSITION_RANK") + self.assertEqual(len(ranks), 256) + self.assertEqual({tuple(row) for row in ranks}, + {(a, b, c, d) for a in range(4) for b in range(4) + for c in range(4) for d in range(4)}) + dictionary = extract_array(self.text, f"BC{fmt}_FULL_DICTIONARY") + self.assertEqual(len(dictionary), 255) + for row in dictionary: + if fmt == 2: + alpha, ep, ix = row + self.assertEqual(len(alpha), 16) + self.assertTrue(all(v in range(16) for v in alpha)) + else: + ep, ix = row + self.assertEqual(len(ep), 6) + self.assertTrue(all(v in range(64 if i % 3 == 1 else 32) + for i, v in enumerate(ep))) + self.assertEqual(len(ix), 16) + self.assertTrue(all(v in range(4) for v in ix)) + + def test_bc6_tables_structure(self): + dictionary = extract_array(self.text, "BC6_DICTIONARY") + self.assertEqual(len(dictionary), 255) + for ep, ix in dictionary: + self.assertEqual(len(ep), 4) + for endpoint in ep: + self.assertEqual(len(endpoint), 3) + self.assertTrue(all(v in range(65536) for v in endpoint)) + self.assertEqual(len(ix), 16) + self.assertTrue(all(v in range(65536) for v in ix)) + wire = extract_array(self.text, "BC6_WIRE") + self.assertEqual(len(wire), 14) + for mode, row in enumerate(wire): + self.assertEqual(len(row), 82 if mode < 10 else 65) + for field, bit in row: + self.assertIn(field, range(14)) + self.assertIn(bit, range(16)) + self.assertEqual(len(extract_array(self.text, "BC6_ENDPOINT_BITS")), 15) def test_bc4_tables_structure(self): pairs = extract_array(self.text, "RANK_PAIR_BC4") @@ -202,10 +226,6 @@ def test_compare_with_reference_data_if_present(self): expected_dict.append([subsets, [ep[0:8], ep[8:16], ep[16:24]], [ix[0:16], ix[16:32]]]) self.assertEqual(extract_array(self.text, "BC7_DICTIONARY"), expected_dict) - window_json = json.loads((REF_DATA / "bc1_window.json").read_text(encoding="utf-8"))["slots"] - expected_window = [[0] * 6 if e is None else e["value"] for e in window_json] - self.assertEqual(extract_array(self.text, "BC1_WINDOW"), expected_window) - # BC4 checks bc4_json = json.loads((REF_DATA / "bc4.json").read_text(encoding="utf-8")) self.assertEqual(extract_array(self.text, "RANK_PAIR_BC4"), bc4_json["pairs"]) diff --git a/tests/cmake/bcpack_formats.cmake b/tests/cmake/bcpack_formats.cmake new file mode 100644 index 0000000000..aa1fe16d16 --- /dev/null +++ b/tests/cmake/bcpack_formats.cmake @@ -0,0 +1,15 @@ +add_executable(bcpack_formats_check tests/bcpack_formats_check.cpp) +target_compile_features(bcpack_formats_check PRIVATE cxx_std_17) +target_include_directories(bcpack_formats_check PRIVATE src) +target_compile_definitions(bcpack_formats_check PRIVATE X2W_BCPACK_LANE_TESTS) +add_test(NAME bcpack_all_formats COMMAND bcpack_formats_check) +add_test(NAME bcpack_all_formats_golden_control COMMAND bcpack_formats_check --mutate) +set_tests_properties(bcpack_all_formats bcpack_all_formats_golden_control PROPERTIES TIMEOUT 120) +set_tests_properties(bcpack_all_formats_golden_control PROPERTIES WILL_FAIL TRUE) +add_test(NAME startup_bcpack_storage COMMAND startup_stub_consumer bcpack-storage) +set_tests_properties(startup_bcpack_storage PROPERTIES TIMEOUT 60) + +# Explicit target only: normal builds and all runtime DLLs need no oracle bridge. +add_library(bcpack_oracle_bridge SHARED EXCLUDE_FROM_ALL tests/bcpack_oracle_bridge.cpp) +target_compile_features(bcpack_oracle_bridge PRIVATE cxx_std_17) +target_include_directories(bcpack_oracle_bridge PRIVATE src) diff --git a/tests/startup_stub_check.py b/tests/startup_stub_check.py index f2e39ccfa5..1398c34630 100644 --- a/tests/startup_stub_check.py +++ b/tests/startup_stub_check.py @@ -102,7 +102,7 @@ run.stderr) requests_by_format = {int(f): int(n) for f, n in re.findall(r"(\d+):(\d+)", summary.group(1))} if summary else {} blank_by_format = {int(f): int(n) for f, n in re.findall(r"(\d+):(\d+)", summary.group(2))} if summary else {} -bcpack_ok = (requests_by_format.get(6) == 1 and blank_by_format.get(6) == 1 +bcpack_ok = (requests_by_format.get(6) == 1 and blank_by_format.get(6, 0) == 0 and requests_by_format.get(1) == 2 and blank_by_format.get(1, 0) == 0 and requests_by_format.get(3) == 3 and blank_by_format.get(3, 0) == 0 and requests_by_format.get(4) == 4 and blank_by_format.get(4, 0) == 0 diff --git a/tests/startup_stub_consumer.cpp b/tests/startup_stub_consumer.cpp index 3951fa93a8..722f7f4b2f 100644 --- a/tests/startup_stub_consumer.cpp +++ b/tests/startup_stub_consumer.cpp @@ -24,6 +24,8 @@ #include #include #include +#include "bcpack_format_fixtures.h" +#include "bcpack_storage_goldens.h" using u64 = std::uint64_t; @@ -1964,39 +1966,40 @@ bool dstorage_checks() { std::memcpy(bc1_packed_trailing, bc1_packed, sizeof(bc1_packed)); bc1_packed_trailing[515] = 0x01; + // GDK 1.2603.3.0 output for the unchanged synthetic_11 input above. const unsigned char bc1_expected[512] = { - 0x85, 0x31, 0x64, 0xd5, 0xaf, 0xbe, 0xff, 0xbf, 0x50, 0x84, 0xc7, 0x6b, 0xba, 0xa5, 0xbf, 0xbf, - 0x50, 0x84, 0x27, 0xc9, 0x56, 0x06, 0x5e, 0x5f, 0x25, 0x6a, 0x43, 0xaa, 0x5e, 0xee, 0xf5, 0xf5, - 0xe8, 0x72, 0xa0, 0x91, 0x5e, 0x5e, 0xfb, 0xfb, 0x2a, 0x3b, 0x83, 0xf1, 0x9a, 0xa5, 0x7a, 0xfa, - 0x81, 0x08, 0xcc, 0xa2, 0x9a, 0x9d, 0xbb, 0xff, 0x28, 0x73, 0x20, 0xbe, 0x8a, 0x8f, 0x05, 0x05, - 0x41, 0x00, 0x8c, 0xda, 0xfa, 0x5f, 0xfa, 0xdb, 0xfe, 0x8a, 0x7a, 0x5a, 0x72, 0x3a, 0xfa, 0xba, - 0x41, 0xf8, 0x8c, 0x32, 0x0f, 0xff, 0xfa, 0xba, 0xec, 0x5a, 0xa6, 0xa9, 0x6b, 0x5f, 0xaf, 0xaf, - 0x50, 0x84, 0x26, 0x89, 0x5a, 0x5f, 0x5f, 0x5f, 0x44, 0x21, 0x23, 0xb1, 0xaf, 0x5d, 0xaf, 0xab, - 0x0d, 0x6b, 0x24, 0x52, 0xaf, 0xf7, 0xbf, 0xfd, 0x0c, 0x5b, 0x26, 0x7c, 0xbe, 0x9e, 0x05, 0x05, - 0x3e, 0x83, 0x7a, 0x39, 0xd5, 0x95, 0xaa, 0x5a, 0x61, 0x10, 0x6e, 0x68, 0x5b, 0x0f, 0xff, 0xbd, - 0x8a, 0x9b, 0x65, 0x51, 0x2f, 0xaa, 0xaa, 0x5a, 0xb8, 0xc6, 0xd3, 0x4a, 0x4f, 0x45, 0xf0, 0xb0, - 0x1e, 0xb6, 0x1e, 0x6d, 0x5b, 0x5f, 0xba, 0xba, 0x50, 0x84, 0x27, 0xe4, 0xfa, 0x5a, 0xaa, 0xaf, - 0x65, 0x52, 0x45, 0xd2, 0x5e, 0x0f, 0xaf, 0xef, 0xaf, 0x73, 0x06, 0x55, 0xae, 0x8f, 0xae, 0x5f, - 0x89, 0x52, 0xa1, 0x80, 0x0f, 0x0b, 0xa5, 0xa5, 0x03, 0x21, 0xe2, 0xe8, 0x7b, 0x5f, 0x0a, 0x0a, - 0xa5, 0x39, 0x23, 0x99, 0xd0, 0xd0, 0xaa, 0xff, 0x2c, 0x8b, 0xca, 0x0a, 0x20, 0xa0, 0xaf, 0xfb, - 0x28, 0x6b, 0xc1, 0x08, 0x0a, 0x5a, 0xff, 0xaa, 0x4a, 0x4a, 0x45, 0x09, 0xba, 0xab, 0x5e, 0x5e, - 0x0c, 0x7a, 0x40, 0xaa, 0x7f, 0x7e, 0x0e, 0x0f, 0x20, 0x48, 0x9d, 0x3b, 0x5f, 0x5f, 0x00, 0x00, - 0x4b, 0xd6, 0xc4, 0xd4, 0x60, 0x60, 0xfb, 0xef, 0x45, 0x3a, 0x41, 0xa9, 0xba, 0x9f, 0xa7, 0xf7, - 0x0d, 0x5b, 0x37, 0x4a, 0xdb, 0x2b, 0xef, 0xaa, 0x20, 0x48, 0x8e, 0x0b, 0x8e, 0xaa, 0xaf, 0xaf, - 0xd8, 0xcd, 0x75, 0x6d, 0x0e, 0x0a, 0xba, 0xff, 0xbc, 0xa3, 0xf8, 0x3e, 0xbf, 0xdf, 0x5a, 0xfa, - 0x9f, 0x08, 0xd2, 0x9a, 0x25, 0x5f, 0xff, 0xba, 0x09, 0x94, 0xc3, 0x82, 0xff, 0xfe, 0xba, 0xba, - 0x21, 0x79, 0x3c, 0x31, 0xaf, 0xfe, 0xaf, 0x5a, 0xbf, 0x53, 0xe1, 0xd1, 0xbf, 0xab, 0x5f, 0x5b, - 0x26, 0x6b, 0xc3, 0xd8, 0x2a, 0xb5, 0xfb, 0xbf, 0x89, 0x42, 0x5f, 0xe1, 0xaf, 0xff, 0xb5, 0xb5, - 0x0a, 0x94, 0x8b, 0xfb, 0xa5, 0xd5, 0x0f, 0x0f, 0xa8, 0x52, 0xc7, 0x01, 0x9f, 0xab, 0x55, 0x55, - 0x29, 0xf8, 0x86, 0x7a, 0xfa, 0xfa, 0xff, 0xaa, 0x40, 0x00, 0x9a, 0x7a, 0xbe, 0xfe, 0xfa, 0xfa, - 0x54, 0x8c, 0x29, 0xc4, 0x0a, 0x0a, 0xaf, 0xab, 0x6c, 0x6b, 0x08, 0x0a, 0xa0, 0xd0, 0xf0, 0xf0, - 0x6b, 0x7c, 0xd9, 0x51, 0xa5, 0xd5, 0xf5, 0xe5, 0x82, 0x21, 0x00, 0x32, 0x00, 0x50, 0xa0, 0xa0, - 0x42, 0x19, 0x35, 0x99, 0xbf, 0xe7, 0xaf, 0xff, 0x46, 0x7b, 0x60, 0x42, 0x60, 0x45, 0x0f, 0x0f, - 0xd4, 0x31, 0x33, 0x99, 0xda, 0xaa, 0xa5, 0xaf, 0x1a, 0xd7, 0xe9, 0x80, 0xba, 0xba, 0x0a, 0x0f, - 0xc6, 0x08, 0x97, 0xe0, 0xff, 0xfa, 0xba, 0xba, 0x51, 0xd6, 0xdf, 0xec, 0x65, 0x65, 0x5f, 0x5a, - 0xbb, 0xbe, 0xda, 0x22, 0x2e, 0xaa, 0xf0, 0xf0, 0x6c, 0x63, 0x1d, 0x72, 0xeb, 0xeb, 0x5f, 0x5f, - 0xce, 0x31, 0x36, 0x91, 0x70, 0x70, 0xaa, 0xf2, 0x57, 0x8c, 0x27, 0xb4, 0x8f, 0xab, 0xf0, 0xb0, - 0x49, 0x7b, 0x6a, 0x42, 0xef, 0xfb, 0xa5, 0xb5, 0x7f, 0x6b, 0x2a, 0x3a, 0x75, 0x75, 0x5a, 0x5f + 0x8d, 0x73, 0x0a, 0x07, 0xea, 0xb8, 0xfa, 0xbe, 0x91, 0x84, 0x04, 0x53, 0xd8, 0xa7, 0x2a, 0x4a, + 0xc3, 0x18, 0xe2, 0x75, 0xa9, 0xf9, 0xa1, 0xa0, 0xef, 0x83, 0x6d, 0xd4, 0xf8, 0x8e, 0xa0, 0xb5, + 0x48, 0x4a, 0x63, 0xaa, 0xd7, 0xd7, 0xbd, 0xb9, 0x8c, 0x6c, 0xc2, 0xf9, 0x3b, 0x05, 0xe0, 0xa0, + 0x90, 0x84, 0xc5, 0x60, 0x30, 0x33, 0xb2, 0x5f, 0x2f, 0x84, 0xed, 0xf8, 0xba, 0xbc, 0xb4, 0x5a, + 0x3e, 0x71, 0x3e, 0xa0, 0x2e, 0x08, 0xdf, 0x9d, 0x82, 0x18, 0xa1, 0xe9, 0xec, 0x20, 0x70, 0xb8, + 0x91, 0x7c, 0x04, 0xab, 0xf7, 0x71, 0x5a, 0xc0, 0xe1, 0x07, 0x40, 0x88, 0xea, 0xdf, 0x25, 0x2f, + 0xb2, 0x94, 0x6c, 0x2b, 0xf0, 0xfa, 0x5f, 0x5f, 0xc1, 0x10, 0xa1, 0xa0, 0x5f, 0xa4, 0x00, 0x04, + 0xad, 0x8b, 0x88, 0x83, 0x2a, 0xae, 0x2b, 0xfd, 0x43, 0x29, 0x62, 0xf3, 0x2f, 0x3a, 0x7b, 0x7b, + 0x68, 0x42, 0xe1, 0xd0, 0x40, 0xc5, 0xe0, 0x10, 0xad, 0x8b, 0x46, 0x57, 0x0d, 0xa5, 0x55, 0xd4, + 0xa2, 0x18, 0x01, 0xd1, 0x14, 0xa0, 0x7a, 0x0a, 0x4b, 0x53, 0x87, 0xe7, 0xda, 0xdf, 0xa4, 0xb0, + 0xe5, 0x39, 0x22, 0xe9, 0xda, 0x5e, 0xde, 0xda, 0x03, 0x19, 0xc5, 0xa1, 0x58, 0x08, 0xe0, 0xee, + 0x0f, 0x84, 0x21, 0x88, 0x0e, 0xae, 0xaa, 0xc0, 0x69, 0x52, 0x46, 0x65, 0xe8, 0x92, 0x08, 0xdf, + 0x4b, 0x63, 0x03, 0x99, 0xd8, 0xd0, 0xdb, 0xd3, 0x99, 0xce, 0xa6, 0xf9, 0xc2, 0xff, 0x50, 0x50, + 0xbf, 0x53, 0xfd, 0xa9, 0x4a, 0xd2, 0x02, 0xaa, 0xeb, 0x62, 0x64, 0xb9, 0xca, 0x0e, 0x41, 0x2d, + 0xb9, 0xd6, 0xa6, 0x21, 0xef, 0xb5, 0xda, 0xb5, 0x8b, 0x52, 0xa6, 0x19, 0x3a, 0x2a, 0xf8, 0xf8, + 0xb9, 0xac, 0x25, 0x42, 0xc2, 0xea, 0x27, 0xa5, 0x6b, 0xac, 0xd3, 0xc1, 0xe2, 0xea, 0x54, 0x42, + 0xc2, 0x7b, 0x9d, 0x82, 0xe1, 0xe0, 0xbd, 0xaf, 0xb0, 0x54, 0xc3, 0xc0, 0x4e, 0xd1, 0xf7, 0x4e, + 0x4c, 0x53, 0x54, 0x00, 0xb2, 0x43, 0x8d, 0x0b, 0x91, 0x84, 0x15, 0x23, 0xb5, 0xa0, 0x7f, 0xff, + 0xcc, 0x6a, 0xec, 0x22, 0x4e, 0x4a, 0x22, 0x8b, 0xb7, 0xde, 0xa2, 0xe9, 0x65, 0x30, 0x02, 0x4a, + 0xcc, 0x73, 0xc9, 0x10, 0x67, 0x46, 0xd6, 0xb8, 0xfa, 0x9b, 0x7a, 0xa5, 0xc5, 0xd7, 0x4e, 0x4e, + 0xee, 0x62, 0x62, 0xb1, 0x00, 0x5a, 0xaf, 0x52, 0xbf, 0x7a, 0x03, 0xfd, 0x3f, 0xab, 0xff, 0xfb, + 0xa0, 0x18, 0x03, 0x91, 0x4b, 0x30, 0x5d, 0xd7, 0x67, 0x5a, 0x01, 0x1a, 0x90, 0x54, 0x4a, 0x42, + 0x26, 0x4a, 0x43, 0x90, 0xa0, 0xd5, 0x5a, 0x72, 0xec, 0x52, 0xc6, 0xe0, 0x22, 0x03, 0x40, 0x00, + 0x79, 0x84, 0x9c, 0xb0, 0xb0, 0xb8, 0xba, 0xa8, 0x8c, 0x73, 0x8f, 0xb0, 0xd7, 0xaa, 0x80, 0xa2, + 0x07, 0x21, 0xc7, 0x81, 0x0a, 0x0a, 0xaf, 0xab, 0x40, 0x08, 0xe4, 0xe8, 0x35, 0xe0, 0xf2, 0xba, + 0x37, 0x5b, 0x60, 0x11, 0x28, 0x37, 0x0e, 0xa8, 0xa1, 0x39, 0x7d, 0x39, 0x5d, 0x55, 0xa0, 0xa0, + 0xff, 0xff, 0x52, 0x70, 0x97, 0xdc, 0xa1, 0x57, 0x1d, 0x41, 0xba, 0x18, 0xea, 0x94, 0x0d, 0xa5, + 0x73, 0x21, 0x30, 0x70, 0xce, 0x91, 0xa8, 0xf7, 0xb7, 0xce, 0xa8, 0x49, 0x37, 0x3f, 0x2b, 0x84, + 0x68, 0x19, 0x56, 0xd8, 0x5f, 0x20, 0x2f, 0x0b, 0x29, 0x29, 0x05, 0x7b, 0x30, 0x64, 0xfb, 0xf0, + 0x85, 0x08, 0x08, 0xd8, 0x17, 0xbf, 0x08, 0x08, 0x01, 0xf8, 0x15, 0x68, 0x37, 0xfb, 0xef, 0x27, + 0xa4, 0x52, 0x6c, 0x42, 0xe5, 0x71, 0xbe, 0xf2, 0xc4, 0x10, 0xbf, 0x90, 0x05, 0x49, 0xf2, 0xda, + 0x33, 0x7c, 0x53, 0x42, 0x8d, 0xa9, 0xa5, 0xd5, 0x7f, 0x6b, 0xa9, 0x31, 0xae, 0x10, 0x1a, 0x0d, }; void* status_ptr = nullptr; @@ -2019,7 +2022,7 @@ bool dstorage_checks() { std::vector dest_truncated(32, 0xCC); std::vector dest_bc1_valid(512, 0xEE); std::vector dest_bc1_trailing(512, 0xDD); - std::vector dest_bc6h_blank(64, 0xAA); + std::vector dest_bc6h_invalid(64, 0xAA); std::vector dest_bc4_wrong_size(8, 0x5A); std::vector dest_bc4_non_mult(7, 0x5B); std::vector dest_bc5_wrong_size(16, 0x5C); @@ -2097,11 +2100,11 @@ bool dstorage_checks() { *reinterpret_cast(req5 + 0x30) = sizeof(bc1_packed_trailing); *reinterpret_cast(req5 + 0x38) = 512; - // Request 6: BCPack format 6 (BC6H) is not decoded yet; it must be zero-filled and counted. + // Request 6: malformed BC6H must fail without publishing partial output. static const unsigned char bc6h_packed[] = {0x00, 0x01, 0x02, 0x03}; unsigned char req6[0x48] = {}; *reinterpret_cast(req6 + 0x00) = (6ull << 1) | 0x400000; - *reinterpret_cast(req6 + 0x08) = dest_bc6h_blank.data(); + *reinterpret_cast(req6 + 0x08) = dest_bc6h_invalid.data(); *reinterpret_cast(req6 + 0x10) = 0; *reinterpret_cast(req6 + 0x18) = 64; *reinterpret_cast(req6 + 0x20) = bc6h_packed; @@ -2187,9 +2190,9 @@ bool dstorage_checks() { for (unsigned char b : dest_bc1_trailing) { if (b != 0xDD) return false; } - if (hrs[6] != 0) return false; - for (unsigned char b : dest_bc6h_blank) { - if (b != 0) return false; + if (hrs[6] == 0) return false; + for (unsigned char b : dest_bc6h_invalid) { + if (b != 0xAA) return false; } if (hrs[7] == 0) return false; for (unsigned char b : dest_bc4_wrong_size) { @@ -2340,6 +2343,8 @@ bool dstorage_file_information_checks() return ok; } +#include "bcpack_storage_checks.inl" + } // namespace int main(int argc, char** argv) @@ -2347,6 +2352,7 @@ int main(int argc, char** argv) if (argc != 2) return 2; const char* which = argv[1]; if (!std::strcmp(which, "none")) return 0; + if (!std::strcmp(which, "bcpack-storage")) return bcpack_storage_checks() ? 0 : 11; if (!std::strcmp(which, "chad")) return static_cast(XDspActivate(0x11, 0x22, 0x33, 0x44)); if (!std::strcmp(which, "xg_xs")) return static_cast(XGSuggestSwizzleMode(0x55, 0, 0, 0)); if (!std::strcmp(which, "physical")) { diff --git a/tools/_bcpack_rans/THIRD_PARTY_NOTICES.md b/tools/_bcpack_rans/THIRD_PARTY_NOTICES.md index 8b16a91595..5e9550ce8a 100644 --- a/tools/_bcpack_rans/THIRD_PARTY_NOTICES.md +++ b/tools/_bcpack_rans/THIRD_PARTY_NOTICES.md @@ -34,12 +34,12 @@ SOFTWARE ## Ahmet Dedeler bcpack-rs -`src/startup_stubs/bcpack_tables.h` and `src/startup_stubs/bcpack_tables_bcn.inl` contain BC1, BC3, BC4, BC5, and BC7 -codebook, rank, window, and dictionary tables (`BC7_CONTROL_TABLE`, `BC7_DICTIONARY`, `BC1_WINDOW`, `BC1_QUAD_MASKS`, +`src/startup_stubs/bcpack_tables.h` and `src/startup_stubs/bcpack_tables_bcn.inl` contain BC3, BC4, BC5, and BC7 +codebook, rank, and dictionary tables (`BC7_CONTROL_TABLE`, `BC7_DICTIONARY`, `RANK_PAIR_BC4`, `BC4_DICTIONARY`, `RANK_PAIR_BC5`, `BC5_DICTIONARY`, `RANK_PAIR_BC3_ALPHA`, `RANK_QUAD_BC3_COLOUR`, `BC3_DICTIONARY`) adapted from https://github.com/Ahmet-Dedeler/bcpack-rs (pinned revision c55c5fad539644b8cf5a705051df214291763fc0). -The BC1, BC3, BC4, BC5, and BC7 block reconstruction routines in `src/startup_stubs/bcpack_decoder.h` are adapted from +The BC3, BC4, BC5, and BC7 block reconstruction routines in `src/startup_stubs/bcpack_decoder.h` are adapted from the same repository. Used under the MIT License: ``` @@ -65,3 +65,35 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ``` + +## Microsoft DirectXTex + +The `BC6_WIRE` descriptors in `src/startup_stubs/bcpack_tables_extra.inl` adapt +the BC6H bit layout in `DirectXTex/BC6HBC7.cpp` at revision +[`a8e5dbf42909aeeb9fcf9c2ae399ae3c06737379`](https://github.com/microsoft/DirectXTex/tree/a8e5dbf42909aeeb9fcf9c2ae399ae3c06737379). +The BCPack-specific bit ordering is described in +[the implementation notes](../../docs/experiments/bcpack-standalone.md). + +```text +MIT License + + Copyright (c) Microsoft Corporation. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE +``` diff --git a/tools/bcpack_recover_constants.py b/tools/bcpack_recover_constants.py new file mode 100644 index 0000000000..3fab7e05f2 --- /dev/null +++ b/tools/bcpack_recover_constants.py @@ -0,0 +1,228 @@ +"""Reproduce BCPack format constants with chosen synthetic lane streams. + +SPDX-License-Identifier: MIT + +The GDK is a development oracle only. No DLL bytes or memory tables are read here. +BC6H wire bit descriptors are parsed from the public MIT DirectXTex source. +""" +import ctypes as c +import json +import argparse +import hashlib +from pathlib import Path +import re + +parser = argparse.ArgumentParser(description=__doc__) +parser.add_argument("--sdk", type=Path, required=True, help="Installed BCPack.dll, development oracle only") +parser.add_argument("--bridge", type=Path, required=True, help="Source-built bcpack_oracle_bridge.dll") +parser.add_argument("--bc6-reference", type=Path, required=True, help="Pinned public DirectXTex BC6HBC7.cpp") +parser.add_argument("--output", type=Path, required=True, help="Generated .inl (normally under out/)") +parser.add_argument("--storage-goldens", type=Path, help="Also regenerate the source-built storage fixture's expected blocks") +args = parser.parse_args() +sdk = c.CDLL(str(args.sdk.resolve())) +dec = sdk.BCPackDecompress +dec.argtypes = [c.c_size_t, c.c_void_p, c.c_size_t, c.c_void_p, c.c_size_t] +dec.restype = c.c_int32 +encoder = c.CDLL(str(args.bridge.resolve())) +enc = encoder.encode_symbols +enc.argtypes = [c.c_uint, c.POINTER(c.c_uint16), c.c_size_t, c.c_void_p, c.c_size_t] +enc.restype = c.c_size_t +N = {1:12, 2:15, 3:12, 4:12, 5:12, 6:16, 7:16} +PER = {b:1 if b in (1,4) else 2 for b in N} +LINE = [0, 3, 1, 2] +BC6_BITS = [[0]*4,[10,5,5,5],[7,6,6,6],[11,5,4,4],[11,4,5,4], + [11,4,4,5],[9,5,5,5],[8,6,5,5],[8,5,6,5],[8,5,5,6], + [6,6,6,6],[10,10,10,10],[11,9,9,9],[12,8,8,8],[16,4,4,4]] + + +def wire_descriptors(): + source = args.bc6_reference.read_bytes() + if hashlib.sha256(source).hexdigest() != "187434fab12351df0f875ae09390981034e8479159a6f4aaaf0904f007182b8a": + raise ValueError("DirectXTex reference does not match pinned a8e5dbf42909aeeb9fcf9c2ae399ae3c06737379") + text = source.decode("utf-8-sig") + text = text.split('const D3DX_BC6H::ModeDescriptor D3DX_BC6H::ms_aDesc',1)[1] + text = text.split('// Mode, Partitions, Transformed, IndexPrec',1)[0] + desc = [[]] + for mode, body in re.findall(r'\{\s*// Mode (\d+)[^\n]*\n(.*?)\n\s*\},',text,re.S): + mode = int(mode) + pairs = [(f,int(b)) for f,b in re.findall(r'\{\s*(\w+),\s*(\d+)\s*\}',body)] + assert len(pairs) == 82 and mode == len(desc) + # BCPack's packer writes the high base bits ascending in modes 13/14. + if mode in (13,14): + for f in ['RW','GW','BW']: + positions = [i for i,(field,bit) in enumerate(pairs) if field == f and bit >= 10] + for i,b in zip(positions,sorted(pairs[i][1] for i in positions)): + pairs[i] = (f,b) + desc.append(pairs[:82 if mode <= 10 else 65]) + assert len(desc) == 15 + return desc + + +DESC = wire_descriptors() + + +def interleave(a,b): + return sum(((a>>k&1)<<(2*k)) | ((b>>k&1)<<(2*k+1)) for k in range(4)) + + +def split(v): + return [sum((v>>(2*k+j)&1)<= 0 else -2*delta-1 + s[:per] = split(zz) if per == 2 else [zz] + s[per:2*per] = split(ix) if per == 2 else [ix] + if fmt == 1: + s[8:] = [rank]*4 + elif fmt == 2: + s[26:] = [rank]*4 + elif fmt == 6: + s[30] = mode-1 + v = (c.c_uint16*len(s))(*s) + packed = c.create_string_buffer(65536) + n = enc(fmt,v,per,packed,len(packed)) + assert n, (fmt,ep,ix,mode,rank,'encode') + size = 8*per + out = c.create_string_buffer(b'\xa5'*(size+32),size+32) + hr = dec(fmt,c.addressof(out)+16,size,packed,n) + assert hr >= 0, (fmt,ep,ix,mode,rank,hex(hr&0xffffffff)) + assert out.raw[:16] == b'\xa5'*16 and out.raw[-16:] == b'\xa5'*16 + return out.raw[16:-16] + + +def colour(raw): + a,b = int.from_bytes(raw[:2],'little'),int.from_bytes(raw[2:4],'little') + ep = [a>>11,a>>5&63,a&31,b>>11,b>>5&63,b&31] + word = int.from_bytes(raw[4:8],'little') + ix = [LINE[word>>(2*p)&3] for p in range(16)] + return ep,ix + + +def unpack6(raw,mode): + word = int.from_bytes(raw,'little') + fields = {f:0 for f in ['RW','RX','RY','RZ','GW','GX','GY','GZ','BW','BX','BY','BZ']} + for i,(f,bit) in enumerate(DESC[mode]): + if f in fields: fields[f] |= ((word>>i)&1)< 10 and k > 1: continue + for channel,ch in enumerate('RGB'): + bits = BC6_BITS[mode][0 if k == 0 else channel+1] + ep[k][channel] = (fields[ch+e] << (16-bits)) ^ 0x8000 + at = 82 if mode <= 10 else 65 + bits = 3 if mode <= 10 else 4 + ix = [] + for p in range(16): + width = bits - int(p == 0 or mode <= 10 and p == 15) + value = (word>>at)&((1< decoder API -> public BC block fields; no SDK binary-table extraction', + 'bc6_wire':DESC, 'bc6_bits':BC6_BITS} + for fmt in (1,2): + ranks=[] + for rank in range(256): + _, ix = colour(query(fmt,rank=rank)[0 if fmt == 1 else 8:]) + ranks.append([ix[p] for p in (0,1,4,5)]) + zero = ranks.index([0]*4) + rows=[] + for r in range(1,256): + raw = query(fmt,ep=r,ix=r,rank=zero) + ep,ix=colour(raw[0 if fmt == 1 else 8:]) + row={'ep':ep,'ix':ix} + if fmt == 2: + a=int.from_bytes(raw[:8],'little') + row['alpha']=[((a>>(4*p))&15)^8 for p in range(16)] + rows.append(row) + tables[f'bc{fmt}_ranks']=ranks + tables[f'bc{fmt}_dictionary']=rows + print(f'BC{fmt}: {len(ranks)} quadrant ranks and {len(rows)} predictor entries recovered',flush=True) + rows=[] + for r in range(1,256): + a,_=unpack6(query(6,ep=r,mode=14),14) + b,_=unpack6(query(6,ep=r,mode=11),11) + c,_=unpack6(query(6,ep=r,mode=2),2) + _,ix=unpack6(query(6,ix=r,mode=11),11) + rows.append({'ep':[a[0],b[1],c[2],c[3]],'ix':ix}) + tables['bc6_dictionary']=rows + write_tables(tables, args.output) + if args.storage_goldens: + storage_goldens(args.storage_goldens) + print(f'BC6H: {len(rows)} predictor entries recovered',flush=True) + + +def initializer(values): + return '{ ' + ', '.join(initializer(v) if isinstance(v,list) else str(v) for v in values) + ' }' + + +def storage_goldens(out): + build = encoder.storage_symbols + build.argtypes = [c.c_uint, c.POINTER(c.c_uint16), c.c_size_t] + build.restype = c.c_size_t + lines = ["// GDK 1.2603.3.0 golden BC blocks from random_symbols(fmt,4,0x7700+fmt).", + "// Entirely synthetic input, no SDK or title bytes. SPDX-License-Identifier: MIT", "#pragma once"] + for fmt in (2, 6): + symbols = (c.c_uint16 * 128)() + assert build(fmt, symbols, 128) + packed = c.create_string_buffer(65536) + size = enc(fmt, symbols, 8, packed, len(packed)) + assert size + output = c.create_string_buffer(64) + assert dec(fmt, output, 64, packed, size) >= 0 + lines.append(f"inline constexpr unsigned char BC{fmt}_STORAGE_EXPECTED[64] = {{") + for at in range(0, 64, 16): + lines.append(" " + ", ".join(f"0x{v:02x}" for v in output.raw[at:at+16]) + ",") + lines.append("};") + out.write_text("\n".join(lines) + "\n", encoding="utf-8", newline="\n") + + +def write_tables(t, out): + lines=['// BCPack format constants reconstructed with synthetic lane streams.', + '// No SDK binaries or title data are embedded. See docs/experiments/bcpack-standalone.md.', + '// BC6H wire descriptors adapt the MIT-licensed Microsoft DirectXTex BC6HBC7.cpp.', + '// Copyright (c) Microsoft Corporation. All rights reserved.', + '// SPDX-License-Identifier: MIT', '', + 'struct Bc1FullState { uint8_t ep[6]; uint8_t ix[16]; };', + 'struct Bc2State { uint8_t alpha[16]; uint8_t ep[6]; uint8_t ix[16]; };', + 'struct Bc6State { uint16_t ep[4][3]; uint16_t ix[16]; };', + 'struct Bc6WireBit { uint8_t field; uint8_t bit; };',''] + for fmt in (1,2): + lines.append(f'inline constexpr uint8_t BC{fmt}_POSITION_RANK[256][4] = {{') + lines.extend(' '+initializer(row)+',' for row in t[f'bc{fmt}_ranks']) + lines.extend(['};','']) + typ='Bc1FullState' if fmt==1 else 'Bc2State' + lines.append(f'inline constexpr {typ} BC{fmt}_FULL_DICTIONARY[255] = {{') + fields=['ep','ix'] if fmt==1 else ['alpha','ep','ix'] + lines.extend(' '+initializer([row[f] for f in fields])+',' for row in t[f'bc{fmt}_dictionary']) + lines.extend(['};','']) + lines.append('inline constexpr Bc6State BC6_DICTIONARY[255] = {') + lines.extend(' '+initializer([row['ep'],row['ix']])+',' for row in t['bc6_dictionary']) + lines.extend(['};','','inline constexpr uint8_t BC6_ENDPOINT_BITS[15][4] = {']) + lines.extend(' '+initializer(row)+',' for row in t['bc6_bits']) + lines.extend(['};','','// 0 = mode bit, 1 = partition bit; 2 + 3 * endpoint + channel = endpoint bit.', + 'inline constexpr Bc6WireBit BC6_WIRE[14][82] = {']) + for mode,row in enumerate(t['bc6_wire'][1:],1): + vals=[] + for f,b in row: + field = 0 if f in ('M','NA') else 1 if f=='D' else 2+3*'WXYZ'.index(f[1])+'RGB'.index(f[0]) + vals.append([field,b]) + lines.append(' { // Mode '+str(mode)) + for pos in range(0,len(vals),10): + lines.append(' '+', '.join(initializer(v) for v in vals[pos:pos+10])+',') + lines.append(' },') + lines.extend(['};','']) + out.write_text('\n'.join(lines),encoding='utf-8',newline='\n') + print(out, out.stat().st_size) + + +if __name__ == "__main__": + main()