#include <bits/stdc++.h>
using namespace std;
long long m[4], x, y, a;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  for (long long i = 0; i < 10; ++i) {
    cout << i << i << i << i << endl;
    cin >> x >> y;
    if (x == 1) m[a++] = i;
  }
  for (long long i = 0; i < 24; ++i) {
    next_permutation(m, m + 4);
    for (long long i = 0; i < 4; ++i) cout << m[i];
    cout << endl;
    cin >> x >> y;
    if (x == 4) return cout << endl, 0;
  }
}
