#include <bits/stdc++.h>
using namespace std;
float percentage(map<string, int> mapping, string str) {
  int score = mapping[str];
  int count = 0;
  int total = 0;
  for (auto i : mapping) {
    if (i.second <= score) count++;
    total++;
  }
  return ((float)count / total * (100.0));
}
int main() {
  int n;
  cin >> n;
  vector<pair<string, int>> arr;
  map<string, int> mapping;
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    int temp;
    cin >> temp;
    arr.push_back(make_pair(str, temp));
    if (mapping.find(str) == mapping.end()) {
      mapping[str] = temp;
    } else {
      if (mapping[str] < temp) mapping[str] = temp;
    }
  }
  cout << mapping.size() << endl;
  for (auto i : mapping) {
    string s = "";
    float percent = percentage(mapping, i.first);
    if (percent < 50) {
      s = "noob";
    } else if (percent >= 50 && percent < 80) {
      s = "random";
    } else if (percent >= 80 && percent < 90) {
      s = "average";
    } else if (percent >= 90 && percent < 99) {
      s = "hardcore";
    } else {
      s = "pro";
    }
    cout << i.first << " " << s << endl;
  }
}
