#include <bits/stdc++.h>
using namespace std;
int main() {
  cout.setf(ios_base::fixed);
  cout.precision(25);
  vector<int> ans = {0, 0, 0, 0};
  for (int i = 0; i < 4; ++i) {
    int mx = 0, r = 0;
    for (int j = 0; j < 10; ++j) {
      for (int z = 0; z < 4; ++z) {
        cout << (i == z ? j : ans[z]);
      }
      cout << endl;
      int x, y;
      cin >> x >> y;
      if (x == 4 && y == 0) {
        return 0;
      }
      if (mx < x) {
        mx = x;
        r = j;
      }
    }
    ans[i] = r;
  }
  return 0;
}
