#!perl $_= ++$ / x11 . <>; map { $i = $-[0]; { map { 1 while s/w((?<=W.{10})|(?<=W.)|(?=.{9}W|W))/W/s; /W((?<= .{10})|(?<= .)|(?=.{9} | ))/s || $i=~/./ + print("$& $'\n") + last } "$`W$'" while/w/g } } "$`x$'" while/ /g