f={it*.grep{1}.transpose()};(f(f(t="$System.in".split())*.sum{it-'|'}*.padLeft(t.size()-1,'|'))*.sum()+t[0]).any 0.&println