#include <bits/stdc++.h>
using namespace std;
map<string, int> m;
struct node {
  string s;
  int n;
  string rating;
} num[1005];
bool cmp(node a, node b) { return a.n > b.n; }
int main() {
  int n;
  cin >> n;
  int t = n;
  getchar();
  m.clear();
  while (t--) {
    string str;
    int num;
    cin >> str >> num;
    if (m[str] < num) m[str] = num;
  }
  cout << m.size() << endl;
  map<string, int>::iterator it;
  int flag = 1;
  for (it = m.begin(); it != m.end(); ++it) {
    num[flag].s = it->first;
    num[flag].n = it->second;
    flag++;
  }
  sort(num + 1, num + flag, cmp);
  cout << num[1].s << " "
       << "pro" << endl;
  num[1].rating = "pro";
  for (int i = 2; i < flag; ++i) {
    if (num[i].n == num[i - 1].n)
      num[i].rating = num[i - 1].rating;
    else {
      double rate = 1.0 * (flag - i) / (flag - 1);
      if (rate >= 0.99 - 1e-7)
        num[i].rating = "pro";
      else if (rate >= 0.9 - 1e-7)
        num[i].rating = "hardcore";
      else if (rate >= 0.8 - 1e-7)
        num[i].rating = "average";
      else if (rate >= 0.5 - 1e-7)
        num[i].rating = "random";
      else
        num[i].rating = "noob";
    }
    cout << num[i].s << " " << num[i].rating << endl;
  }
  return 0;
}
