Вроде все выводит как надо, или я что то не понял из условия?
package com.javarush.task.task08.task0829;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
/*
Модернизация ПО
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
Map<String,String> map = new HashMap();
while (true){
String family = reader.readLine();
String city = reader.readLine();
if (family.isEmpty()) {
break;
}
map.put(city,family);
}
String city = reader.readLine();
System.out.println(map.get(city));
}
}