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

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

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

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

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

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

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

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

k.y = g
b.y = i
l.o = m
d.y = c
m.o = l
c.y = d
j.o = m
g.y = k
i.y = c
assert c.y.y.y.y.y.txt == "d"