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

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

m = A("m")
a = B("a")
j = B("j")
f = A("f")
b = B("b")
i = B("i")
e = A("e")
n = B("n")
k = A("k")

m.u = k
a.p = k
a.z = e
j.p = e
j.z = k
f.u = m
b.p = f
b.z = f
i.p = e
i.z = k
e.u = f
n.p = m
n.z = k
k.u = m
assert a.p.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

m = A("m")
a = B("a")
j = B("j")
f = A("f")
b = B("b")
i = B("i")
e = A("e")
n = B("n")
k = A("k")

m.u = k
a.p = k
a.z = e
j.p = e
j.z = k
f.u = m
b.p = f
b.z = f
i.p = e
i.z = k
e.u = f
n.p = m
n.z = k
k.u = m
assert a.p.u.u.u.u.u.txt == "m"