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

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

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

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

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

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

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

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

j.o = m
m.p = n
k.w = n
g.o = m
l.p = i
n.p = i
b.w = m
i.p = l
assert i.p.p.p.p.p.txt == "l"