#include <bits/stdc++.h>
using namespace std;
int cnt = 0, flag = 0;
int bull, cow;
int ans = 0;
int lastb = 0, lastc = 0;
vector<int> chos;
vector<string> aa;
int p = 0;
void makeans() {
  char ss[5];
  ss[0] = chos[0] + '0';
  ss[1] = chos[1] + '0';
  ss[2] = chos[2] + '0';
  ss[3] = chos[3] + '0';
  ss[4] = '\0';
  string ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[0] + '0';
  ss[1] = chos[1] + '0';
  ss[2] = chos[3] + '0';
  ss[3] = chos[2] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[0] + '0';
  ss[1] = chos[2] + '0';
  ss[2] = chos[1] + '0';
  ss[3] = chos[3] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[0] + '0';
  ss[1] = chos[2] + '0';
  ss[2] = chos[3] + '0';
  ss[3] = chos[1] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[0] + '0';
  ss[1] = chos[3] + '0';
  ss[2] = chos[1] + '0';
  ss[3] = chos[2] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[0] + '0';
  ss[1] = chos[3] + '0';
  ss[2] = chos[2] + '0';
  ss[3] = chos[1] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[1] + '0';
  ss[1] = chos[0] + '0';
  ss[2] = chos[2] + '0';
  ss[3] = chos[3] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[1] + '0';
  ss[1] = chos[0] + '0';
  ss[2] = chos[3] + '0';
  ss[3] = chos[2] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[1] + '0';
  ss[1] = chos[2] + '0';
  ss[2] = chos[0] + '0';
  ss[3] = chos[3] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[1] + '0';
  ss[1] = chos[2] + '0';
  ss[2] = chos[3] + '0';
  ss[3] = chos[0] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[1] + '0';
  ss[1] = chos[3] + '0';
  ss[2] = chos[0] + '0';
  ss[3] = chos[2] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[1] + '0';
  ss[1] = chos[3] + '0';
  ss[2] = chos[2] + '0';
  ss[3] = chos[0] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[2] + '0';
  ss[1] = chos[0] + '0';
  ss[2] = chos[1] + '0';
  ss[3] = chos[3] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[2] + '0';
  ss[1] = chos[0] + '0';
  ss[2] = chos[3] + '0';
  ss[3] = chos[1] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[2] + '0';
  ss[1] = chos[3] + '0';
  ss[2] = chos[0] + '0';
  ss[3] = chos[1] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[2] + '0';
  ss[1] = chos[3] + '0';
  ss[2] = chos[1] + '0';
  ss[3] = chos[0] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[2] + '0';
  ss[1] = chos[1] + '0';
  ss[2] = chos[0] + '0';
  ss[3] = chos[3] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[2] + '0';
  ss[1] = chos[1] + '0';
  ss[2] = chos[3] + '0';
  ss[3] = chos[0] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[3] + '0';
  ss[1] = chos[0] + '0';
  ss[2] = chos[1] + '0';
  ss[3] = chos[2] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[3] + '0';
  ss[1] = chos[0] + '0';
  ss[2] = chos[2] + '0';
  ss[3] = chos[1] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[3] + '0';
  ss[1] = chos[1] + '0';
  ss[2] = chos[0] + '0';
  ss[3] = chos[2] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[3] + '0';
  ss[1] = chos[1] + '0';
  ss[2] = chos[2] + '0';
  ss[3] = chos[0] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[3] + '0';
  ss[1] = chos[2] + '0';
  ss[2] = chos[1] + '0';
  ss[3] = chos[0] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
  ss[0] = chos[3] + '0';
  ss[1] = chos[2] + '0';
  ss[2] = chos[0] + '0';
  ss[3] = chos[1] + '0';
  ansss = (string)ss;
  aa.push_back(ansss);
}
int main() {
  int mak = 1;
  for (int i = 0; i < 10; ++i) {
    printf("%d%d%d%d\n", ans, ans, ans, ans);
    fflush(stdout);
    cin >> bull >> cow;
    if ((cow + bull > 0) && chos.size() < 4) {
      chos.push_back(ans);
    }
    ans++;
    if (chos.size() >= 4) break;
  }
  makeans();
  for (int i = 0; i < 24; ++i) {
    cout << aa[i] << endl;
    fflush(stdout);
    cin >> bull >> cow;
    if (bull == 4) {
      flag = 1;
      break;
    }
  }
  return 0;
}
