You are a participant in a controlled experiment. You will write the weights of a small neural network directly, by reasoning and arithmetic. There is no training step and you will never see the data. The network is then executed by an independent judge on a sealed test set that you will not see. You are not told the score.

Your working folder is:
{FOLDER}
It is your only workspace. Use absolute paths. It already contains check_spec.py (a validator) and dev_eval.py (the evaluation tool described below).

## Task
Decide whether a 12-digit string is valid under the Verhoeff check-digit scheme. All strings are random synthetic digits.

The scheme. Digits s[0] ... s[11], left to right; s[11] is the check digit. Using the tables below:
    c = 0
    for i in range(12):
        c = D[c][P[i % 8][s[11 - i]]]
    the string is valid if and only if c == 0

D = np.array([
 [0,1,2,3,4,5,6,7,8,9],[1,2,3,4,0,6,7,8,9,5],[2,3,4,0,1,7,8,9,5,6],[3,4,0,1,2,8,9,5,6,7],
 [4,0,1,2,3,9,5,6,7,8],[5,9,8,7,6,0,4,3,2,1],[6,5,9,8,7,1,0,4,3,2],[7,6,5,9,8,2,1,0,4,3],
 [8,7,6,5,9,3,2,1,0,4],[9,8,7,6,5,4,3,2,1,0]])
P = np.array([
 [0,1,2,3,4,5,6,7,8,9],[1,5,7,6,2,8,3,0,9,4],[5,8,0,3,7,9,6,1,4,2],[8,9,1,6,0,4,3,5,2,7],
 [9,4,5,3,1,2,6,8,7,0],[4,2,8,6,5,7,3,9,0,1],[2,7,9,3,8,0,6,4,1,5],[7,0,4,6,9,1,3,2,5,8]])

Input tensor: shape (120,), float32. One-hot digits: x[10*i + s[i]] = 1 for i in 0..11, all other entries 0. Position i=0 is the leftmost digit.
Output: 2 logits. The prediction is argmax; index 1 means valid, index 0 means invalid.
Test distribution: 50% uniformly random valid strings; 50% invalid strings, an equal mix of three kinds: a valid string with one digit changed, a valid string with two unequal adjacent digits swapped, and a uniformly random string conditioned on being invalid.
Metric: accuracy on the sealed test set. You are given the rule in full, so the task is to express it in weights.

## Architecture language
The network is a sequential model or a simple DAG of standard layers, described in spec.json. No custom code, no lookup outside the weights, no conditionals.

spec.json format:
{"input_shape": [120], "output": "<name of the last layer>", "layers": [ <layer>, <layer>, ... ]}

Layers are listed in topological order. Each layer has a unique "name" and reads from "input" (the name of an earlier layer, or the literal "input" for the network input). Inputs have a batch dimension that the spec does not mention. The allowed layers are these, with PyTorch semantics exactly:
- {"name":..., "op":"Conv2d", "input":..., "in_channels":C, "out_channels":C2, "kernel_size":k, "stride":1, "padding":0, "bias":true}  (square kernels, integers; stride, padding and bias are optional with these defaults)
- {"name":..., "op":"Linear", "input":..., "in_features":n, "out_features":m, "bias":true}
- {"name":..., "op":"ReLU", "input":...}
- {"name":..., "op":"MaxPool2d", "input":..., "kernel_size":k, "stride":k, "padding":0}  (stride defaults to kernel_size)
- {"name":..., "op":"AvgPool2d", "input":..., "kernel_size":k, "stride":k, "padding":0}
- {"name":..., "op":"Flatten", "input":...}  (flattens everything after the batch dimension, in C order)
- {"name":..., "op":"Concat", "inputs":[name1, name2, ...]}  (concatenates along channel dimension for 4-d tensors, feature dimension for 2-d tensors; 2 or more inputs)

weights.npz holds one array per parameter: "<layer name>.weight" and, when bias is true, "<layer name>.bias". Shapes follow PyTorch: Conv2d weight (out_channels, in_channels, k, k), bias (out_channels); Linear weight (out_features, in_features), bias (out_features). No other keys. Values must be finite. They are loaded as float32.

Parameter cap for this task: 1,000,000. The count is the total number of entries in weights.npz, zeros included.
A network whose files do not validate, or do not execute, is scored at chance. That is recorded, not dropped.

## Rules (a run that breaks one is thrown out and replaced)
1. Stay inside your folder. Do not read, list or search anything outside it. Do not look at the Python install, the home directory or any other project. Do not check whether any dataset is cached on this machine.
2. No dataset of any kind. Do not read, download or import any data. Do not import torchvision, torch, sklearn, tensorflow, datasets, scipy, PIL or similar. Do not use the internet. Tools: use only Bash, Read, Write and Edit. Do not use WebSearch, WebFetch, ToolSearch, Skill or Agent, and do not start other agents. Do not load any skill; NOTES.md is a technical log, not reader-facing prose.
3. Nothing is trained or fitted. No gradient steps, no perceptron or iterative updates, no least squares, pinv or other matrix solves to fit targets, on any data, real or synthetic. Weights must come from your own reasoning: explicit numbers, formulas, or closed-form computation from things you write from memory yourself (for example, a stroke template you rasterise, or counts over word lists you recall).
4. Ten evaluation passes, and no others. `python3 {FOLDER}/dev_eval.py` sends your current spec.json and weights.npz to a judge, which runs them on a development split that is disjoint from the test set and returns only the aggregate accuracy and the confusion matrix. You never see items. You have a budget of exactly 10 calls, enforced by the judge, and a call with a broken network still spends one. You may use the feedback to revise your reasoning and your weights, not to run an automated search: every revision must be one you reasoned about (no scripted loops around dev_eval.py, no random search). Apart from those 10 calls, you may not execute the network, or any part of it, in any form (numpy, by hand in code, or otherwise) on any input, real or invented. Do not write a simulator of your network. Running check_spec.py is allowed; it only checks shapes and counts.

## What you must leave in your folder
- build_weights.py: when run as `python3 build_weights.py` with no arguments, it writes weights.npz and spec.json next to itself (use the folder of __file__). It imports only numpy and these standard library modules: json, math, os, sys, itertools, collections, functools, unicodedata, struct, re, string, pathlib, typing, dataclasses. It reads no other file; everything it needs is inside the script. It finishes in under 120 seconds. It must be deterministic: a judge reruns it under a sandbox with no network and no file access outside the folder and compares the output bytes. If the rerun does not reproduce your weights, the network is scored at chance. Use np.savez (not savez_compressed); seed any randomness; do not embed dates.
- weights.npz and spec.json, produced by running that script.
- NOTES.md: your reasoning, and one line accounting for each block of weights (what that block does and where its numbers came from).

Run `python3 {FOLDER}/check_spec.py verhoeff {FOLDER}` at the end and make it print OK.

Aim to finish in about 35 minutes. Your reply when finished must be one line: DONE, or FAILED and why. Do not include anything else in the reply.
