#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

long long first  [10];	// d0*
long long current[10];	// d.*
long long last   [10];	// d9*

#define CYCLE 16
long long digit  [CYCLE];	// first digit as 2^d (cyclic)

long long started = 0;	// mask of pending digits

int main() {
	for (int d=0; d<=9; d++) {
		first[d] = current[d] = last[d] = d;
	}

	memset(digit, 0, sizeof(digit));

	int k = 0;
	for (long long n=1;; n++) {
		if (started==0) {
			printf("%lld %lld\n", ++k, n);
			fflush(stdout);
			if (k==10000) {
				break;
			}
		}

		if (digit[n % CYCLE]==0) {
			long long vv = LLONG_MAX;
			long long bb = 0;
			long long dd = 0;

			for (int d=1, b=1; d<=9; d++,b*=2) {
				if ((started & b)==0 && !digit[(n+1+d)%CYCLE]) {
					if (vv > current[d]) {
						vv = current[d];
						dd = d;
						bb = b;
					}
				}
			}

			if (dd) {
				started += digit[(n+1+dd)%CYCLE] = bb;

				// consume 2 numbers
				for (int c=0; c<=1; c++) {
					if (current[dd]==last[dd]) {
						current[dd] = first[dd] = 10 * first[dd];
						last[dd] = 10 * last[dd] + 9;
					} else {
						current[dd]++;
					}
				}
			} else {
				fprintf(stderr, "# the end\n");
				exit(1);
			}

		} else {
			// second term of a pair
			started -= digit[n % CYCLE];
			digit[n % CYCLE] = 0;
		}
	}

	return 0;
}