#include <bits/stdc++.h>
using namespace std;
inline int max(int a, int b) { return a > b ? a : b; }
string cat[5] = {"noob", "random", "average", "hardcore", "pro"};
struct Player {
  string name;
  int score;
  int cas;
};
Player p[1003];
int m;
void update(string name, int score) {
  for (int i = 0; i < m; i++) {
    if (p[i].name == name) {
      p[i].score = max(p[i].score, score);
      return;
    }
  }
  p[m].name = name;
  p[m].score = score;
  m++;
}
void judge(int k) {}
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    m = 0;
    char name[15];
    int score;
    while (n--) {
      scanf("%s %d", name, &score);
      update(string(name), score);
    }
    printf("%d\n", m);
    for (int i = 0; i < m; i++) {
      int c1 = 0;
      int c2 = 0;
      for (int j = 0; j < m; j++) {
        if (p[j].score > p[i].score) {
          c1++;
        }
        if (p[j].score >= p[i].score) {
          c2++;
        }
      }
      double d1 = 1.0 * c1 / m;
      double d2 = 1.0 * c2 / m;
      if (d1 > 0.5) {
        p[i].cas = 0;
      } else if (d1 > 0.2) {
        p[i].cas = 1;
      } else if (d1 > 0.1) {
        p[i].cas = 2;
      } else if (d1 > 0.01) {
        p[i].cas = 3;
      } else {
        p[i].cas = 4;
      }
    }
    for (int i = 0; i < m; i++) {
      printf("%s %s\n", p[i].name.c_str(), cat[p[i].cas].c_str());
    }
  }
  return 0;
}
