#include <bits/stdc++.h>
using namespace std;
void solve() {
  map<string, pair<string, long long>> best;
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    string name;
    long long score;
    cin >> name >> score;
    best[name].second = max(best[name].second, score);
  }
  for (auto itr = best.begin(); itr != best.end(); itr++) {
    long long count = 0;
    for (auto i = best.begin(); i != best.end(); i++) {
      if (itr->second.second >= i->second.second) count++;
    }
    double percent = ((double)count / best.size() * 1.0) * 100.0;
    if (percent < 50.0)
      itr->second.first = "noob";
    else if (percent >= 50.0 && percent < 80.0)
      itr->second.first = "random";
    else if (percent >= 80.0 && percent < 90.0)
      itr->second.first = "average";
    else if (percent >= 90.0 && percent < 99.0)
      itr->second.first = "hardcore";
    else
      itr->second.first = "pro";
  }
  cout << best.size() << endl;
  for (auto x : best) {
    cout << x.first << " " << x.second.first << endl;
  }
}
int32_t main() {
  long long testcases = 1;
  while (testcases--) {
    solve();
  }
  return 0;
}
