#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  vector<int> v;
  for (int i = 0; i <= 9; i++) {
    cout << i << i << i << i;
    cout << endl;
    fflush(stdout);
    cin >> a >> b;
    if (a == 4 and b == 0) {
      exit(0);
    } else if (a > 0 or b > 0) {
      v.push_back(i);
    }
    if (v.size() == 4) break;
  }
  do {
    for (int i = 0; i < v.size(); i++) {
      cout << v[i];
    }
    fflush(stdout);
    cout << endl;
    cin >> a >> b;
    if (a == 4 and b == 0) {
      exit(0);
    }
  } while (next_permutation(v.begin(), v.end()));
}
