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

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

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

class D:
    def __init__(self, txt: str):
        self.r: B = None
        self.w: B = None
        self.p: A = None
        self.txt = txt

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

h.s = d
d.z = i
d.x = i
d.u = f
d.p = m
f.o = d
f.r = i
i.r = d
i.w = d
i.p = m
m.s = d
a.o = d
a.r = i
assert a.o.p.s.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: B = None
        self.w: B = None
        self.p: A = None
        self.txt = txt

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

h.s = d
d.z = i
d.x = i
d.u = f
d.p = m
f.o = d
f.r = i
i.r = d
i.w = d
i.p = m
m.s = d
a.o = d
a.r = i
assert a.o.p.s.u.r.txt == "i"