#include <bits/stdc++.h>
using namespace std;
string p = "0000";
signed main() {
  ios ::sync_with_stdio(false);
  cin.tie(0);
  cout << p << "\n" << flush;
  long long bulls, cows;
  long long b = 0, c = 0, i = 0, j = 0, t = 0;
  while (cin >> bulls >> cows) {
    t += 1;
    if (bulls == 4 && cows == 0) {
      break;
    }
    if (bulls < b && t > 1) {
      j -= 1;
      if (j < 0) j = 9;
      p[i] = (char)(j + '0');
      i += 1;
      j = 0;
    } else {
      j += 1;
      if (j == 10) j = 0;
      p[i] = (char)(j + '0');
      i = i;
    }
    cout << p << "\n" << flush;
    b = bulls, c = cows;
  }
}
