#include <bits/stdc++.h>
using namespace std;
using namespace std;
class TaskB {
 public:
  void solve(std::istream &in, std::ostream &out) {
    ios::sync_with_stdio(false);
    vector<int> count(10);
    int bulls = 0, cows = 0, found = 0;
    string s = "";
    int empty = 9;
    for (int i = 0; i < 10 && found < 4; ++i) {
      s = "";
      for (int j = 0; j < 4; ++j) {
        s += to_string(i);
      }
      out << s << endl;
      fflush(stdout);
      in >> bulls >> cows;
      count[i] = bulls;
      if (bulls == 0) {
        empty = i;
      } else {
        found += bulls;
      }
    }
    s = "XXXX";
    string res = "XXXX";
    string empty_str = "";
    for (int i = 0; i < 4; ++i) {
      empty_str += to_string(empty);
    }
    for (int i = 0; i < 10; ++i) {
      for (int j = 0; j < 4 && count[i] > 0; ++j) {
        if (s[j] == 'X') {
          res = empty_str;
          res.replace(j, 1, to_string(i));
          out << res << endl;
          fflush(stdout);
          in >> bulls >> cows;
          if (bulls > 0) {
            count[i]--;
            s.replace(j, 1, to_string(i));
          }
        }
      }
    }
    out << s << endl;
    fflush(stdout);
  }
};
int main() {
  TaskB solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}
