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

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

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

e = A("e")
n = B("n")
f = C("f")
h = C("h")
j = A("j")
d = B("d")
k = A("k")
c = B("c")

e.z = n
e.q = n
e.r = c
n.s = h
f.r = e
h.r = j
j.z = d
j.r = d
j.q = c
d.s = f
k.z = c
k.r = d
k.q = d
c.s = f
assert k.z.s.r.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: B = None
        self.q: B = None
        self.txt = txt

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

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

e = A("e")
n = B("n")
f = C("f")
h = C("h")
j = A("j")
d = B("d")
k = A("k")
c = B("c")

e.z = n
e.q = n
e.r = c
n.s = h
f.r = e
h.r = j
j.z = d
j.r = d
j.q = c
d.s = f
k.z = c
k.r = d
k.q = d
c.s = f
assert k.z.s.r.r.s.txt == "f"