#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;
vector<int> v;
int main() {
  for (int i = 0; i < 10; i++) {
    string s = "";
    for (int j = 0; j < 4; j++) s += '0' + i;
    cout << s << "\n";
    fflush(stdout);
    int b, c;
    cin >> b >> c;
    fflush(stdout);
    if (b == 0) continue;
    v.push_back(i);
    if (v.size() == 4) break;
  }
  int a[] = {0, 1, 2, 3};
  do {
    string s = "";
    for (int i = 0; i < 4; i++) s += '0' + v[a[i]];
    cout << s << "\n";
    fflush(stdout);
    int b, c;
    cin >> b >> c;
    if (b == 4 && c == 0) return 0;
  } while (next_permutation(a, a + 4));
  return 0;
}
