#include <bits/stdc++.h>
std::vector<int> Move(const std::vector<int>& ids) {
  printf("next");
  for (auto id : ids) {
    printf(" %d", id);
  }
  printf("\n");
  fflush(stdout);
  std::vector<int> groups(10);
  char buffer[20];
  int n = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%s", buffer);
    for (int j = 0; buffer[j]; ++j) {
      int id = buffer[j] - '0';
      groups[id] = i;
    }
  }
  return groups;
}
int main() {
  std::vector<int> id0({0});
  std::vector<int> id01({0, 1});
  std::vector<int> id_all;
  for (int i = 0; i <= 9; ++i) {
    id_all.push_back(i);
  }
  int k = 0;
  while (1) {
    Move(id0);
    auto groups = Move(id01);
    k++;
    if (groups[0] == groups[1]) {
      break;
    }
  }
  while (1) {
    auto groups = Move(id_all);
    int sum = 0;
    for (int i = 0; i <= 9; ++i) {
      sum += groups[i];
    }
    if (sum == 0) {
      puts("done");
      fflush(stdout);
      break;
    }
  }
  return 0;
}
