#include <bits/stdc++.h>
using namespace std;
template <class T>
string i2s(T x) {
  ostringstream o;
  o << x;
  return o.str();
}
int s2i(string x) {
  int r = 0;
  istringstream sin(x);
  sin >> r;
  return r;
}
template <class T>
inline void _min(T &mn, T x) {
  if (mn > x) mn = x;
}
template <class T>
inline void _max(T &mx, T x) {
  if (mx < x) mx = x;
}
int n, m;
map<string, int> mp;
int main() {
  int cnt;
  int i, j, k, t, val;
  string s;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> s >> k;
    if (mp.count(s) > 0)
      mp[s] = max(k, mp[s]);
    else
      mp[s] = k;
  }
  m = mp.size();
  cout << m << endl;
  int fifty = ceil(0.5 * (double)m);
  int eighty = ceil(0.8 * (double)m);
  int ninty = ceil(0.9 * (double)m);
  int n9 = ceil(0.99 * (double)m);
  for (typeof((mp).begin()) it = (mp).begin(); it != (mp).end(); ++it) {
    val = it->second;
    cnt = 0;
    for (typeof((mp).begin()) jt = (mp).begin(); jt != (mp).end(); ++jt) {
      if (val >= jt->second) cnt++;
    }
    int mm = m - cnt;
    if (cnt < fifty) {
      cout << it->first << " "
           << "noob" << endl;
    } else if (cnt < eighty)
      cout << it->first << " "
           << "random" << endl;
    else if (cnt < ninty)
      cout << it->first << " "
           << "average" << endl;
    else if (cnt < n9)
      cout << it->first << " "
           << "hardcore" << endl;
    else
      cout << it->first << " "
           << "pro" << endl;
  }
  return 0;
}
