#include <bits/stdc++.h>
using namespace std;
int x, y, d, ans[4];
vector<int> v;
void ch() {
  if (x == 4 && y == 0) exit(0);
}
int main() {
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 4; j++) cout << i;
    cout << "\n";
    cin >> x >> y;
    ch();
    if (x)
      v.push_back(i);
    else
      d = i;
  }
  memset(ans, -1, sizeof(ans));
  for (int i = 0; i < v.size(); i++) {
    int a = v[i];
    for (int j = 0; j < 4; j++) {
      if (ans[j] != -1) continue;
      cout << "\n";
      for (int k = 0; k < 4; k++) {
        if (k == j)
          cout << a;
        else
          cout << d;
      }
      cout << "\n";
      cin >> x >> y;
      ch();
      if (x) ans[j] = a;
    }
  }
  for (int i = 0; i < 4; i++) cout << ans[i];
  cout << "\n";
  cin >> x >> y;
}
