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

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

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

h = A("h")
a = B("a")
e = C("e")
f = B("f")
i = C("i")
k = B("k")
g = B("g")
n = B("n")

h.s = e
a.u = h
a.z = h
e.q = g
e.r = f
f.u = h
f.z = h
i.q = n
i.r = n
k.u = h
k.z = h
g.u = h
g.z = h
n.u = h
n.z = h
assert i.r.u.s.q.z.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

h = A("h")
a = B("a")
e = C("e")
f = B("f")
i = C("i")
k = B("k")
g = B("g")
n = B("n")

h.s = e
a.u = h
a.z = h
e.q = g
e.r = f
f.u = h
f.z = h
i.q = n
i.r = n
k.u = h
k.z = h
g.u = h
g.z = h
n.u = h
n.z = h
assert i.r.u.s.q.z.s.r.txt == "f"