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

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

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

m = A("m")
j = B("j")
a = C("a")
f = A("f")
l = B("l")
c = C("c")
h = B("h")
b = A("b")

m.p = h
j.v = m
j.s = m
a.u = l
f.p = h
l.v = b
l.s = b
c.u = l
h.v = b
h.s = f
b.p = l
assert j.s.p.s.p.s.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

m = A("m")
j = B("j")
a = C("a")
f = A("f")
l = B("l")
c = C("c")
h = B("h")
b = A("b")

m.p = h
j.v = m
j.s = m
a.u = l
f.p = h
l.v = b
l.s = b
c.u = l
h.v = b
h.s = f
b.p = l
assert j.s.p.s.p.s.p.v.txt == "b"