#!/usr/bin/env python
# GistID: 3285baf647fd1403ce18
import sys
from netaddr import IPNetwork, cidr_merge, AddrFormatError
CF_ANYCAST_NETS = []
lines = []
if len(sys.argv) > 1:
with open(sys.argv[1]) as f:
for line in f.readlines():
lines.append(line)
else:
for line in sys.stdin.readlines():
lines.append(line)
for line in lines:
try:
CF_ANYCAST_NETS.append(IPNetwork(line))
except AddrFormatError:
pass
for net in cidr_merge(CF_ANYCAST_NETS):
print net