#include <bits/stdc++.h>
using namespace std;
struct Player {
  string name;
  int points;
  string cat;
  Player(int _v = 0) : points(10000000) {}
};
bool cmp(const Player &p1, const Player &p2) { return p1.points < p2.points; }
int main() {
  int n;
  cin >> n;
  unordered_map<string, int> mp;
  string name;
  int points;
  for (int i = 0; i < n; ++i) {
    cin >> name >> points;
    mp[name] = max(mp[name], points);
  }
  vector<Player> players(n + 5);
  int numOfPlayers = 0;
  for (auto iter : mp) {
    players[numOfPlayers].name = iter.first;
    players[numOfPlayers].points = iter.second;
    numOfPlayers++;
  }
  sort(players.begin(), players.end(), cmp);
  for (int i = 0; i < numOfPlayers; ++i) {
    auto iter = upper_bound(players.begin(), players.end(), players[i], cmp);
    int num_worse = (int)(iter - players.begin());
    if (num_worse * 100 >= numOfPlayers * 99)
      players[i].cat = "pro";
    else if (num_worse * 100 >= numOfPlayers * 90)
      players[i].cat = "hardcore";
    else if (num_worse * 100 >= numOfPlayers * 80)
      players[i].cat = "average";
    else if (num_worse * 100 >= numOfPlayers * 50)
      players[i].cat = "random";
    else
      players[i].cat = "noob";
  }
  cout << numOfPlayers << endl;
  for (int i = 0; i < numOfPlayers; ++i)
    cout << players[i].name << " " << players[i].cat << endl;
}
