/ depth first dshape:{:[~t:4:x;(#x),{(+/&\=/((#x)&#y)#'(x;y))#x}/_f'x;0>t;#x;!0]} / breadth first bshape:{s:!0;i:0;while[(i=#s)&~|/,//{x'}/[i;@:]x;if[1=#c:?(),i,//{x'}/[i;#:]x;s,:c];i+:1];s}