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

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

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

f = A("f")
d = B("d")
k = C("k")
n = A("n")

f.o = k
d.x = f
d.t = k
d.z = k
k.z = f
k.t = d
k.y = d
n.o = k
assert f.o.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

f = A("f")
d = B("d")
k = C("k")
n = A("n")

f.o = k
d.x = f
d.t = k
d.z = k
k.z = f
k.t = d
k.y = d
n.o = k
assert f.o.y.z.txt == "k"