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

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

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

j = A("j")
h = B("h")
n = C("n")
d = A("d")
c = A("c")
a = B("a")
m = C("m")
i = B("i")
b = A("b")

j.z = h
j.s = n
j.q = m
h.r = a
n.w = d
d.z = i
d.s = m
d.q = m
c.z = h
c.s = n
c.q = n
a.r = i
m.w = c
i.r = h
b.z = a
b.s = m
b.q = m
assert c.z.r.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.s: C = None
        self.q: C = None
        self.txt = txt

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

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

j = A("j")
h = B("h")
n = C("n")
d = A("d")
c = A("c")
a = B("a")
m = C("m")
i = B("i")
b = A("b")

j.z = h
j.s = n
j.q = m
h.r = a
n.w = d
d.z = i
d.s = m
d.q = m
c.z = h
c.s = n
c.q = n
a.r = i
m.w = c
i.r = h
b.z = a
b.s = m
b.q = m
assert c.z.r.r.r.r.r.r.r.txt == "a"