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

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

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

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

c.o = f
f.q = k
k.x = c
k.z = c
assert f.q.z.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

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

c.o = f
f.q = k
k.x = c
k.z = c
assert f.q.z.o.txt == "f"