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

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

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

m = A("m")
n = B("n")
l = C("l")
c = B("c")
e = A("e")
j = C("j")
g = B("g")
d = A("d")

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

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

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

m = A("m")
n = B("n")
l = C("l")
c = B("c")
e = A("e")
j = C("j")
g = B("g")
d = A("d")

m.z = c
m.r = c
m.v = j
n.v = e
l.p = n
c.v = e
e.z = n
e.v = j
e.r = c
j.p = c
g.v = m
d.z = g
d.r = g
d.v = l
assert g.v.v.p.v.r.txt == "c"