#include <bits/stdc++.h>
using namespace std;
int c, p, cmp[15];
void get_cmp(string s) {
  cout << "next " << s << endl;
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    string s;
    cin >> s;
    for (auto c : s) cmp[c - '0'] = i;
  }
}
int main() {
  do get_cmp("0 1"), get_cmp("1"), p++;
  while (cmp[0] ^ cmp[1]);
  do get_cmp("1"), c++;
  while (cmp[0] ^ cmp[1]);
  while (p-- % c) get_cmp("0 1");
  while (cmp[0] ^ cmp[2]) get_cmp("0 1 2 3 4 5 6 7 8 9");
  cout << "done\n";
}
