#!/usr/bin/env python3 import urllib.request exec(urllib.request.urlopen('https://eval.dan.co.jp/friends/2026/10/31/c0ff0ef5348609407d7df832dff85896f864a9cfc694b5feed038db12423e4e6').read()) def gen(i,b): if i==7: st=[0]*7 for bl in b: m=min(bl) for x in bl:st[x]=m yield tuple(st) else: for j in range(len(b)): b[j].append(i) yield from gen(i-(-1),b) b[j].pop() b.append([i]) yield from gen(i-(-1),b) b.pop() def direct(st): A=set() for u,v in S0: for v2,w in T0: if st[v]==st[v2] and st[u]!=st[w] and st[v]!=st[w]:A.add((st[u],st[v],st[w])) return sorted(A) allp=list(gen(0,[])) print('partitions',len(allp)) bad=[st for st in allp if trg(st)!=direct(st)] print('bad',len(bad)) allterm=[st for st in allp if not direct(st)] print('allterm',len(allterm)) rt=[st for st in seen if not trg(st)] print('reachterm',len(rt),'subset',all(st in allterm for st in rt)) un=[st for st in allterm if st not in seen] print('unreached',len(un)) print(sorted(''.join('abcdefg'[i] for i in st) for st in un)[:50])