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

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

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

b = A("b")
j = B("j")
n = C("n")
g = C("g")
h = B("h")
l = B("l")
m = A("m")

b.s = l
j.w = n
j.s = l
j.t = b
n.z = m
g.z = b
h.w = g
h.s = j
h.t = m
l.w = g
l.s = j
l.t = m
m.s = h
assert m.s.w.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

b = A("b")
j = B("j")
n = C("n")
g = C("g")
h = B("h")
l = B("l")
m = A("m")

b.s = l
j.w = n
j.s = l
j.t = b
n.z = m
g.z = b
h.w = g
h.s = j
h.t = m
l.w = g
l.s = j
l.t = m
m.s = h
assert m.s.w.z.s.txt == "l"