#include <bits/stdc++.h>
using namespace std;
vector<pair<int, string> > d;
vector<int> cnt;
int main() {
  int n;
  cin >> n;
  map<string, int> mp;
  for (int i = 0; i < n; i++) {
    string name;
    int pts;
    cin >> name >> pts;
    mp[name] = max(mp[name], pts);
  }
  for (pair<string, int> p : mp) d.push_back(make_pair(p.second, p.first));
  sort(d.begin(), d.end());
  int m = d.size();
  for (int i = 0; i < m;) {
    int l = i;
    while (i < m && d[i].first == d[l].first) i++;
    int r = i - 1;
    for (int j = l; j <= r; j++) {
      cnt.push_back(m - 1 - r);
    }
  }
  cout << m << endl;
  for (int i = 0; i < int(d.size()); i++) {
    cout << d[i].second << " ";
    if (cnt[i] * 100 > 50 * m)
      cout << "noob";
    else if (cnt[i] * 100 > 20 * m)
      cout << "random";
    else if (cnt[i] * 100 > 10 * m)
      cout << "average";
    else if (cnt[i] * 100 > 1 * m)
      cout << "hardcore";
    else
      cout << "pro";
    cout << endl;
  }
  return 0;
}
