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

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

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

h = A("h")
c = B("c")
g = C("g")
e = B("e")
i = C("i")
n = C("n")
m = C("m")
a = C("a")
b = A("b")
l = C("l")

h.q = c
c.s = e
c.y = m
c.z = h
g.t = h
e.s = c
e.y = l
e.z = h
i.t = b
n.t = b
m.t = h
a.t = b
b.q = e
l.t = h
assert l.t.q.z.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

h = A("h")
c = B("c")
g = C("g")
e = B("e")
i = C("i")
n = C("n")
m = C("m")
a = C("a")
b = A("b")
l = C("l")

h.q = c
c.s = e
c.y = m
c.z = h
g.t = h
e.s = c
e.y = l
e.z = h
i.t = b
n.t = b
m.t = h
a.t = b
b.q = e
l.t = h
assert l.t.q.z.q.z.txt == "h"