#include <bits/stdc++.h>
using namespace std;
int n;
map<string, int> record;
struct player {
  string ratings;
  string name;
  int scr;
  void getratings(int bnum) {
    if (bnum * 2 > n) {
      ratings = "noob";
      return;
    }
    if (bnum * 5 > n) {
      ratings = "random";
      return;
    }
    if (bnum * 10 > n) {
      ratings = "average";
      return;
    }
    if (bnum * 100 > n) {
      ratings = "hardcore";
      return;
    }
    ratings = "pro";
  }
};
vector<player> ans;
bool cmpscr(player a, player b) { return a.scr > b.scr; }
bool cmpname(player a, player b) { return a.name < b.name; }
int main() {
  cin >> n;
  string name;
  for (int i = 0; i < n; i++) {
    int scr;
    cin >> name >> scr;
    record[name] = max(record[name], scr);
  }
  int pln = record.size();
  ans.resize(pln);
  map<string, int>::iterator i;
  int cnt = 0;
  for (i = record.begin(); i != record.end(); i++) {
    ans[cnt].name = i->first;
    ans[cnt].scr = i->second;
    cnt++;
  }
  sort(ans.begin(), ans.end(), cmpscr);
  int bnum = 0;
  n = pln;
  for (int i = 0; i < cnt; i++) {
    if (i > 0 && ans[i].scr != ans[i - 1].scr) bnum = i;
    ans[i].getratings(bnum);
  }
  sort(ans.begin(), ans.end(), cmpname);
  cout << cnt << endl;
  for (int i = 0; i < cnt; i++)
    cout << ans[i].name << " " << ans[i].ratings << endl;
  return 0;
}
