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

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

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

b = A("b")
f = B("f")
m = C("m")
a = A("a")
d = B("d")
h = C("h")
k = B("k")
n = B("n")

b.z = m
f.q = n
f.r = d
m.y = a
m.u = d
m.z = f
a.z = m
d.q = f
d.r = n
h.y = a
h.u = d
h.z = f
k.q = f
k.r = d
n.q = k
n.r = k
assert b.z.y.z.u.r.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

b = A("b")
f = B("f")
m = C("m")
a = A("a")
d = B("d")
h = C("h")
k = B("k")
n = B("n")

b.z = m
f.q = n
f.r = d
m.y = a
m.u = d
m.z = f
a.z = m
d.q = f
d.r = n
h.y = a
h.u = d
h.z = f
k.q = f
k.r = d
n.q = k
n.r = k
assert b.z.y.z.u.r.r.q.txt == "f"