Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from itertools import permutations
- from functools import reduce
- print(*next(
- reduce(
- lambda x, y: filter(
- lambda z: (z[y[0] - 1] < z[y[1] - 1] and z[y[2] - 1] > z[y[3] - 1]) \
- or (z[y[0] - 1] > z[y[1] - 1] and z[y[2] - 1] < z[y[3] - 1]),
- x
- ),
- [permutations(range(
- 1,
- int(open('input.txt').readline().split()[0]) + 1
- )
- )
- ] +
- list(
- map(
- lambda x: tuple(map(int, str.split(x))),
- open('input.txt').readlines()[1:]
- )
- )
- ),
- [0]
- ))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement