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

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

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

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

i = A("i")
d = B("d")
m = C("m")
e = D("e")
j = D("j")
h = D("h")

i.s = m
i.u = m
i.o = m
d.x = m
m.u = h
e.x = d
j.x = d
h.x = d
assert j.x.x.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.u: C = None
        self.o: C = None
        self.txt = txt

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

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

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

i = A("i")
d = B("d")
m = C("m")
e = D("e")
j = D("j")
h = D("h")

i.s = m
i.u = m
i.o = m
d.x = m
m.u = h
e.x = d
j.x = d
h.x = d
assert j.x.x.u.x.txt == "d"