#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  map<string, int> x;
  map<string, vector<string> > m;
  vector<string> v;
  v.push_back("noob");
  v.push_back("random");
  v.push_back("average");
  v.push_back("hardcore");
  v.push_back("pro");
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    int z;
    cin >> s >> z;
    x[s] = max(x[s], z);
  }
  int sz = x.size();
  for (map<string, int>::iterator it = x.begin(); it != x.end(); it++) {
    int c = 0;
    for (map<string, int>::iterator it2 = x.begin(); it2 != x.end(); it2++)
      if ((*it).second >= (*it2).second) c++;
    int y = (c * 100) / sz;
    if (y < 50)
      m["noob"].push_back((*it).first);
    else if (y < 80)
      m["random"].push_back((*it).first);
    else if (y < 90)
      m["average"].push_back((*it).first);
    else if (y < 99)
      m["hardcore"].push_back((*it).first);
    else
      m["pro"].push_back((*it).first);
  }
  cout << sz << endl;
  for (int i = 0; i < v.size(); i++)
    for (int j = 0; j < m[v[i]].size(); j++)
      cout << m[v[i]][j] << " " << v[i] << endl;
  return 0;
}
