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

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

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

a = A("a")
c = B("c")
f = C("f")
g = C("g")
j = A("j")
m = A("m")
l = B("l")

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

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

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

a = A("a")
c = B("c")
f = C("f")
g = C("g")
j = A("j")
m = A("m")
l = B("l")

a.s = c
c.y = g
f.u = g
f.r = g
f.y = c
g.u = f
g.r = f
g.y = c
j.s = l
m.s = c
l.y = g
assert c.y.u.y.y.u.y.y.txt == "g"