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

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

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

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

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

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

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

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

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

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

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

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

b.o = d
g.s = l
i.z = d
d.w = b
d.u = m
d.y = a
d.q = i
d.r = g
l.x = d
l.t = d
l.w = i
a.o = d
m.z = d
assert d.u.z.y.o.txt == "d"