#include <bits/stdc++.h>
using namespace std;
pair<int, int> qry(int a, int b, int c, int d) {
  cout << a << b << c << d << endl;
  fflush(stdout);
  int e, f;
  cin >> e >> f;
  return make_pair(e, f);
}
int main() {
  vector<int> d;
  for (int i = 0; i < 10; ++i) {
    pair<int, int> r = qry(i, i, i, i);
    if (r.first + r.second > 0) {
      d.push_back(i);
    }
  }
  int xi[] = {0, 1, 2, 3};
  do {
    pair<int, int> r = qry(d[xi[0]], d[xi[1]], d[xi[2]], d[xi[3]]);
    if (r.first == 4 && r.second == 0) {
      return 0;
    }
  } while (next_permutation(xi, xi + 4));
  return 0;
}
