#include <bits/stdc++.h>
using namespace std;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-9;
int bit_count(int first) {
  return first == 0 ? 0 : 1 + bit_count(first & (first - 1));
}
inline int low_bit(int first) { return first & -first; }
inline int sign(double first) {
  return first < -EPS ? -1 : first > EPS ? 1 : 0;
}
inline int sign(int first) { return (first > 0) - (first < 0); }
inline int getInt() {
  int a;
  return scanf("%d", &a) ? a : (fprintf(stderr, "trying to read\n"), -1);
}
inline double getDouble() {
  double a;
  return scanf("%lf", &a) ? a : (fprintf(stderr, "trying to read\n"), -1.0);
}
inline double myRand() {
  return ((double)rand() / RAND_MAX) + ((double)rand() / RAND_MAX / RAND_MAX);
}
const int BUF_SIZE = 1001 * 1000;
char buf[BUF_SIZE];
inline string getToken() {
  return scanf("%s", buf) ? buf : (fprintf(stderr, "trying to read\n"), "");
}
inline string getLine() {
  string ret;
  getline(cin, ret);
  return ret;
}
map<string, int> cache;
void myCode() {
  int ttt = getInt();
  for (int tt = (int)0; tt < (int)ttt; ++tt) {
    string s = getToken();
    int first = getInt();
    if (cache.count(s) == 0 || cache[s] < first) cache[s] = first;
  }
  int n = ((int)(cache).size());
  vector<int> scores;
  for (typeof((cache).begin()) i = (cache).begin(); i != (cache).end(); ++i)
    scores.push_back(i->second);
  sort((scores).begin(), (scores).end());
  printf("%d\n", ((int)(cache).size()));
  for (typeof((cache).begin()) i = (cache).begin(); i != (cache).end(); ++i) {
    string s;
    double u = upper_bound((scores).begin(), (scores).end(), i->second) -
               scores.begin();
    if (u / n > 0.99 - EPS)
      s = "pro";
    else if (u / n > 0.9 - EPS)
      s = "hardcore";
    else if (u / n > 0.8 - EPS)
      s = "average";
    else if (u / n > 0.5 - EPS)
      s = "random";
    else
      s = "noob";
    printf("%s %s\n", i->first.c_str(), s.c_str());
  }
}
int main() {
  srand(time(NULL));
  myCode();
  return 0;
}
