#include <bits/stdc++.h>
using namespace std;
int g[12];
void ask(vector<int> a) {
  cout << "next";
  for (auto x : a) cout << " " << x;
  cout << "\n";
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < (int)s.size(); j++) {
      g[s[j] - '0'] = i;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  while (true) {
    ask({0, 1});
    ask({0});
    if (g[0] == g[1]) break;
  }
  while (true) {
    ask({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
    if (g[0] == g[2]) break;
  }
  cout << "done\n";
}
