#include <bits/stdc++.h>
using namespace std;
struct node {
  char name[20];
  int score;
} a[1500];
int ct;
char ss[20][20] = {"noob", "random", "average", "hardcore", "pro"};
int main() {
  int n, i, j, t;
  char s[20];
  while (scanf("%d", &n) != EOF) {
    ct = 0;
    for (i = 0; i < n; i++) a[i].score = 0;
    for (i = 0; i < n; i++) {
      scanf("%s%d", s, &t);
      for (j = 0; j < ct; j++)
        if (strcmp(a[j].name, s) == 0) break;
      strcpy(a[j].name, s);
      a[j].score = max(a[j].score, t);
      if (j == ct) ct++;
    }
    printf("%d\n", ct);
    for (i = 0; i < ct; i++) {
      int x = 0, y = 0;
      for (j = 0; j < ct; j++) {
        if (a[j].score <= a[i].score) x++;
        if (a[j].score > a[i].score) y++;
      }
      int tt;
      if (y > (int)(0.5 * ct))
        tt = 0;
      else if (x >= (int)(0.5 * ct) && y > (int)(0.2 * ct))
        tt = 1;
      else if (x >= (int)(0.8 * ct) && y > (int)(0.1 * ct))
        tt = 2;
      else if (x >= (int)(0.9 * ct) && y > (int)(0.01 * ct))
        tt = 3;
      else if (x >= (int)(0.99 * ct))
        tt = 4;
      printf("%s %s\n", a[i].name, ss[tt]);
    }
  }
  return 0;
}
