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

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

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

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

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

g = A("g")
j = B("j")
m = C("m")
d = D("d")
f = E("f")

g.t = j
j.t = m
j.s = m
m.u = j
m.s = d
d.o = m
d.r = m
d.s = f
d.x = f
f.s = m
assert d.o.s.x.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

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

g = A("g")
j = B("j")
m = C("m")
d = D("d")
f = E("f")

g.t = j
j.t = m
j.s = m
m.u = j
m.s = d
d.o = m
d.r = m
d.s = f
d.x = f
f.s = m
assert d.o.s.x.s.s.txt == "d"