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

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

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

h = A("h")
f = B("f")
b = C("b")
g = B("g")
e = A("e")
a = A("a")
n = C("n")

h.z = g
h.t = n
f.s = n
b.q = h
b.w = f
b.u = f
g.s = b
e.z = g
e.t = n
a.z = f
a.t = n
n.q = a
n.w = f
n.u = g
assert n.u.s.w.s.w.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.t: C = None
        self.txt = txt

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

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

h = A("h")
f = B("f")
b = C("b")
g = B("g")
e = A("e")
a = A("a")
n = C("n")

h.z = g
h.t = n
f.s = n
b.q = h
b.w = f
b.u = f
g.s = b
e.z = g
e.t = n
a.z = f
a.t = n
n.q = a
n.w = f
n.u = g
assert n.u.s.w.s.w.s.q.txt == "a"