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

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

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

f = A("f")
b = B("b")
l = C("l")
a = B("a")

f.y = b
b.v = l
b.z = a
l.v = a
l.x = f
a.v = l
a.z = b
assert a.v.v.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

f = A("f")
b = B("b")
l = C("l")
a = B("a")

f.y = b
b.v = l
b.z = a
l.v = a
l.x = f
a.v = l
a.z = b
assert a.v.v.z.z.txt == "a"