#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:65000000")
using namespace std;
map<string, int> mp;
vector<pair<int, string> > v;
int main() {
  int n;
  cin >> n;
  string s;
  int p;
  for (int i = 0; i < n; ++i) {
    cin >> s >> p;
    mp[s] = max(mp[s], p);
  }
  for (map<string, int>::iterator it = mp.begin(); it != mp.end(); ++it)
    v.push_back(pair<int, string>(it->second, it->first));
  sort(v.begin(), v.end());
  vector<int> vv;
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); ++i) vv.push_back(v[i].first);
  for (int i = 0; i < v.size(); ++i) {
    vector<int>::iterator it = upper_bound(vv.begin(), vv.end(), v[i].first);
    int d = vv.end() - it;
    d *= 100;
    if (d > 50 * vv.size())
      s = "noob";
    else if (d > 20 * vv.size())
      s = "random";
    else if (d > 10 * vv.size())
      s = "average";
    else if (d > 1 * vv.size())
      s = "hardcore";
    else
      s = "pro";
    cout << v[i].second << " " << s << endl;
  }
  return 0;
}
