#!python3
import itertools
def three_sum(listnum):
possibility = itertools.combinations(listnum, 3)
list_res = []
for pos in possibility:
sum = 0
for num in pos:
sum += num
if sum == 0:
list_res.append(pos)
for i,l in enumerate(list_res):
list_res[i] = tuple(sorted(l))
list_res = set(tuple(list_res))
for i in list_res:
for j in i:
print(str(j)+' ', end='')
print()
print('----------------------------------------------')
three_sum([9, -6, -5, 9, 8, 3, -4, 8, 1, 7, -4, 9, -9, 1, 9, -9, 9, 4, -6, -8])
print('----------------------------------------------')
three_sum([4, 5, -1, -2, -7, 2, -5, -3, -7, -3, 1])
print('----------------------------------------------')
three_sum([-1, -6, -3, -7, 5, -8, 2, -8, 1])
print('----------------------------------------------')
three_sum([-5, -1, -4, 2, 9, -9, -6, -1, -7])
IyFweXRob24zCgppbXBvcnQgaXRlcnRvb2xzCgpkZWYgdGhyZWVfc3VtKGxpc3RudW0pOgogICAgCiAgICBwb3NzaWJpbGl0eSA9IGl0ZXJ0b29scy5jb21iaW5hdGlvbnMobGlzdG51bSwgMykKICAgIGxpc3RfcmVzID0gW10KCiAgICBmb3IgcG9zIGluIHBvc3NpYmlsaXR5OgogICAgICAgIHN1bSA9IDAKICAgICAgICBmb3IgbnVtIGluIHBvczoKICAgICAgICAgICAgc3VtICs9IG51bQogICAgICAgIGlmIHN1bSA9PSAwOgogICAgICAgICAgICBsaXN0X3Jlcy5hcHBlbmQocG9zKQoKICAgIGZvciBpLGwgaW4gZW51bWVyYXRlKGxpc3RfcmVzKToKICAgICAgICBsaXN0X3Jlc1tpXSA9IHR1cGxlKHNvcnRlZChsKSkKICAgIGxpc3RfcmVzID0gc2V0KHR1cGxlKGxpc3RfcmVzKSkKCiAgICBmb3IgaSBpbiBsaXN0X3JlczoKICAgICAgICBmb3IgaiBpbiBpOgogICAgICAgICAgICBwcmludChzdHIoaikrJyAnLCBlbmQ9JycpCiAgICAgICAgcHJpbnQoKQoKcHJpbnQoJy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t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