#include <bits/stdc++.h>
using namespace std;
int Ans[5];
int main() {
  for (int i = 1; i <= 4; i++) {
    int mx = 0, mxw = 0;
    for (int j = 0; j <= 9; j++) {
      for (int k = 1; k < i; k++) printf("0");
      printf("%d", j);
      for (int k = i + 1; k <= 4; k++) printf("0");
      printf("\n");
      fflush(stdout);
      int x, y;
      scanf("%d%d", &x, &y);
      if (x > mx) mx = x, mxw = j;
    }
    Ans[i] = mxw;
  }
  for (int i = 1; i <= 4; i++) printf("%d", Ans[i]);
  fflush(stdout);
  return 0;
}
