#include <bits/stdc++.h>
using namespace std;
pair<string, int> m[1000];
int getPercent(int n, int p) { return (p * 100) / n; }
int main() {
  int n, S = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    int a;
    bool b = false;
    cin >> s >> a;
    for (int j = 0; j < i; j++)
      if (m[j].first == s) {
        m[j].second = max(m[j].second, a);
        b = true;
      }
    if (!b) {
      m[S].first = s;
      m[S].second = a;
      S++;
    }
  }
  cout << S << endl;
  for (int i = 0; i < S; i++) {
    int b = 0, k = 0;
    for (int j = 0; j < S; j++)
      if (i != j) {
        if (m[i].second >= m[j].second) b++;
        if (m[j].second > m[i].second) k++;
      }
    int cur = getPercent(S, b + 1);
    string ans;
    if (cur < 50) ans = "noob";
    if (cur >= 50) ans = "random";
    if (cur >= 80) ans = "average";
    if (cur >= 90) ans = "hardcore";
    if (cur >= 99) ans = "pro";
    cout << m[i].first << " " << ans << endl;
  }
  return 0;
}
