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

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

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

n = A("n")
g = B("g")
k = C("k")
l = C("l")
f = B("f")
b = A("b")
j = A("j")
e = C("e")

n.w = j
g.p = l
k.r = g
l.r = f
f.p = e
b.w = j
j.w = b
e.r = g
assert g.p.r.p.r.p.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

n = A("n")
g = B("g")
k = C("k")
l = C("l")
f = B("f")
b = A("b")
j = A("j")
e = C("e")

n.w = j
g.p = l
k.r = g
l.r = f
f.p = e
b.w = j
j.w = b
e.r = g
assert g.p.r.p.r.p.r.p.txt == "e"