Changed code to use Triplet<Integer, Integer, Integer> instead of Pair<Integer, Pair<Integer, Integer>>