#include <bits/stdc++.h>
using namespace std;
int n;
map<string, int> player;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios::fixed);
  cout.precision(20);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    int p;
    cin >> s >> p;
    if (player.count(s)) {
      if (p > player[s]) player[s] = p;
    } else
      player[s] = p;
  }
  map<int, int> score;
  for (auto it = player.begin(); it != player.end(); ++it) ++score[it->second];
  map<int, string> rk;
  int now_num = 0;
  int total_num = player.size();
  for (auto it = score.begin(); it != score.end(); ++it) {
    int point = it->first;
    int tmp_num = it->second;
    now_num += tmp_num;
    if (now_num * 2 < total_num)
      rk[point] = "noob";
    else if (now_num * 2 >= total_num and now_num * 5 < total_num * 4)
      rk[point] = "random";
    else if (now_num * 5 >= total_num * 4 and now_num * 10 < total_num * 9)
      rk[point] = "average";
    else if (now_num * 10 >= total_num * 9 and now_num * 100 < total_num * 99)
      rk[point] = "hardcore";
    else
      rk[point] = "pro";
  }
  cout << total_num << '\n';
  for (auto it = player.begin(); it != player.end(); ++it)
    cout << it->first << ' ' << rk[it->second] << '\n';
}
