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

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

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

c = A("c")
m = B("m")
k = C("k")
a = B("a")
j = B("j")
n = A("n")
f = C("f")

c.r = n
c.v = n
c.z = n
m.p = a
m.o = c
m.r = c
k.x = f
k.v = n
a.p = j
a.o = c
a.r = c
j.p = a
j.o = c
j.r = c
n.r = c
n.v = c
n.z = c
f.x = k
f.v = c
assert m.p.p.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.v: A = None
        self.z: A = None
        self.txt = txt

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

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

c = A("c")
m = B("m")
k = C("k")
a = B("a")
j = B("j")
n = A("n")
f = C("f")

c.r = n
c.v = n
c.z = n
m.p = a
m.o = c
m.r = c
k.x = f
k.v = n
a.p = j
a.o = c
a.r = c
j.p = a
j.o = c
j.r = c
n.r = c
n.v = c
n.z = c
f.x = k
f.v = c
assert m.p.p.r.r.txt == "n"