#include <bits/stdc++.h>
using namespace std;
long long ncr(long long n, long long r) {
  if (n < r)
    return 0;
  else if (n == r)
    return 1;
  r = min(r, n - r);
  long long ans = 1;
  for (int i = 1; i <= r; i++) {
    ans *= (long long)(n - i + 1);
    ans /= i;
    ans %= 1000000007;
  }
  return ans % 1000000007;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  map<string, int> mp;
  for (long long int i = 0; i < n; i++) {
    string s;
    int o;
    cin >> s >> o;
    mp[s] = max(mp[s], o);
  }
  vector<pair<int, string> > v;
  for (auto &x : mp) v.push_back(make_pair(x.second, x.first));
  sort(v.begin(), v.end());
  n = v.size();
  cout << n << "\n";
  for (int i = 0; i < n; i++) {
    vector<string> g = {v[i].second};
    while (i < n - 1 && v[i].first == v[i + 1].first) {
      g.push_back(v[i + 1].second);
      i++;
    }
    double d = (n - i - 1.0) / n;
    string h = "";
    if (d > 0.5) {
      h = "noob";
    } else if (d > 0.2) {
      h = "random";
    } else if (d > 0.1) {
      h = "average";
    } else if (d > 0.01) {
      h = "hardcore";
    } else {
      h = "pro";
    }
    for (auto &x : g) cout << x << " " << h << "\n";
  }
}
