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

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

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

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

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

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

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

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

k.p = c
k.o = n
k.z = j
m.p = l
m.u = n
j.r = k
j.v = g
c.p = l
c.u = n
g.p = m
g.u = n
n.r = k
n.v = m
l.p = c
l.u = n
assert c.p.u.r.p.txt == "c"