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

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

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

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

f = A("f")
b = B("b")
c = C("c")
d = D("d")
e = A("e")
j = D("j")
i = A("i")

f.v = d
f.t = d
b.q = e
c.y = i
d.z = e
e.v = j
e.t = d
j.z = f
i.v = d
i.t = d
assert d.z.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.t: D = None
        self.txt = txt

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

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

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

f = A("f")
b = B("b")
c = C("c")
d = D("d")
e = A("e")
j = D("j")
i = A("i")

f.v = d
f.t = d
b.q = e
c.y = i
d.z = e
e.v = j
e.t = d
j.z = f
i.v = d
i.t = d
assert d.z.t.z.txt == "e"