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

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

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

a = A("a")
h = B("h")
i = C("i")
l = B("l")
d = B("d")
j = C("j")
g = A("g")
n = A("n")

a.v = i
a.z = l
h.r = g
i.p = a
l.r = n
d.r = g
j.p = a
g.v = j
g.z = d
n.v = j
n.z = h
assert n.v.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.z: B = None
        self.txt = txt

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

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

a = A("a")
h = B("h")
i = C("i")
l = B("l")
d = B("d")
j = C("j")
g = A("g")
n = A("n")

a.v = i
a.z = l
h.r = g
i.p = a
l.r = n
d.r = g
j.p = a
g.v = j
g.z = d
n.v = j
n.z = h
assert n.v.p.z.txt == "l"