Java program to find the shortest pairwise distance between any two different good nodes .
import java . util . ArrayList ; import java . util . Comparator ; import java . util . PriorityQueue ; class GFG { static class Pair { int first , second ; public Pair ( int first , int second ) { this . first = first ; this . second = second ; } public Pair ( ) { } } static final int N = 100005 ; static final int MAXI = 99999999 ;