#include <bits/stdc++.h>
using namespace std;
int b, c;
string s = "0000", tmp = "0000";
int main() {
  for (int i = 0; i < 4; i++) {
    int mx = 0;
    for (int j = 0; j < 10; j++) {
      tmp[i] = j + '0';
      cout << tmp << endl;
      cin >> b >> c;
      if (b > mx) {
        s[i] = j + '0';
        mx = b;
      }
      if (b == 4) exit(0);
    }
    tmp = s;
  }
}
