while 1:R,S=eval(input()[5:].replace('* range',','));M=min,max;print('range(%d,%d)'%tuple(m(f(R)*g(S)for f in M for g in M)for m in M))