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

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

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

k = A("k")
b = B("b")
i = C("i")
g = A("g")
m = A("m")
l = A("l")
d = B("d")
f = C("f")
c = C("c")
h = A("h")

k.y = g
b.o = f
i.o = m
i.w = h
g.y = k
m.y = g
l.y = g
d.o = f
f.o = g
f.w = m
c.o = k
c.w = k
h.y = g
assert k.y.y.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

k = A("k")
b = B("b")
i = C("i")
g = A("g")
m = A("m")
l = A("l")
d = B("d")
f = C("f")
c = C("c")
h = A("h")

k.y = g
b.o = f
i.o = m
i.w = h
g.y = k
m.y = g
l.y = g
d.o = f
f.o = g
f.w = m
c.o = k
c.w = k
h.y = g
assert k.y.y.y.y.y.y.y.y.txt == "k"