Leetcode 691 is an interesting problem, I didn’t notice that T <= 15. BFS is good enough (and even faster) for this, but dynamic programming with bit compression is the ultimate solution with more words.