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

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

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

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

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

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

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

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

m.p = j
g.y = j
d.p = j
e.y = d
a.p = d
k.y = d
j.p = d
l.p = d
c.p = d
b.y = d
assert a.p.p.p.p.p.p.p.p.p.txt == "d"