We know that this is solved recursively, which means that each node can be solved (for x or x+n as VQC says) with the solution of the previous two nodes. For 145, the correct X value we want is 7. The nodes for this are 12 and 1. We know that for 1, the X value must be 0, because d=1, a=1, x=d-a. 12 is even, so we chop 12 down until it is 3. Then for 3 we have factors a={1,3}, d=1, so x={0,-2}. So somehow from these two sets:
{0,-2} and {0}
we need to get this: {7,-22}
We may be able to do a function on {0,-2} twice because of the 'chopping' of 12.