#include <bits/stdc++.h>
using namespace std;
int main() {
  map<string, int> name;
  string s, grade;
  int a, n, i, k = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> s >> a;
    if (name[s] == 0) {
      name[s] += a;
    } else
      name[s] = max(name[s], a);
  }
  k = name.size();
  cout << k << endl;
  map<string, int>::iterator cur2, cur1;
  for (cur1 = name.begin(); cur1 != name.end(); cur1++) {
    double hushe_pr;
    int hushe = 0;
    hushe = 0;
    for (cur2 = name.begin(); cur2 != name.end(); cur2++) {
      if ((*cur1).second >= (*cur2).second) hushe++;
    }
    setprecision(12);
    hushe_pr = hushe / (k + 0.0);
    cout << (*cur1).first << " ";
    if (100 * hushe < 50 * k)
      grade = "noob";
    else if (100 * hushe < 80 * k)
      grade = "random";
    else if (100 * hushe < 90 * k)
      grade = "average";
    else if (100 * hushe < 99 * k)
      grade = "hardcore";
    else
      grade = "pro";
    cout << grade << endl;
  }
}
