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

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

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

c = A("c")
k = B("k")
f = C("f")
d = B("d")
n = B("n")
l = B("l")
m = C("m")

c.w = k
c.v = m
k.p = d
k.y = l
f.r = m
f.q = c
f.t = n
d.p = n
d.y = n
n.p = k
n.y = l
l.p = d
l.y = d
m.r = f
m.q = c
m.t = d
assert d.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.v: C = None
        self.txt = txt

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

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

c = A("c")
k = B("k")
f = C("f")
d = B("d")
n = B("n")
l = B("l")
m = C("m")

c.w = k
c.v = m
k.p = d
k.y = l
f.r = m
f.q = c
f.t = n
d.p = n
d.y = n
n.p = k
n.y = l
l.p = d
l.y = d
m.r = f
m.q = c
m.t = d
assert d.p.p.p.p.txt == "n"