#include <bits/stdc++.h>
using namespace std;
char ss[5][20] = {"noob", "random", "average", "hardcore", "pro"};
struct node {
  string s;
  int sc, rank;
  node() : sc(0), rank(-1) {}
} t[1010];
int p = 0;
map<string, int> m;
bool cmp(node a, node b) { return (a.sc < b.sc ? true : false); }
bool cmp1(node a, node b) { return a.s < b.s; }
int findrank(int equ) {
  double per = equ / (double)p;
  if (per >= 0.99)
    return 4;
  else if (per >= 0.9 && 1 - per > 0.01)
    return 3;
  else if (per >= 0.8 && 1 - per > 0.1)
    return 2;
  else if (per >= 0.5 && 1 - per > 0.2)
    return 1;
  else
    return 0;
}
int main() {
  int num;
  cin >> num;
  string s;
  int sc, i, j;
  for (i = 0; i < num; ++i) {
    cin >> s >> sc;
    if (m.find(s) == m.end()) m[s] = p++;
    j = m[s];
    t[j].s = s;
    t[j].sc = max(t[j].sc, sc);
  }
  sort(t, t + p, cmp);
  int beg, end = 0, cur = 0;
  for (; cur < p; ++cur) {
    if (cur >= end)
      for (; t[cur].sc == t[end].sc; ++end)
        ;
    t[cur].rank = findrank(end);
  }
  sort(t, t + p, cmp1);
  cout << p << endl;
  for (i = 0; i < p; ++i) cout << t[i].s << " " << ss[t[i].rank] << endl;
  return 0;
}
