class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.t: A = None
        self.txt = txt

l = A("l")
b = B("b")
h = A("h")
c = B("c")
k = B("k")
g = B("g")
n = A("n")
m = A("m")
f = B("f")

l.p = h
b.z = h
b.t = h
h.p = l
c.z = l
c.t = m
k.z = m
k.t = l
g.z = h
g.t = m
n.p = m
m.p = n
f.z = l
f.t = n
assert k.z.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.t: A = None
        self.txt = txt

l = A("l")
b = B("b")
h = A("h")
c = B("c")
k = B("k")
g = B("g")
n = A("n")
m = A("m")
f = B("f")

l.p = h
b.z = h
b.t = h
h.p = l
c.z = l
c.t = m
k.z = m
k.t = l
g.z = h
g.t = m
n.p = m
m.p = n
f.z = l
f.t = n
assert k.z.p.p.txt == "m"