#include <stdio.h>
#include <time.h>
int main(void){
	int a = 1, n, f = 0;
	char c;
	
	for(n=0;n<10;++n)scanf("%*d %*c %*c %*c");
	
	while( scanf("%d%c %*c %*c %*c", &n, &c ), n != 0 ){
		if( c == ' ' ){
			clock_t c1 = a * CLOCKS_PER_SEC / 50 + clock();
			while( clock() < c1 );
			if( f++ ) return 0;
			c1 = CLOCKS_PER_SEC / 2 + clock();
			while(clock() < c1);
		}
		++a;
	}
return 0;
}