#include <bits/stdc++.h>
using namespace std;
void swap(char *x, char *y) {
  char temp;
  temp = *x;
  *x = *y;
  *y = temp;
}
int cow;
int bull;
int flag;
void permute(char *a, int l, int r) {
  int i;
  if (flag == 1) return;
  if (l == r) {
    cout << a << endl;
    scanf("%d %d", &cow, &bull);
    if (cow == 4) {
      flag = 1;
      return;
    }
    fflush(stdout);
  } else {
    for (i = l; i <= r; i++) {
      swap((a + l), (a + i));
      permute(a, l + 1, r);
      swap((a + l), (a + i));
    }
  }
}
int main() {
  int i, j;
  char num[10];
  flag = 0;
  j = 0;
  for (i = 0; i < 10; i++) {
    cout << i << i << i << i << endl;
    scanf("%d %d", &cow, &bull);
    if (cow == 1) num[j++] = i + '0';
    fflush(stdout);
  }
  num[4] = '\0';
  permute(num, 0, 3);
  return 0;
}
