#include <bits/stdc++.h>
using namespace std;
template <typename G>
struct triple {
  G first, second, T;
};
vector<int> query(vector<int> v) {
  cout << "next";
  for (auto &i : v) cout << " " << i;
  cout << '\n';
  cout.flush();
  vector<int> w(10);
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    string s;
    cin >> s;
    for (auto &j : s) w[j - '0'] = i;
  }
  return w;
}
int main() {
  while (true) {
    query({0, 1});
    auto v = query({1});
    if (v[0] == v[1]) break;
  }
  while (true) {
    auto v = query({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
    bool ok = true;
    for (int i = 0; i < 10; i++) ok &= (v[i] == 0);
    if (ok) break;
  }
  cout << "done\n";
  cout.flush();
  return 0;
}
