C # program of the above approach
using System ; using System . Collections . Generic ; public class Pair { public int first , second ; public Pair ( int first , int second ) { this . first = first ; this . second = second ; } } public class GFG {