def reduce(args):
if len(args) < <NUM_LIT:2>: return args<EOL>args.sort()<EOL>ret = [args[<NUM_LIT:0>]]<EOL>for next_i, (s, e) in enumerate(args, start=<NUM_LIT:1>):<EOL><INDENT>if next_i == len(args):<EOL><INDENT>ret[-<NUM_LIT:1>] = ret[-<NUM_LIT:1>][<NUM_LIT:0>], max(ret[-<NUM_LIT:1>][<NUM_LIT:1>], e)<EOL>break<EOL><DEDENT>ns, ne = args[next_i]<EOL>if e > ns or ret[-<NUM_LIT:1>][<NUM_LIT:1>] > ns:<EOL><INDENT>ret[-<NUM_LIT:1>] = ret[-<NUM_LIT:1>][<NUM_LIT:0>], max(e, ne, ret[-<NUM_LIT:1>][<NUM_LIT:1>])<EOL><DEDENT>else:<EOL><INDENT>ret.append((ns, ne))<EOL><DEDENT><DEDENT>return ret<EOL>
>>> reduce([(2, 4), (4, 9)])
[(2, 4), (4, 9)]

>>> reduce([(2, 6), (4, 10)])
[(2, 10)]