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

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

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

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

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

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

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

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

h.z = k
h.s = e
b.y = e
b.z = m
b.p = m
m.q = k
n.q = k
e.y = k
e.z = m
e.p = m
k.y = b
k.z = g
k.p = n
d.z = k
d.s = b
g.q = k
f.z = k
f.s = e
assert b.z.q.z.q.z.txt == "g"