#include <bits/stdc++.h>
using namespace std;
int t, b[20], ans[20];
vector<int> a;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  for (int i = 0; i <= 9; i++) {
    cout << i << i << i << i << endl;
    fflush(stdout);
    int x, y;
    cin >> x >> y;
    if (x == 0 && y == 0)
      t = i;
    else
      a.push_back(i);
  }
  for (int i = 0; i < 4; i++)
    for (int l = 0; l < 4; l++) {
      for (int j = 0; j < 4; j++) b[j] = t;
      b[l] = a[i];
      for (int j = 0; j < 4; j++) cout << b[j];
      cout << endl;
      fflush(stdout);
      int x, y;
      cin >> x >> y;
      if (x == 1) ans[l] = a[i];
    }
  for (int i = 0; i < 4; i++) cout << ans[i];
  return 0;
}
