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

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

d = A("d")
n = B("n")
l = B("l")
j = A("j")
i = B("i")
b = A("b")

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

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

d = A("d")
n = B("n")
l = B("l")
j = A("j")
i = B("i")
b = A("b")

d.t = n
n.z = d
l.z = j
j.t = i
i.z = d
b.t = i
assert b.t.z.t.txt == "n"