f(){ x=$1 $2||{ echo ? $1 $2 read z a[z]+=\ $[x^$2^z] f ${*:3} $z } } read n eval f {1..$n} f${a[x]} echo ! $x