#include <bits/stdc++.h>
using namespace std;
int main() {
  string s = "";
  int a, b;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 4; j++) cout << i;
    cout << endl;
    fflush(stdout);
    cin >> a >> b;
    if (a == 1) s += (char)(i + '0');
  }
  do {
    cout << s << endl;
    fflush(stdout);
    cin >> a >> b;
    if (a == 4) return 0;
  } while (next_permutation(s.begin(), s.end()));
}
