#include <bits/stdc++.h>
using namespace std;
int now[6];
int main() {
  fflush(stdout);
  int a, b, k = 0, i, j;
  for (i = 0; i <= 9; i++) {
    for (j = 1; j <= 4; j++) cout << i;
    cout << "\n";
    cin >> a >> b;
    if (a || b) now[++k] = i;
    if (k == 4) break;
  }
  sort(now + 1, now + 5);
  for (i = 1; i <= 4; i++) cout << now[i];
  cout << "\n";
  cin >> a >> b;
  if (a == 4) return 0;
  while (next_permutation(now + 1, now + 5)) {
    for (i = 1; i <= 4; i++) cout << now[i];
    cout << "\n";
    cin >> a >> b;
    if (a == 4) break;
  }
  return 0;
}
