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

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

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

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

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

b.s = h
b.r = h
c.s = b
c.u = a
h.z = b
h.r = d
h.u = c
f.x = i
f.p = a
f.y = b
a.s = b
a.u = c
d.z = b
d.r = h
d.u = a
i.x = f
i.p = a
i.y = b
assert a.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.r: C = None
        self.txt = txt

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

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

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

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

b.s = h
b.r = h
c.s = b
c.u = a
h.z = b
h.r = d
h.u = c
f.x = i
f.p = a
f.y = b
a.s = b
a.u = c
d.z = b
d.r = h
d.u = a
i.x = f
i.p = a
i.y = b
assert a.u.u.u.txt == "c"