#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)1e4 + 5;
const int N = (int)1e4;
int cntans[15];
bool used[MAXN];
int m[MAXN];
int cnt = 0, first = 0;
pair<int, int> ans;
bool alldiff(int x) {
  int a, b, c, d;
  a = x / 1000;
  x %= 1000;
  b = x / 100;
  x %= 100;
  c = x / 10;
  x %= 10;
  d = x;
  return (a != b && a != c && a != d && b != c && b != d && c != d);
}
void gen(int i, int x) {
  if (i == 4) {
    if (alldiff(x)) {
      m[cnt] = x;
      cnt++;
    }
  } else {
    for (int j = 0; j < 10; j++) gen(i + 1, x * 10 + j);
  }
}
pair<int, int> getans(int x, int y) {
  pair<int, int> p = make_pair(0, 0);
  int a1, b1, c1, d1, a2, b2, c2, d2;
  a1 = x / 1000;
  x %= 1000;
  b1 = x / 100;
  x %= 100;
  c1 = x / 10;
  x %= 10;
  d1 = x;
  a2 = y / 1000;
  y %= 1000;
  b2 = y / 100;
  y %= 100;
  c2 = y / 10;
  y %= 10;
  d2 = y;
  if (a1 == a2) p.first++;
  if (b1 == b2) p.first++;
  if (c1 == c2) p.first++;
  if (d1 == d2) p.first++;
  if ((a2 == b1 || a2 == c1 || a2 == d1) && a2 != a1) p.second++;
  if ((b2 == a1 || b2 == c1 || b2 == d1) && b2 != b1) p.second++;
  if ((c2 == a1 || c2 == b1 || c2 == d1) && c2 != c1) p.second++;
  if ((d2 == a1 || d2 == b1 || d2 == c1) && d2 != d1) p.second++;
  return p;
}
void go(int x) {
  int a, b, c, d, tx = x;
  a = x / 1000;
  x %= 1000;
  b = x / 100;
  x %= 100;
  c = x / 10;
  x %= 10;
  d = x;
  cout << a << b << c << d << endl;
  fflush(stdout);
  cin >> ans.first >> ans.second;
  if (ans.first == 4) exit(0);
  for (int i = first; i < cnt; i++)
    if (getans(tx, m[i]) != ans) {
      swap(m[i], m[first]);
      first++;
    }
  used[tx] = 1;
}
int counts(int x, bool &f) {
  f = false;
  for (int i = 0; i < 15; i++) cntans[i] = 0;
  for (int i = first; i < cnt; i++) {
    pair<int, int> q = getans(x, m[i]);
    if (q.first == 0 && q.second == 0) cntans[0]++;
    if (q.first == 0 && q.second == 1) cntans[1]++;
    if (q.first == 0 && q.second == 2) cntans[2]++;
    if (q.first == 0 && q.second == 3) cntans[3]++;
    if (q.first == 0 && q.second == 4) cntans[4]++;
    if (q.first == 1 && q.second == 0) cntans[5]++;
    if (q.first == 1 && q.second == 1) cntans[6]++;
    if (q.first == 1 && q.second == 2) cntans[7]++;
    if (q.first == 1 && q.second == 3) cntans[8]++;
    if (q.first == 2 && q.second == 0) cntans[9]++;
    if (q.first == 2 && q.second == 1) cntans[10]++;
    if (q.first == 2 && q.second == 2) cntans[11]++;
    if (q.first == 3 && q.second == 0) cntans[12]++;
    if (q.first == 4 && q.second == 0) cntans[13]++;
    if (m[i] == x) f = true;
  }
  int mx = 0;
  for (int i = 0; i < 14; i++) {
    mx = max(mx, cntans[i]);
  }
  return mx;
}
int best() {
  int mn = (int)1e9;
  int thebest = 0;
  bool flag = false;
  for (int i = 0; i < (int)1e4; i++)
    if (!used[i]) {
      bool f;
      int mx;
      mx = counts(i, f);
      if (mx < mn || (mx == mn && !flag && f)) {
        mn = mx;
        thebest = i;
        flag = f;
      }
    }
  return thebest;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  gen(0, 0);
  int good = m[rand() % cnt];
  for (int i = 0; i < 7; i++) {
    go(good);
    good = best();
  }
}
