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

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

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

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

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

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

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

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

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

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

e.o = g
e.r = g
e.y = g
e.q = l
g.r = m
g.z = m
g.t = a
g.s = e
m.r = l
m.s = a
m.p = g
l.w = e
l.r = g
a.r = l
a.s = m
a.p = g
assert e.q.w.o.s.o.txt == "g"