#include <bits/stdc++.h>
using namespace std;
int prob[10], decrypt_algorithm[15][2];
int maximum(int a, int b, int i, int j) { return a > b ? i : j; }
void print_guessed_string(int a, int b, int c, int d) {
  cout << a << b << c << d << endl;
  fflush(stdout);
  return;
}
void guess_secret_string() {
  int i, j, bulls, cows, max_nonzero, t = 4;
  stack<int> code;
  for (i = 0; i < 10; i++) {
    print_guessed_string(i, i, i, i);
    cin >> bulls >> cows;
    if (bulls) {
      prob[i] = 1;
      code.push(i);
    } else {
      prob[i] = 0;
      j = i;
    }
  }
  int a, b, c, d;
  i = code.top();
  while (code.size() > 0) {
    code.pop();
    print_guessed_string(i, j, j, j);
    cin >> bulls >> cows;
    if (bulls) {
      a = i;
    }
    print_guessed_string(j, i, j, j);
    cin >> bulls >> cows;
    if (bulls) {
      b = i;
    }
    print_guessed_string(j, j, i, j);
    cin >> bulls >> cows;
    if (bulls) {
      c = i;
    }
    print_guessed_string(j, j, j, i);
    cin >> bulls >> cows;
    if (bulls) {
      d = i;
    }
    if (code.size()) i = code.top();
  }
  print_guessed_string(a, b, c, d);
  return;
}
int main() {
  ios::sync_with_stdio(false);
  guess_secret_string();
  return 0;
}
