#include <bits/stdc++.h>
using namespace std;
int steps = 0;
vector<string> go(vector<int> &men) {
  steps++;
  int k;
  cout << "next ";
  for (int i = 0; i < men.size(); i++) {
    cout << men[i] << ' ';
  }
  cout << '\n';
  fflush(stdout);
  cin >> k;
  vector<string> res(k);
  for (int i = 0; i < k; i++) {
    cin >> res[i];
  }
  return res;
}
vector<string> go(int first, int num) {
  steps++;
  int k;
  cout << "next ";
  for (int i = first; i < first + num; i++) {
    cout << i << ' ';
  }
  cout << '\n';
  fflush(stdout);
  cin >> k;
  vector<string> res(k);
  for (int i = 0; i < k; i++) {
    cin >> res[i];
  }
  return res;
}
int main() {
  vector<string> res;
  int s, t, coor1;
  res = go(0, 1);
  res = go(0, 2);
  while (res.size() == 3) {
    res = go(0, 1);
    res = go(0, 2);
  }
  coor1 = steps / 2;
  if (coor1 == 1) {
    res = go(2, 8);
    cout << "done\n";
    return 0;
  }
  res = go(0, 1);
  while (res.size() == 3) {
    res = go(0, 1);
  }
  s = steps - coor1 * 2;
  for (int i = 0; i < coor1 - steps; i++) {
    res = go(2, 8);
  }
  while (res.size() > 1) {
    res = go(0, 10);
  }
  cout << "done\n";
  return 0;
}
