#include <bits/stdc++.h>
using namespace std;
int main() {
  set<int> su;
  int a, b;
  for (int i = 0; i <= 9; i++) {
    char c = 48 + i;
    string s = "";
    s = s + c + c + c + c;
    cout << s << endl;
    cin >> a >> b;
    if (a == 1) {
      su.insert(i);
    }
    fflush(stdout);
  }
  char arr[4];
  for (int i = 0; i < 4; i++) {
    set<int>::iterator it = su.begin();
    int x = *it;
    su.erase(x);
    arr[i] = x + 48;
  }
  sort(arr, arr + 4);
  do {
    for (int i = 0; i < 4; i++) cout << arr[i];
    cout << endl;
    cin >> a >> b;
    if (a == 4) {
      return 0;
    }
    fflush(stdout);
  } while (next_permutation(arr, arr + 4));
  return 0;
}
