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

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

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

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

e = A("e")
g = B("g")
d = C("d")
m = D("m")

e.q = g
e.v = m
g.z = m
g.o = m
d.y = e
d.o = m
d.u = m
d.w = g
m.x = e
assert d.y.v.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.v: D = None
        self.txt = txt

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

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

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

e = A("e")
g = B("g")
d = C("d")
m = D("m")

e.q = g
e.v = m
g.z = m
g.o = m
d.y = e
d.o = m
d.u = m
d.w = g
m.x = e
assert d.y.v.x.q.txt == "g"