#include <bits/stdc++.h>
using namespace std;
int main() {
  int cows, bulls, cur = 0;
  vector<int> nums;
  for (int i = 0; i <= 9; i++) {
    for (int j = 0; j < 4; j++) cout << i;
    cout << "\n";
    fflush(stdout);
    cin >> bulls >> cows;
    if (bulls) nums.push_back(i);
    if (nums.size() == 4) break;
  }
  bool f = 0;
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      if (j == i) continue;
      for (int k = 0; k < 4; k++) {
        if (k == j || k == i) continue;
        for (int l = 0; l < 4; l++) {
          if (l == k || l == j || l == i) continue;
          cout << nums[i] << nums[j] << nums[k] << nums[l] << "\n";
          fflush(stdout);
          cin >> bulls >> cows;
          if (bulls == 4) {
            f = 1;
            break;
          }
        }
        if (f) break;
      }
      if (f) break;
    }
    if (f) break;
  }
  return 0;
}
