#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int bulls, cows, non_used_dig;
  for (int i = 0; i < 10; i++) {
    cout << i << i << i << i << '\n' << flush;
    cin >> bulls >> cows;
    if (bulls == 0 && cows == 0) {
      non_used_dig = i;
      break;
    }
  }
  int digs[4], ind = 0;
  for (int i = 0; i < 10; i++) {
    cout << i << non_used_dig << non_used_dig << non_used_dig << '\n' << flush;
    cin >> bulls >> cows;
    if (bulls != 0 || cows != 0) {
      digs[ind++] = i;
    }
  }
  do {
    cout << digs[0] << digs[1] << digs[2] << digs[3] << '\n' << flush;
    cin >> bulls >> cows;
    if (bulls == 4) {
      break;
    }
  } while (next_permutation(digs, digs + 4));
  return 0;
}
