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

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

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

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

n.p = b
h.p = g
b.s = c
b.r = c
b.v = m
c.s = b
c.r = b
c.v = a
l.p = g
j.p = b
k.p = c
m.p = b
g.p = h
a.p = b
assert n.p.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

n.p = b
h.p = g
b.s = c
b.r = c
b.v = m
c.s = b
c.r = b
c.v = a
l.p = g
j.p = b
k.p = c
m.p = b
g.p = h
a.p = b
assert n.p.v.p.txt == "b"