#include <bits/stdc++.h>
using namespace std;
void query(int *fl, int *co) {
  printf("next");
  for (int i = (int)(0); i <= (int)(9); i++)
    if (fl[i]) printf(" %d", i);
  puts("");
  fflush(stdout);
  int cnt;
  char s[15];
  scanf("%d", &cnt);
  for (int i = (int)(1); i <= (int)(cnt); i++) {
    scanf("%s", s + 1);
    int len = strlen(s + 1);
    for (int j = (int)(1); j <= (int)(len); j++) co[s[j] - '0'] = i;
  }
}
int fl[15], co[15];
void solve() {
  int tt = 0;
  for (;;) {
    fl[0] = fl[1] = 1;
    tt += 2;
    query(fl, co);
    fl[1] = 0;
    query(fl, co);
    fl[0] = 0;
    if (co[0] == co[1]) break;
  }
  for (;;) {
    for (int i = (int)(0); i <= (int)(9); i++) fl[i] = 1;
    tt++;
    query(fl, co);
    for (int i = (int)(0); i <= (int)(9); i++) fl[i] = 0;
    if (co[0] == co[2]) break;
  }
  puts("done");
  fflush(stdout);
}
int main() { solve(); }
