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

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

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

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

class E:
    def __init__(self, txt: str):
        self.s: C = None
        self.y: D = None
        self.txt = txt

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.s: C = None
        self.y: D = None
        self.txt = txt

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

m.x = d
m.p = d
m.z = g
d.s = l
d.t = l
e.r = m
e.p = g
e.x = l
g.t = l
g.q = e
l.s = e
l.y = g
assert l.s.x.y.txt == "g"