#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
int comp[10];
inline void get() {
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    string s;
    cin >> s;
    for (char c : s) comp[c - '0'] = i;
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  do {
    cout << "next 0 1" << endl;
    get();
    cout << "next 1" << endl;
    get();
  } while (comp[0] != comp[1]);
  while (comp[0] != comp[2]) {
    cout << "next ";
    for (int i = 0; i < 10; i++) cout << i << ' ';
    cout << endl;
    get();
  }
  cout << "done" << endl;
}
