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

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

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

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

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

j.t = d
j.o = d
j.z = c
d.q = j
d.t = c
f.q = d
c.v = j
c.w = f
assert j.o.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.o: B = None
        self.z: D = None
        self.txt = txt

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

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

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

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

j.t = d
j.o = d
j.z = c
d.q = j
d.t = c
f.q = d
c.v = j
c.w = f
assert j.o.q.t.txt == "d"