Under construction

Still being built. Things may change

range

Time limit0.5sMemory limit1024 MB

Summary
Given one Python range call, print the lexicographically smallest range call that produces the same sequence of numbers.
Level

Medium4 of 10

Topics
Implementation, Math
Solved
No attempts yet

Problem

Python, one of the languages supported by SNUPC, has a class named range. This class was made to represent finite arithmetic sequences.

A finite arithmetic sequence {ai}=[a0,…,aL−1]\{a_i\} = [a_0, \ldots, a_{L-1}] can be characterized by three integers s, e, and d (d ≠\ne 0). It is the finite subsequence of an arithmetic sequence {Di}\{D_i\} with first term s and common difference d, made of all elements x that satisfy ∣d∣ds≤∣d∣dx<∣d∣de\frac{|d|}{d} s \le \frac{|d|}{d} x < \frac{|d|}{d} e. For example, with s = 0, e = 5, and d = 1, the sequence is [0, 1, 2, 3, 4].

The length of a finite arithmetic sequence is the size of the set of its numbers. In the example above, the length is 5. Two finite arithmetic sequences {ai}\{a_i\} and {bi}\{b_i\} are equal when they have the same length L and ai=bia_i = b_i for every integer 0 ≤\le i << L.

range supports three forms.

  • range(a) represents the sequence with s = 0, e = a, and d = 1.
  • range(a,b) represents the sequence with s = a, e = b, and d = 1.
  • range(a,b,c) represents the sequence with s = a, e = b, and d = c. Here c must not be 0.

When Python compares two range objects for equality, it compares the sequences they represent. For example, range(5) and range(0,5) both represent [0, 1, 2, 3, 4], so they are equal. A sequence can have length 0. For example, range(5,9,-3) and range(7,2) both have length 0, so they are equal.

Your task is to read one Python range and print a range that Python considers equal to it.

Input

The first line contains a range. Each character of the string is one of (),-0123456789aegnr. The values of a, b, and c inside the parentheses are given as integers with absolute value less than 10910^9.

An integer n is written as follows. If n is greater than 0, it consists only of decimal digits, and its first character is not 0. If n is 0, it is always 0. If n is less than 0, its first character is -, and the rest of the string writes (-n).

The number of arguments to range can be one, two, or three.

Output

On the first line, print a string that represents a range Python considers equal to the input. Integers must be written in the same format as the input rules, but the absolute value of each number does not have to be less than 10910^9.

If several strings are possible, print the lexicographically smallest one. Compare characters by ASCII order, that is, by the order of (),-0123456789aegnr, where earlier characters are smaller.

Examples3

  1. Example 1

    Input
    range(37,90,5)
    
    Expected output
    range(37,88,5)
    
  2. Example 2

    Input
    range(24,117,53)
    
    Expected output
    range(24,100,53)
    
  3. Example 3

    Input
    range(-2,10,30)
    
    Expected output
    range(-2,-1)