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

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

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

h = A("h")
i = B("i")
b = C("b")
d = B("d")
e = C("e")
a = C("a")
c = A("c")
g = A("g")
f = B("f")
k = B("k")

h.z = e
h.p = b
h.s = d
i.z = e
b.q = h
b.p = a
d.z = a
e.q = h
e.p = a
a.q = h
a.p = e
c.z = b
c.p = e
c.s = f
g.z = e
g.p = b
g.s = k
f.z = a
k.z = b
assert c.z.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.p: C = None
        self.s: B = None
        self.txt = txt

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

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

h = A("h")
i = B("i")
b = C("b")
d = B("d")
e = C("e")
a = C("a")
c = A("c")
g = A("g")
f = B("f")
k = B("k")

h.z = e
h.p = b
h.s = d
i.z = e
b.q = h
b.p = a
d.z = a
e.q = h
e.p = a
a.q = h
a.p = e
c.z = b
c.p = e
c.s = f
g.z = e
g.p = b
g.s = k
f.z = a
k.z = b
assert c.z.p.q.txt == "h"