import java.util.*;
import java.util.Scanner;
import java.util.Arrays;
public class Main{
public static void main
(string[] args
){
Scanner sc=
new Scanner
(system.
in);
Footwear[] ar=new Footwear[5];
for(int i=0;i<5;i++){
int a=sc.nextInt();
sc.nextLine();
int d=sc.nextInt();
sc.nextLine();
ar[i]=new Footwear(a,b,c,d);
}
string new_type=sc.
nextLine();
string new_name=sc.
nextLine();
int output=count(ar,new_type);
if(output>0)
else
system.
out.
println("Footwear not available");
Footwear obj=second(ar,new_name);
if(obj!=null){
system.
out.
println(obj.
price);
}
else
system.
out.
println("Brand not available");
}
public static int count
(Footwear
[] ar1,
string new_type
){
int c=0;
for(int i=0;i<5;i++){
if(ar1[i].type.equalsIgnoreCase(new_type)){
c++;
}
}
return c;
}
public static Footwear second
(Footwear
[] ar1,
string new_name
){
Footwear[] help=new Footwear[0];
for(int i=0;i<5;i++){
if(ar1[i].name.equalsIgnoreCase(new_name)){
help=
arrays.
copyOf(help,help.
length+1);
help[help.length-1]=ar1[i];
}
}
if(help.length>0){
for(int i=0;i<help.length-1;i++){
for(int j=0;j<help.length-1;j++){
if(help[j].price<help[j+1].price){
Footwear temp=help[j+1];
help[j+1]=help[j];
help[j]=temp;
}
}
}
if(help.length>1)
return help[1];
else
return help[0];
}
return null;
}
}
class Footwear{
int id;
int price;
this.id=id;
this.name=name;
this.type=type;
this.price=price;
}
}