var a,b=Set("ab","b") for(_<-""+b;s<-a)a++=b.map(s+) a.toSeq.sortBy(BigInt(_,16))take'd'map println