#include <bits/stdc++.h>
using namespace std;
set<int> pool;
bool valid(int x) {
  set<int> q;
  for (int i = 0; i < 4; ++i) {
    q.insert(x % 10);
    x /= 10;
  }
  return q.size() == 4;
}
bool check(int x, int y, int u, int v) {
  vector<int> X(4), Y(4);
  set<int> XS, YS;
  for (int i = 0; i < 4; ++i) {
    X[i] = x % 10;
    Y[i] = y % 10;
    XS.insert(x % 10);
    YS.insert(y % 10);
    x /= 10;
    y /= 10;
  }
  int cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < 4; ++i) {
    if (X[i] == Y[i]) {
      cnt1++;
      XS.erase(X[i]);
      YS.erase(Y[i]);
    }
  }
  if (cnt1 != u) return false;
  for (auto m : YS)
    if (XS.count(m)) cnt2++;
  if (cnt2 != v) return false;
  return true;
}
void init() {
  for (int n = 0; n < 10000; ++n) {
    if (valid(n)) pool.insert(n);
  }
}
int main() {
  std::ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  init();
  while (!pool.empty()) {
    int y = *pool.begin();
    int y1 = y;
    for (int i = 0; i < 4; ++i) {
      cout << y1 % 10;
      y1 /= 10;
    }
    cout << endl;
    fflush(stdout);
    int u, v;
    cin >> u >> v;
    if (u == 4) return 0;
    set<int> tmp;
    for (auto x : pool)
      if (check(x, y, u, v)) tmp.insert(x);
    pool.swap(tmp);
  }
}
