Java program for the above approach
import java . util . * ; public class Main { public static class Pair { int Item1 , Item2 ; public Pair ( int Item1 , int Item2 ) { this . Item1 = Item1 ; this . Item2 = Item2 ; } }