#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
const int maxN = 1 << 17;
int A[maxN];
vector<string> B[maxN];
int main() {
  int n;
  cin >> n;
  map<string, int> m;
  for (int i = 0; i < n; i++) {
    string s;
    int x;
    cin >> s >> x;
    m[s] = max(m[s], x);
  }
  for (auto x : m) {
    B[x.second].push_back(x.first);
    A[x.second]++;
  }
  vector<pair<int, string> > c{{0, "noob"},
                               {50, "random"},
                               {80, "average"},
                               {90, "hardcore"},
                               {99, "pro"}};
  int j = 0;
  cout << m.size() << endl;
  for (int i = 0; i < maxN; i++) {
    if (i) A[i] += A[i - 1];
    while (j < (int)c.size() - 1 &&
           c[j + 1].first * (int)m.size() <= 100 * A[i]) {
      j++;
    }
    for (auto s : B[i]) {
      cout << s << " " << c[j].second << endl;
    }
  }
  return 0;
}
