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

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

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

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

c.y = l
k.s = c
g.p = l
g.s = f
g.v = b
m.s = c
l.p = g
l.s = f
l.v = f
f.s = c
a.s = c
b.s = c
assert g.s.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

c.y = l
k.s = c
g.p = l
g.s = f
g.v = b
m.s = c
l.p = g
l.s = f
l.v = f
f.s = c
a.s = c
b.s = c
assert g.s.s.y.txt == "l"