#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  char s[2000][40];
  char s1[40];
  int a[2000], a1, count = 0;
  ;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    cin >> s1 >> a1;
    bool b = false;
    for (int j = 0; j < count; j++)
      if (strcmp(s[j], s1) == 0) {
        b = true;
        if (a1 > a[j]) a[j] = a1;
        break;
      }
    if (b == false) {
      strcpy(s[count], s1);
      a[count++] = a1;
    }
  }
  int less[2000];
  for (int i = 0; i < count; i++) less[i] = 1;
  for (int i = 0; i < count - 1; i++)
    for (int j = i + 1; j < count; j++)
      if (a[i] > a[j])
        less[i]++;
      else if (a[i] != a[j])
        less[j]++;
      else {
        less[j]++;
        less[i]++;
      }
  printf("%d\n", count);
  for (int i = 0; i < count; i++) {
    printf("%s ", s[i]);
    if (less[i] < count / 2 + count % 2)
      printf("noob\n");
    else if (less[i] < (count * 4 / 5) + ((4 * count % 5) ? 1 : 0))
      printf("random\n");
    else if (less[i] < (9 * count / 10) + ((9 * count % 10) ? 1 : 0))
      printf("average\n");
    else if (less[i] < (99 * count / 100) + ((99 * count % 100) ? 1 : 0))
      printf("hardcore\n");
    else
      printf("pro\n");
  }
  return 0;
}
