#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;

int main(int argc, char **argv)
{
  int *array, *array2, *array3, s, t, l = 0;

  array = (int *)calloc(100, sizeof(int));
  array2 = (int *)calloc(100, sizeof(int));

  while(1){
    scanf("%d,%d", &s, &t);
    if(s == 0 || t == 0){
      break;
    }
    array[s] = t;
    if(array2[t] != t){
      array2[t] = t;
      l++;
    }
  }

  sort(array2, array2+100);
  array3 = (int *)calloc(l, sizeof(int));
  for(int i = 0; i < l; i++){
    array3[i] = array2[99-i];
  }
  free(array2);
  sort(array3, array3+l);

  while(scanf("%d", &s) != EOF){
    for(int i = 0; i < l; i++){
      if(array[s] == array3[i]){
	printf("-- %d\n", (l-i));
	break;
      }
    }
  }
  free(array);
  free(array3);

  return 0;
}