A Pair class for handling queries in JAVA As , there is no in - built function of Tuple
static class Pair { int item1 , item2 ; Pair ( int item1 , int item2 ) { this . item1 = item1 ; this . item2 = item2 ; } }