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

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

j = A("j")
b = B("b")
d = A("d")

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

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

j = A("j")
b = B("b")
d = A("d")

j.t = b
j.z = b
b.p = d
b.v = d
d.t = b
d.z = b
assert j.t.p.z.txt == "b"