#include <bits/stdc++.h>
using namespace std;
vector<int> adj;
int remem[10];
int res[5];
int main() {
  int key = 0;
  int w = 0;
  int cnt = 0;
  int t = 0;
  int atm = 0;
  int notx = -1;
  while (1) {
    if (!key) {
      for (int i = 0; i < 4; i++) {
        printf("%d", w);
      }
      printf("\n");
      fflush(stdout);
      int foo[2];
      scanf("%d%d", foo, foo + 1);
      if (foo[0]) {
        adj.push_back(w);
        remem[w]++;
      }
      w++;
      if (w == 10) {
        key = 1;
        for (int i = 0; i < 10; i++) {
          if (!remem[i]) {
            notx = i;
            break;
          }
        }
        w = 0;
        continue;
      }
      atm++;
    } else {
      for (int i = 0; i < 4; i++) {
        if (i == cnt)
          printf("%d", adj[w]);
        else
          printf("%d", notx);
      }
      printf("\n");
      fflush(stdout);
      int foo[2];
      scanf("%d%d", foo, foo + 1);
      if (foo[0]) {
        res[cnt] = adj[w];
      }
      cnt++;
      if (cnt == 4) {
        w++;
        cnt = 0;
        if (w == 4) {
          for (int i = 0; i < 4; i++) {
            printf("%d", res[i]);
          }
          printf("\n");
          fflush(stdout);
          return 0;
        }
      }
      atm++;
    }
    fflush(stdout);
  }
}
