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

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

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

j = A("j")
a = B("a")
n = C("n")
d = C("d")

j.z = n
j.p = n
j.y = a
a.q = n
n.s = d
n.v = j
n.t = j
d.s = n
d.v = j
d.t = j
assert a.q.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.y: B = None
        self.p: C = None
        self.txt = txt

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

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

j = A("j")
a = B("a")
n = C("n")
d = C("d")

j.z = n
j.p = n
j.y = a
a.q = n
n.s = d
n.v = j
n.t = j
d.s = n
d.v = j
d.t = j
assert a.q.v.z.txt == "n"