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

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

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

c = A("c")
e = B("e")
d = C("d")
j = A("j")
g = B("g")
i = A("i")
f = B("f")
h = A("h")
m = C("m")
a = C("a")

c.s = g
c.q = e
e.z = i
d.r = f
d.y = g
d.q = e
j.s = e
j.q = f
g.z = j
i.s = f
i.q = e
f.z = h
h.s = g
h.q = g
m.r = e
m.y = g
m.q = f
a.r = e
a.y = f
a.q = g
assert a.r.z.s.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.q: B = None
        self.txt = txt

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

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

c = A("c")
e = B("e")
d = C("d")
j = A("j")
g = B("g")
i = A("i")
f = B("f")
h = A("h")
m = C("m")
a = C("a")

c.s = g
c.q = e
e.z = i
d.r = f
d.y = g
d.q = e
j.s = e
j.q = f
g.z = j
i.s = f
i.q = e
f.z = h
h.s = g
h.q = g
m.r = e
m.y = g
m.q = f
a.r = e
a.y = f
a.q = g
assert a.r.z.s.z.q.txt == "g"