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

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

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

n = A("n")
e = B("e")
d = C("d")
c = C("c")
k = C("k")
a = B("a")

n.v = d
e.z = n
e.t = a
d.q = k
d.r = e
d.s = e
c.q = d
c.r = a
c.s = e
k.q = d
k.r = a
k.s = e
a.z = n
a.t = e
assert d.s.t.z.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

n = A("n")
e = B("e")
d = C("d")
c = C("c")
k = C("k")
a = B("a")

n.v = d
e.z = n
e.t = a
d.q = k
d.r = e
d.s = e
c.q = d
c.r = a
c.s = e
k.q = d
k.r = a
k.s = e
a.z = n
a.t = e
assert d.s.t.z.v.r.txt == "e"