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

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

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

h = A("h")
e = B("e")
d = C("d")
k = B("k")
m = C("m")
b = C("b")
n = A("n")
f = B("f")
g = C("g")

h.y = g
e.w = h
e.v = f
d.y = m
k.w = h
k.v = e
m.y = g
b.y = g
n.y = g
f.w = n
f.v = e
g.y = m
assert h.y.y.y.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

h = A("h")
e = B("e")
d = C("d")
k = B("k")
m = C("m")
b = C("b")
n = A("n")
f = B("f")
g = C("g")

h.y = g
e.w = h
e.v = f
d.y = m
k.w = h
k.v = e
m.y = g
b.y = g
n.y = g
f.w = n
f.v = e
g.y = m
assert h.y.y.y.y.y.y.y.y.y.txt == "g"