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

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

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

b = A("b")
a = B("a")
f = C("f")
g = B("g")
l = C("l")
j = B("j")
d = B("d")
m = A("m")
k = B("k")

b.u = g
a.y = j
a.w = m
f.s = l
g.y = k
g.w = m
l.s = f
j.y = d
j.w = b
d.y = j
d.w = m
m.u = j
k.y = g
k.w = b
assert j.w.u.w.u.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

b = A("b")
a = B("a")
f = C("f")
g = B("g")
l = C("l")
j = B("j")
d = B("d")
m = A("m")
k = B("k")

b.u = g
a.y = j
a.w = m
f.s = l
g.y = k
g.w = m
l.s = f
j.y = d
j.w = b
d.y = j
d.w = m
m.u = j
k.y = g
k.w = b
assert j.w.u.w.u.w.u.txt == "g"