#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, k;
  cin >> n;
  map<string, int> p;
  map<string, bool> u;
  vector<pair<int, string> > pl;
  vector<string> who(1001);
  for (j = 0; j < n; j++) {
    string tmp;
    cin >> tmp >> k;
    if (!p[tmp]) p[tmp] = k;
    if (!u[tmp]) pl.push_back(make_pair(0, tmp));
    u[tmp] = 1;
    p[tmp] = max(p[tmp], k);
  }
  for (j = 0; j < pl.size(); j++) pl[j].first = p[pl[j].second];
  sort(pl.begin(), pl.end());
  int all = pl.size();
  for (j = 0; j < pl.size(); j++) {
    int l = 0, h = 0, lvl = 0;
    for (i = 0; i < pl.size(); i++) {
      if (pl[i].first == pl[j].first) lvl++;
      if (pl[i].first > pl[j].first) l++;
      if (pl[i].first < pl[j].first) h++;
    }
    double luc = 100 * (double)l / (double)all;
    double huz = 100 * ((double)lvl + (double)h) / (double)all;
    if (luc > 50) who[j] = "noob";
    if (huz > 50 - 0.000001 && luc > 20) who[j] = "random";
    if (huz > 80 - 0.000001 && luc > 10) who[j] = "average";
    if (huz > 90 - 0.000001 && luc > 1) who[j] = "hardcore";
    if (huz > 99 - 0.000001 && luc < 1 + 0.000001) who[j] = "pro";
  }
  cout << pl.size() << endl;
  for (j = 0; j < pl.size(); j++) cout << pl[j].second << ' ' << who[j] << endl;
}
