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

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

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

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

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

n = A("n")
m = B("m")
c = C("c")
d = D("d")
g = E("g")

n.u = m
m.z = c
m.t = c
m.x = g
c.v = d
d.w = g
g.o = d
assert g.o.w.o.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

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

n = A("n")
m = B("m")
c = C("c")
d = D("d")
g = E("g")

n.u = m
m.z = c
m.t = c
m.x = g
c.v = d
d.w = g
g.o = d
assert g.o.w.o.w.o.txt == "d"