#include <bits/stdc++.h>
using namespace std;
int main() {
  string ans = "";
  for (int i = 0; i <= 9; i++) {
    string s = "";
    for (int j = 0; j < 4; j++) s += to_string(i);
    cout << s << endl;
    int b, c;
    cin >> b >> c;
    if (b == 1 && c == 0) ans += to_string(i);
  }
  sort(ans.begin(), ans.end());
  do {
    cout << ans << endl;
    int b, c;
    cin >> b >> c;
    if (b == 4 && c == 0) break;
  } while (next_permutation(ans.begin(), ans.end()));
}
