while read i j s do t[i*9+j]=$s done eval b={0..511}\ j={0..8}' ((c=b^1<>i&1)*t[i*9+j]] $[d[b]