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

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

j = A("j")
a = B("a")
n = B("n")
c = B("c")
i = B("i")
d = B("d")

j.o = i
a.t = d
a.z = d
n.t = i
n.z = a
c.t = i
c.z = a
i.t = d
i.z = a
d.t = a
d.z = n
assert d.z.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

j = A("j")
a = B("a")
n = B("n")
c = B("c")
i = B("i")
d = B("d")

j.o = i
a.t = d
a.z = d
n.t = i
n.z = a
c.t = i
c.z = a
i.t = d
i.z = a
d.t = a
d.z = n
assert d.z.t.z.txt == "a"