This pair is used to store the X and Y coordinate of a point respectively
static class Pair { int first , second ; public Pair ( int first , int second ) { this . first = first ; this . second = second ; } }