#include <bits/stdc++.h>
using namespace std;
int used[4];
vector<string> v;
vector<char> ans;
string num;
void backtrack(string num, int level) {
  if (level == 4) {
    v.push_back(num);
    return;
  }
  for (int i = (0); i <= (3); i++) {
    if (used[i] == 0) {
      used[i] = 1;
      char c = ans[i];
      backtrack(num + c, level + 1);
      used[i] = 0;
    }
  }
}
int main() {
  for (int i = ('0'); i <= ('9'); i++) {
    string t = "";
    for (int j = (0); j <= (3); j++) t += i;
    cout << t << "\n";
    fflush(stdout);
    int cow, bull;
    scanf("%d %d", &bull, &cow);
    if (bull >= 1) ans.push_back(i);
  }
  backtrack("", 0);
  for (int i = (0); i <= (((int)v.size()) - 1); i++) {
    cout << v[i] << "\n";
    fflush(stdout);
    int cow, bull;
    scanf("%d %d", &bull, &cow);
    if (bull == 4) {
      return 0;
    }
  }
  return 0;
}
