#include <bits/stdc++.h>
using namespace std;
int nowpos[10];
int goal1[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
bool mv[10];
vector<vector<int>> p;
int of[10];
void F() {
  cout << "next ";
  for (int i = 0; i < 10; ++i) {
    if (mv[i]) {
      ++nowpos[i];
      cout << i << ' ';
    }
  }
  cout << '\n';
  cout.flush();
  p.clear();
  int s;
  cin >> s;
  for (int i = 1; i <= s; ++i) {
    string g;
    cin >> g;
    p.push_back({});
    for (char c : g) {
      p.back().push_back(c - '0');
      of[c - '0'] = p.size() - 1;
    }
  }
}
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  while (true) {
    mv[0] = mv[1] = true;
    F();
    mv[0] = false;
    mv[1] = true;
    F();
    if (of[0] == of[1]) break;
  }
  while (true) {
    memset(mv, 1, sizeof mv);
    F();
    if (of[0] == of[2]) break;
  }
  cout << "done" << endl;
}
