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

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

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

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

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

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

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

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

i.z = f
b.v = f
b.y = l
b.q = i
l.t = b
f.v = b
f.y = l
f.q = i
assert f.y.t.v.txt == "f"