#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[4] = {0, 0, 0, 0};
  int a_pr = 0, k = 0, b = 0, mx_id;
  for (int i = 0; i < 4; i++) {
    a_pr = i;
    for (int z = 0; z < 10; z++) {
      for (int j = 0; j < 4; j++) cout << a[j];
      cout << '\n';
      cin >> k >> b;
      if (k == 4) {
        return 0;
      } else if (k > a_pr) {
        a_pr = k;
        mx_id = z;
        a[i]++;
      } else
        a[i]++;
    }
    a[i] = mx_id;
  }
}
