#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  string s = "0000";
  for (int i = 0; i < 4; ++i) {
    int cows = 0, dig = 0;
    bool breakKor = false;
    for (int j = 0; j < 10; ++j) {
      s[i] = j + '0';
      cout << s << endl;
      fflush(stdout);
      int c, b;
      cin >> c >> b;
      if (c > cows) {
        cows = c;
        dig = j;
      }
      if (c == 4 && b == 0) {
        breakKor = true;
        break;
      }
    }
    s[i] = dig + '0';
    if (breakKor) {
      break;
    }
  }
  cout << s << endl;
  fflush(stdout);
  return 0;
}
