#include <bits/stdc++.h>
int cnt[10];
int pos[10];
void read() {
  int tot = 0, cnt = 0;
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    char buff[15];
    scanf("%s", buff);
    int l = strlen(buff);
    ++cnt;
    for (int i = 0; i < l; i++) {
      pos[buff[i] - '0'] = cnt;
    }
    tot += l;
  }
}
void query(std::vector<int> v) {
  printf("next");
  for (int i : v) printf(" %d", i);
  printf("\n");
  fflush(stdout);
  read();
}
int main() {
  while (1) {
    query({0, 1});
    query({1});
    if (pos[0] == pos[1]) break;
  }
  while (1) {
    query({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
    if (pos[1] == pos[2]) break;
  }
  puts("done");
  fflush(stdout);
}
