#include <bits/stdc++.h>
using namespace std;
template <typename T>
using V = vector<T>;
template <typename T>
using VV = vector<V<T>>;
template <typename T>
using Mi = map<long long, T>;
template <typename T>
using MMi = map<long long, Mi<T>>;
const double PI = 3.141592653589793238463;
void cinArr(vector<long long> &arr) {
  for (int i = 0; i < arr.size(); i++) {
    cin >> arr[i];
  }
}
int xx[4] = {1, -1, 0, 0};
int yy[4] = {0, 0, 1, -1};
class Node {
 private:
  long long value;

 public:
  long long l;
  long long r;
  long long mod = 0;
  Node *lChildren;
  Node *rChildren;
  long long getValue() { return value + mod; }
  long long getValue(long long ind) {
    if (l == r) {
      return getValue();
    }
    long long mid = (l + r) / 2;
    if (ind <= mid) {
      return lChildren->getValue(ind);
    } else {
      return rChildren->getValue(ind);
    }
  }
  long long ansNode(long long a, long long b) { return min(a, b); }
  Node(long long l, long long r, vector<long long> &arr) {
    this->l = l;
    this->r = r;
    if (l == r) {
      value = arr[l];
    } else {
      long long mid = (l + r) / 2;
      lChildren = new Node(l, mid, arr);
      rChildren = new Node(mid + 1, r, arr);
      value = ansNode(lChildren->getValue(), rChildren->getValue());
    }
  }
  void update(long long l, long long r, long long add) {
    if (l == this->l && r == this->r) {
      mod += add;
      return;
    }
    long long mid = (this->l + this->r) / 2;
    if (l <= mid) {
      lChildren->update(l, min(mid, r), add);
    }
    if (r > mid) {
      rChildren->update(max(mid + 1, l), r, add);
    }
    value = ansNode(lChildren->getValue(), rChildren->getValue());
  }
};
void go(vector<long long> &arr) {
  cout << "next ";
  for (long long a : arr) {
    cout << a << " ";
  }
  cout << endl;
}
void go(vector<long long> &arr1, vector<long long> &arr2) {
  cout << "next ";
  for (long long a : arr1) {
    cout << a << " ";
  }
  for (long long a : arr2) {
    cout << a << " ";
  }
  cout << endl;
}
void go(vector<long long> &arr1, vector<long long> &arr2,
        vector<long long> &arr3) {
  cout << "next ";
  for (long long a : arr1) {
    cout << a << " ";
  }
  for (long long a : arr2) {
    cout << a << " ";
  }
  for (long long a : arr3) {
    cout << a << " ";
  }
  cout << endl;
}
int cinC() {
  long long k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    long long a;
    cin >> a;
  }
  return k;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(15);
  vector<long long> arr1 = {0, 1, 2, 3, 4, 5, 6, 7};
  vector<long long> arr2 = {8};
  vector<long long> arr3 = {9};
  long long k = 3;
  go(arr1);
  cinC();
  go(arr1, arr2);
  cinC();
  long long count = 0;
  while (k == 3) {
    count++;
    if (count % 2 == 0) {
      go(arr1);
      k = cinC();
    } else {
      go(arr1, arr2);
      k = cinC();
    }
  }
  while (k == 2) {
    go(arr1, arr2, arr3);
    k = cinC();
  }
  cout << "done" << endl;
  return 0;
}
