Use Fenwick tree for powers, still too slow