#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d, e, f, g, aa;
  cout << "0000" << endl;
  cin >> a >> b;
  aa = a;
  for (c = 1; c < 10; c++) {
    cout << "000" << c << endl;
    cin >> a >> b;
    if (a == 4)
      return 0;
    else {
      if (aa < a) {
        aa = a;
        break;
      } else if (aa > a) {
        c--;
        break;
      }
      aa = a;
    }
  }
  for (d = 1; d < 10; d++) {
    cout << "00" << d << c << endl;
    cin >> a >> b;
    if (a == 4)
      return 0;
    else {
      if (aa < a) {
        aa = a;
        break;
      } else if (aa > a) {
        d--;
        break;
      }
      aa = a;
    }
  }
  for (e = 1; e < 10; e++) {
    cout << 0 << e << d << c << endl;
    cin >> a >> b;
    if (a == 4)
      return 0;
    else {
      if (aa < a) {
        aa = a;
        break;
      } else if (aa > a) {
        e--;
        break;
      }
      aa = a;
    }
  }
  for (f = 0; f < 10; f++) {
    cout << f << e << d << c << endl;
    cin >> a >> b;
    if (a == 4) return 0;
  }
}
