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

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

class C:
    def __init__(self, txt: str):
        self.t: A = None
        self.u: A = None
        self.v: B = None
        self.s: B = None
        self.txt = txt

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

e = A("e")
l = B("l")
g = C("g")
m = D("m")
i = B("i")

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

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

class C:
    def __init__(self, txt: str):
        self.t: A = None
        self.u: A = None
        self.v: B = None
        self.s: B = None
        self.txt = txt

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

e = A("e")
l = B("l")
g = C("g")
m = D("m")
i = B("i")

e.z = l
e.q = m
e.y = g
l.w = m
l.t = g
l.s = g
g.t = e
g.u = e
g.v = l
g.s = l
m.t = l
m.v = g
m.o = e
i.w = m
i.t = g
i.s = g
assert m.o.z.w.t.s.txt == "g"