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

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

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

b = A("b")
m = B("m")
f = C("f")
c = C("c")
e = A("e")

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

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

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

b = A("b")
m = B("m")
f = C("f")
c = C("c")
e = A("e")

b.s = m
m.p = e
m.u = b
f.v = e
f.u = m
f.x = c
c.v = e
c.u = m
c.x = f
e.s = m
assert e.s.p.s.p.s.txt == "m"