#include <bits/stdc++.h>
using namespace std;
void debug_out() { cout << "\n"; }
template <typename T1, typename... T2>
void debug_out(T1 A, T2... B) {
  cout << " " << A;
  debug_out(B...);
}
int test = 1;
template <typename T1>
void print(vector<T1> V, int add = 0, int start = -1, int end = -1) {
  if (start < 0) start = 0;
  if (end < 0) end = V.size() - 1;
  for (int i = start; i <= end; i++) {
    cout << V[i] + add << ((i == end) ? "\n" : " ");
  }
}
template <typename T1>
T1 chmin(T1 &x, const T1 v) {
  return x = min(x, v);
}
template <typename T1>
T1 chmax(T1 &x, const T1 v) {
  return x = max(x, v);
}
vector<int> move(vector<int> mv) {
  cout << "next ";
  print(mv);
  cout.flush();
  vector<int> A(10);
  int s;
  cin >> s;
  string g;
  for (int i = 0; i < s; i++) {
    cin >> g;
    for (auto c : g) {
      A[c - '0'] = i;
    }
  }
  return A;
}
void solve() {
  while (true) {
    move({0, 1});
    vector<int> S = move({1});
    if (S[0] == S[1]) break;
  }
  while (true) {
    vector<int> S = move({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
    if (S[0] == S.back()) break;
  }
  cout << "done\n";
}
int main(int argc, const char *argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (int testCount = 1; testCount <= test; testCount++) {
    solve();
  }
  return 0;
}
