#include <bits/stdc++.h>
using namespace std;
int a[6];
int main() {
  bool ok = 0;
  for (int k = 1; k <= 4; k++) {
    int mx = -1;
    int num = -1;
    for (int i = 0; i < 10; i++) {
      for (int j = 1; j < k; j++) {
        cout << a[j];
      }
      cout << i;
      for (int j = k + 1; j <= 4; j++) {
        cout << 0;
      }
      cout << endl;
      fflush(stdout);
      int a, b;
      cin >> a >> b;
      if (a == 4 && b == 0) {
        ok = 1;
        break;
      }
      if (a > mx) {
        mx = a;
        num = i;
      }
    }
    a[k] = num;
    if (ok) {
      break;
    }
  }
  return 0;
}
