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

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

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

a = A("a")
c = B("c")
f = C("f")
k = C("k")
d = A("d")

a.v = f
c.s = a
f.y = d
k.y = a
d.v = f
assert c.s.v.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

a = A("a")
c = B("c")
f = C("f")
k = C("k")
d = A("d")

a.v = f
c.s = a
f.y = d
k.y = a
d.v = f
assert c.s.v.y.v.txt == "f"