#include <bits/stdc++.h>
using namespace std;
struct Q {
  int a, b, c, d;
  Q(int x, int y, int z, int w) : a(x), b(y), c(z), d(w) {}
};
pair<int, int> query(Q z) {
  int u, v;
  printf("%d%d%d%d\n", z.a, z.b, z.c, z.d);
  fflush(stdout);
  scanf("%d%d", &u, &v);
  return make_pair(u, v);
}
pair<int, int> dist(Q e, Q f) {
  int bulls = 0, cows = 0;
  if (e.a == f.a) bulls++;
  if (e.b == f.b) bulls++;
  if (e.c == f.c) bulls++;
  if (e.d == f.d) bulls++;
  if ((e.a == f.a) || (e.a == f.b) || (e.a == f.c) || (e.a == f.d)) cows++;
  if ((e.b == f.a) || (e.b == f.b) || (e.b == f.c) || (e.b == f.d)) cows++;
  if ((e.c == f.a) || (e.c == f.b) || (e.c == f.c) || (e.c == f.d)) cows++;
  if ((e.d == f.a) || (e.d == f.b) || (e.d == f.c) || (e.d == f.d)) cows++;
  return make_pair(bulls, cows - bulls);
}
int main() {
  vector<Q> X;
  for (int i = 0; i < 10; ++i)
    for (int j = 0; j < 10; ++j)
      if (i - j) {
        for (int k = 0; k < 10; ++k)
          if ((i - k) && (j - k)) {
            for (int l = 0; l < 10; ++l)
              if ((i - l) && (j - l) && (k - l)) {
                Q h(i, j, k, l);
                X.push_back(h);
              }
          }
      }
  int bulls = 0, cows = 0;
  while (bulls < 4) {
    pair<int, int> Z = query(X[0]);
    bulls = Z.first;
    cows = Z.second;
    vector<Q> Y;
    Q V = X[0];
    for (int i = 0; i < X.size(); ++i) {
      pair<int, int> T = dist(V, X[i]);
      if (T.first == bulls && T.second == cows) Y.push_back(X[i]);
    }
    X = Y;
  }
  return 0;
}
