#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10, P = 15;
int pos[P], comp[P];
int _t, _c, _q;
void move(vector<int> players);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int p = 10;
  for (int i = 0; i < p; ++i) {
    comp[i] = 0;
  }
  int c = 0;
  move({0, 1});
  move({1});
  while (true) {
    move({0, 1});
    move({1});
    if (comp[0] == comp[1]) {
      break;
    }
  }
  vector<int> all;
  for (int i = 0; i < p; ++i) {
    all.push_back(i);
  }
  while (comp[0] != comp[2]) {
    move(all);
  }
  cout << "done" << endl;
}
void move(vector<int> players) {
  string print = "next ";
  for (auto &i : players) {
    ++pos[i];
    print += char(i + '0');
    print += ' ';
  }
  cout << print << endl;
  int k;
  cin >> k;
  for (int i = 0; i < k; ++i) {
    string s;
    cin >> s;
    for (auto &c : s) {
      comp[c - '0'] = i;
    }
  }
}
