#include <bits/stdc++.h>
using namespace std;
#define DEBUG_MODE
#define endl '\n'
#ifdef DEBUG_MODE
#define DEBUG(X) debug_func(X, #X)
#define DEBUG_ENDL endl
#define DEBUG_SEPARATOR_LINE cout<<"=================\n"
#else
#define DEBUG(X) 0
#define DEBUG_ENDL 0
#define DEBUG_SEPARATOR_LINE 0
#endif
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
#define DEBUG_ENDL_S(S) ((S).size() ? "\n" : "")
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
void debug_func_preffix(const string &s) { if(s.size()) cout << s << " = "; }
template <typename T>
void debug_func(const T &t, const string &s = "") {
    debug_func_preffix(s);
    cout << t << DEBUG_ENDL_S(s);
}
template <typename T, typename U>
void debug_func(const P<T, U> &p, const string &s = "") {
    debug_func_preffix(s);
    cout << "(";
    debug_func(p.first);
    cout << ", ";
    debug_func(p.second);
    cout << ")" << DEBUG_ENDL_S(s);
}
template <typename T>
void debug_func(const V<T> &v, const string &s = "") {
    for(ll i = 0; i < v.size(); i++) {
        string t = s + "[" + to_string(i) + "]";
        debug_func(v[i], t);
    }
}

VV<ll> edges;
VV<ll> dummy_children;
ll e_cnt;
ll N, K;

void create_dummy_children(V<ll> now, ll num) {
    V<ll> nxt;
    for(ll e : now) {
        for(ll i = 0; i < 2; i++) {
            if(num == N) break;
            dummy_children[e].push_back(num);
            nxt.push_back(num);
            num++;
        }
    }
    if(nxt.size()) create_dummy_children(move(nxt), num);
}

V<ll> add_edges(ll now) {
    V<ll> tmp1(0), tmp2(0);
    if(dummy_children[now].size() >= 1) {
        tmp1 = add_edges(dummy_children[now][0]);
        for(ll e : tmp1) {
            e_cnt++;
            edges[now].push_back(e);
        }
    }
    if(dummy_children[now].size() >= 2) {
        tmp2 = add_edges(dummy_children[now][1]);
        for(ll e : tmp2) tmp1.push_back(e);
    }
    tmp1.push_back(now);
    return move(tmp1);
}

int main() {
    cin >> N >> K;
    edges.resize(N);
    dummy_children.resize(N);
    if(N != 1 && N != 2) {
        create_dummy_children({0}, 1);
        add_edges(0);
    }
    cout << e_cnt << endl;
    for(ll i = 0; i < N; i++) for(ll e : edges[i]) if(i < e) cout << i + 1 << ' ' <<  e + 1 << endl;
    cout << flush;
    for(ll que = 0; que < K; que++) {
        ll now = 0;
        while(1) {
            cout << now + 1 << endl << flush;
            string s;
            cin >> s;
            if(s == "Yes") break;
            if(N != 2) {
                if(s == "Near") now = dummy_children[now][0];
                if(s == "No") now = dummy_children[now][1];
            } else {
                now = 1;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3308