import java.util.*;
class Solution {
public int[] solution(String[] id_list, String[] report, int k) {
int[] answer = new int[id_list.length];
int[][] table = new int[id_list.length][id_list.length];
int[] sum = new int[id_list.length];
Set<String> set = new HashSet<>();
Map<String, Integer> map = new HashMap<>();
for(int i=0; i<id_list.length; i++) { map.put(id_list[i], i); }
for(String r : report) { set.add(r); }
Iterator<String> iterator = set.iterator();
while(iterator.hasNext()) {
String[] arr = iterator.next().split(" ");
table[map.get(arr[0])][map.get(arr[1])]++;
}
for(int i=0; i<id_list.length; i++) {
for(int j=0; j<id_list.length; j++) { sum[i] += table[j][i]; }
}
for(int i=0; i<id_list.length; i++) {
for(int j=0; j<id_list.length; j++) {
if(sum[j]>=k && table[i][j]==1) { answer[i]++; }
}
}
return answer;
}
}