#include <bits/stdc++.h>
using namespace std;
int main() {
  int b[10], c[10];
  int m[4] = {0};
  int i = 0;
  int d = 0;
  for (int a = 0; a < 10; a++) {
    cout << a << a << a << a << endl;
    cin >> b[a] >> c[a];
    if (b[a] > 0) {
      m[i] = a;
      i++;
    }
  }
  cout << m[0] << m[1] << m[2] << m[3] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[0] << m[1] << m[3] << m[2] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[0] << m[2] << m[1] << m[3] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[0] << m[2] << m[3] << m[1] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[0] << m[3] << m[1] << m[2] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[0] << m[3] << m[2] << m[1] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[1] << m[0] << m[2] << m[3] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[1] << m[0] << m[3] << m[2] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[1] << m[2] << m[0] << m[3] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[1] << m[2] << m[3] << m[0] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[1] << m[3] << m[0] << m[2] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[1] << m[3] << m[2] << m[0] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[2] << m[1] << m[0] << m[3] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[2] << m[1] << m[3] << m[0] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[2] << m[0] << m[1] << m[3] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[2] << m[0] << m[3] << m[1] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[2] << m[3] << m[1] << m[0] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[2] << m[3] << m[0] << m[1] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[3] << m[1] << m[2] << m[0] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[3] << m[1] << m[0] << m[2] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[3] << m[2] << m[1] << m[0] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[3] << m[2] << m[0] << m[1] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[3] << m[0] << m[1] << m[2] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
  cout << m[3] << m[0] << m[2] << m[1] << endl;
  cin >> i >> d;
  if (i == 4) return 0;
}
