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

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

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

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

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

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

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

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

f.s = a
c.v = f
b.u = c
b.r = c
b.x = m
m.u = c
m.r = c
m.x = b
a.s = f
assert c.v.s.s.txt == "f"