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

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.q: A = None
        self.o: A = None
        self.txt = txt

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

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

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

d.u = i
m.p = d
m.q = d
m.o = d
i.u = m
i.t = m
i.w = h
h.x = i
h.z = i
h.v = e
e.p = d
e.q = d
e.o = d
assert i.w.z.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.q: A = None
        self.o: A = None
        self.txt = txt

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

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

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

d.u = i
m.p = d
m.q = d
m.o = d
i.u = m
i.t = m
i.w = h
h.x = i
h.z = i
h.v = e
e.p = d
e.q = d
e.o = d
assert i.w.z.t.o.txt == "d"