#include <bits/stdc++.h>
using namespace std;
int color[20], k;
void query(bool one, bool two, bool three) {
  printf("next");
  if (one) printf(" 0");
  if (two)
    for (int i = 1; i <= 8; ++i) printf(" %d", i);
  if (three) printf(" 9");
  printf("\n");
  fflush(stdout);
  scanf("%d", &k);
  for (int i = 1; i <= k; ++i) {
    string in;
    cin >> in;
    for (auto g : in) color[g - '0'] = i;
  }
}
int cycle;
int main() {
  for (;;) {
    query(1, 1, 0);
    query(1, 0, 0);
    if (color[0] == color[1]) {
      break;
    }
  }
  while (color[0] != color[9]) query(1, 1, 1);
  puts("done");
  fflush(stdout);
  return 0;
}
