Initialize first value of each variable of Pair type is INT_MIN
Pair x = new Pair ( ) ; Pair y = new Pair ( ) ; Pair z = new Pair ( ) ; x . first = y . first = z . first = Integer . MIN_VALUE ; for ( Map . Entry curr : freq . entrySet ( ) ) {