def main():
    lines = sys.stdin.readlines()
    ips = [parseline(line) for line in lines]
    ips = [ip for ip in ips if (ip is not None)]
    ips = [ip for ip in ips if (ip['ip'] not in SUSPICIOUS_HOSTS)]
    ips = [ip for ip in ips if (ip['blocks'] >= MIN_BLOCKS)]
    ips = [ip for ip in ips if ((ip['service'] & 1) == 1)]
    ips = [ip for ip in ips if (ip['uptime'] > 50)]
    ips = [ip for ip in ips if PATTERN_AGENT.match(re.sub(' ', '-', ip['agent']))]
    ips.sort(key=(lambda x: (x['uptime'], x['lastsuccess'], x['ip'])), reverse=True)
    ips = filtermultiport(ips)
    ips = filterbyasn(ips, MAX_SEEDS_PER_ASN, NSEEDS)
    ips.sort(key=(lambda x: (x['net'], x['sortkey'])))
    for ip in ips:
        if (ip['net'] == 'ipv6'):
            print(('[%s]:%i' % (ip['ip'], ip['port'])))
        else:
            print(('%s:%i' % (ip['ip'], ip['port'])))
def main():
    lines = sys.stdin.readlines()
    ips = [parseline(line) for line in lines]
    ips = [ip for ip in ips if (ip is not None)]
    ips = [ip for ip in ips if (ip['ip'] not in SUSPICIOUS_HOSTS)]
    ips = [ip for ip in ips if (ip['blocks'] >= MIN_BLOCKS)]
    ips = [ip for ip in ips if ((ip['service'] & 1) == 1)]
    ips = [ip for ip in ips if (ip['uptime'] > 50)]
    ips = [ip for ip in ips if PATTERN_AGENT.match(re.sub(' ', '-', ip['agent']))]
    ips.sort(key=(lambda x: (x['uptime'], x['lastsuccess'], x['ip'])), reverse=True)
    ips = filtermultiport(ips)
    ips = filterbyasn(ips, MAX_SEEDS_PER_ASN, NSEEDS)
    ips.sort(key=(lambda x: (x['net'], x['sortkey'])))
    for ip in ips:
        if (ip['net'] == 'ipv6'):
            print(('[%s]:%i' % (ip['ip'], ip['port'])))
        else:
            print(('%s:%i' % (ip['ip'], ip['port'])))