#include <bits/stdc++.h>
using namespace std;
const double Pi = acos(-1);
const long long over999 = 1234567890;
const double eps = 1e-9;
string s;
long long DA, x, NET, y;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  s = "0000";
  for (int i = x + y; i < 4; i = x + y) {
    cout << s << "\n";
    cout << flush;
    ;
    cin >> DA >> NET;
    if (DA == 4) return 0;
    if (DA + NET > x + y) {
      x = DA, y = NET;
      for (int j = i + 1; j < 4; j++) {
        s[j]++;
      }
    } else {
      for (int j = i; j < 4; j++) {
        s[j]++;
      }
    }
  }
  sort(s.begin(), s.end());
  cout << s << "\n";
  cout << flush;
  ;
  cin >> x >> y;
  while (x < 4) {
    next_permutation(s.begin(), s.end());
    cout << s << "\n";
    cout << flush;
    ;
    cin >> x >> y;
  }
  return 0;
}
