Added working R-way trie implementation; slower, but easier to implement final solution.