#include <bits/stdc++.h>
using namespace std;
const static int inf = 10000000;
const static int mod = 1000000007;
bool comp(pair<string, int> a, pair<string, int> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  }
  return a.first < b.first;
}
int main() {
  int n;
  while (cin >> n) {
    map<string, int> table_map;
    for (int i = 0; i < (int)(n); i++) {
      string name;
      int p;
      cin >> name >> p;
      int cur = table_map[name];
      table_map[name] = max(cur, p);
    }
    vector<pair<string, int> > table;
    for (__typeof((table_map).begin()) i = (table_map).begin();
         i != (table_map).end(); ++i) {
      table.push_back(*i);
    }
    sort((table).begin(), (table).end(), comp);
    int cand = table.size();
    int fifty;
    int eighty;
    int ninety;
    int nintynine;
    int cnt = 0;
    for (int i = 0; i < (int)(table.size()); i++) {
      int val = table[i].second;
      if (i * 2 < cand) {
        fifty = val;
      }
      if (i * 5 < cand * 4) {
        eighty = val;
      }
      if (i * 10 < cand * 9) {
        ninety = val;
      }
      if (i * 100 < cand * 99) {
        nintynine = val;
      }
    }
    map<string, string> ans;
    for (int i = 0; i < (int)(table.size()); i++) {
      string name = table[i].first;
      int val = table[i].second;
      if (val >= fifty) {
        ans[name] = "random";
      } else {
        ans[name] = "noob";
      }
      if (val >= eighty) {
        ans[name] = "average";
      }
      if (val >= ninety) {
        ans[name] = "hardcore";
      }
      if (val >= nintynine) {
        ans[name] = "pro";
      }
    }
    cout << cand << endl;
    for (__typeof((ans).begin()) i = (ans).begin(); i != (ans).end(); ++i) {
      cout << i->first << " " << i->second << endl;
    }
  }
  return 0;
}
