#include <bits/stdc++.h>
using namespace std;
int main() {
  int c, b, i, j, k = 0, v[4];
  for (i = 0; i <= 9; ++i) {
    for (j = 0; j < 4; ++j) {
      cout << i;
    }
    cout << '\n';
    fflush(stdout);
    cin >> b >> c;
    if (b == 1) {
      v[k] = i;
      k++;
    }
  }
  do {
    cout << v[0] << v[1] << v[2] << v[3] << '\n';
    fflush(stdout);
    cin >> b >> c;
    if (b == 4) return 0;
  } while (next_permutation(v, v + 4));
  return 0;
}
