#include <bits/stdc++.h>
using namespace std;
int n;
string name[1001];
int fen[1001];
vector<pair<string, int> > old;
vector<pair<int, string> > xin;
vector<int> ff;
int main(int argc, char *argv[]) {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> name[i] >> fen[i];
    old.push_back(make_pair(name[i], fen[i]));
  }
  sort(old.begin(), old.end());
  for (int i = 0; i < (int)old.size(); i++) {
    if (i == (int)old.size() - 1 || old[i].first != old[i + 1].first) {
      xin.push_back(make_pair(old[i].second, old[i].first));
    }
  }
  sort(xin.begin(), xin.end());
  for (int i = 0; i < (int)xin.size(); i++) {
    ff.push_back(xin[i].first);
  }
  int sz = ff.size(), wz;
  cout << sz << endl;
  for (int i = 0; i < (int)xin.size(); i++) {
    wz = sz - (upper_bound(ff.begin(), ff.end(), ff[i]) - ff.begin());
    if (wz * 2 > sz) {
      cout << xin[i].second << " noob\n";
    } else if (wz * 5 > sz) {
      cout << xin[i].second << " random\n";
    } else if (wz * 10 > sz) {
      cout << xin[i].second << " average\n";
    } else if (wz * 100 > sz) {
      cout << xin[i].second << " hardcore\n";
    } else {
      cout << xin[i].second << " pro\n";
    }
  }
  return EXIT_SUCCESS;
}
