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

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

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

c = A("c")
k = B("k")
g = C("g")
i = B("i")
a = C("a")
m = C("m")
h = A("h")

c.s = m
k.r = i
k.y = i
k.s = c
g.w = c
g.u = h
i.r = k
i.y = k
i.s = c
a.w = h
a.u = h
m.w = h
m.u = c
h.s = g
assert m.u.s.u.s.u.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

c = A("c")
k = B("k")
g = C("g")
i = B("i")
a = C("a")
m = C("m")
h = A("h")

c.s = m
k.r = i
k.y = i
k.s = c
g.w = c
g.u = h
i.r = k
i.y = k
i.s = c
a.w = h
a.u = h
m.w = h
m.u = c
h.s = g
assert m.u.s.u.s.u.s.w.txt == "h"