#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int INF = (int)1e9 + 7;
const long long LINF = (long long)9e18 + 7;
const long long P1 = 353251;
const long long P2 = 239017;
const long long MOD = 1e9 + 7;
const long long MOD1 = 1e9 + 7;
const long long MOD2 = 1e9 + 9;
const bool is_testing = 0;
int main() {
  srand('D' + 'E' + 'N' + 'I' + 'S' + 'S' + 'O' + 'N');
  if (is_testing) {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  } else {
  }
  vector<int> d;
  for (int i = 0; i <= 9; i++) {
    for (int j = 0; j < 4; j++) cout << i;
    cout << endl;
    cout.flush();
    int x, y;
    cin >> x >> y;
    if (x + y != 0) d.push_back(i);
  }
  vector<int> s;
  for (int i = 0; i < 4; i++) s.push_back(i);
  do {
    for (int i = 0; i < 4; i++) cout << d[s[i]];
    cout << endl;
    cout.flush();
    int x, y;
    cin >> x >> y;
    if (x == 4) exit(0);
  } while (next_permutation(s.begin(), s.end()));
}
