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

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

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

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

m = A("m")
g = B("g")
b = C("b")
d = D("d")
i = D("i")
a = C("a")
l = C("l")

m.q = g
g.t = i
b.r = l
b.v = d
b.z = m
d.w = b
d.o = i
i.w = b
i.o = d
a.r = l
a.v = i
a.z = m
l.r = b
l.v = i
l.z = m
assert b.z.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

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

m = A("m")
g = B("g")
b = C("b")
d = D("d")
i = D("i")
a = C("a")
l = C("l")

m.q = g
g.t = i
b.r = l
b.v = d
b.z = m
d.w = b
d.o = i
i.w = b
i.o = d
a.r = l
a.v = i
a.z = m
l.r = b
l.v = i
l.z = m
assert b.z.q.t.txt == "i"