#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
vector<int> s[N];
int n;
int main()
{
cin >> n;
int t, p;
for (int i = 1; i <= n; i ++ )
{
cin >> t >> p;
s[t].push_back(p);
}
for (int i = 1; i <= n; i ++ ) sort(s[i].begin(), s[i].end());
for (int i = 1; s[i].size(); i ++ )
{
if (i == 1 || i == 2) cout << i << " N" << endl;
else
{
int min_p = min(s[i - 1][0], s[i - 2][0]);
bool is_find = false;
for (int j = 0; j < s[i].size(); j ++ )
if(s[i][j] - min_p >= 5) is_find = true;
if (is_find) cout << i << " Y" << endl;
else cout << i << " N" << endl;
}
}
return 0;
}