Pair class implementation to use Pair
static class Pair { private int first ; private int second ; Pair ( int first , int second ) { this . first = first ; this . second = second ; } public int getFirst ( ) { return first ; } public int getSecond ( ) { return second ; } }