Coding challenge

Neel has moved to Hyderabad recently and is on a search for a place to stay. He wants to stay in a flat with the flat number having 7s and 4s only and with the equal number of both the digits. He also wants the flat number to be as small as possible. He’s given apartment names and the corresponding flat numbers. Help him with the best option possible by printing the Apartment name. If there’s no flat available meeting his requirement print -1.

Input Format

  • The first line is an integer N denoting the number of flats
  • The next N lines contain the apartment names(a) and the corresponding flat numbers(f)

Constraints

  • 1 <= N <= 10^5
  • 1 <= |a| <= 10
  • 1 <= |f| <= 10^9

Output Format

  • Print the apartment name of the best option available to Neel.
  • If the criteria doesn’t satisy, print -1.

Sample Input 0

5 PalashNivas 474744477 PaarijatNivas 747774 SurajNivas 744 ChampaNivas 448477 KamalNivas 74

Sample Output 0

KamalNivas