class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.t: C = None
        self.r: 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.q: C = None
        self.t: D = None
        self.txt = txt

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

c = A("c")
a = B("a")
l = C("l")
e = D("e")
f = D("f")
g = D("g")
n = C("n")
k = D("k")
m = B("m")

c.v = g
c.t = n
c.r = a
a.p = m
l.q = n
l.t = f
e.p = c
f.p = c
g.p = c
n.q = l
n.t = g
k.p = c
m.p = a
assert m.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.t: C = None
        self.r: 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.q: C = None
        self.t: D = None
        self.txt = txt

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

c = A("c")
a = B("a")
l = C("l")
e = D("e")
f = D("f")
g = D("g")
n = C("n")
k = D("k")
m = B("m")

c.v = g
c.t = n
c.r = a
a.p = m
l.q = n
l.t = f
e.p = c
f.p = c
g.p = c
n.q = l
n.t = g
k.p = c
m.p = a
assert m.p.p.p.p.p.txt == "a"