#include <bits/stdc++.h>
int ans[4];
int main() {
  int bull, cow, e = 0;
  for (int i = 0; i <= 9; i++) {
    printf("%d%d%d%d\n", i, i, i, i);
    fflush(stdout);
    scanf("%d%d", &bull, &cow);
    if (bull == 1) {
      ans[e] = i;
      e++;
    }
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      if (j == i) continue;
      for (int k = 0; k < 4; k++) {
        if (k == i || k == j) continue;
        for (int l = 0; l < 4; l++) {
          if (l == i || l == j || l == k) continue;
          printf("%d%d%d%d\n", ans[i], ans[j], ans[k], ans[l]);
          fflush(stdout);
          scanf("%d%d", &bull, &cow);
          if (bull == 4) break;
        }
        if (bull == 4) break;
      }
      if (bull == 4) break;
    }
    if (bull == 4) break;
  }
  return 0;
}
