Java implementation of the approach
import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static class pair { int first ; String second ; pair ( int first , String second ) { this . first = first ; this . second = second ; } }